Scenario: Add Discard option to scenario switching dialog.

disable_edition_parent_scenario
Pierre-Antoine 2026-05-21 16:26:51 +02:00
parent 4537a829af
commit d922436ada
2 changed files with 11 additions and 5 deletions

View File

@ -426,30 +426,35 @@ class GraphWidget(QGraphicsView):
dlg.setWindowTitle(self._trad["mb_save_title"])
dlg.setText(self._trad["mb_save_msg"])
opt = QMessageBox.Save | QMessageBox.Cancel
opt = QMessageBox.Cancel | QMessageBox.Save | QMessageBox.Discard
dlg.setStandardButtons(opt)
dlg.setIcon(QMessageBox.Warning)
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
dlg.button(QMessageBox.Discard).setText(self._trad["Don't save"])
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
res = dlg.exec()
if res == QMessageBox.Save:
return True
return "Save"
elif res == QMessageBox.Cancel:
return False
return "Cancel"
else:
return "Discard"
def select_scenario(self, item):
if type(item) is not ScenarioItem:
return
must_saved = self.dialog_save()
must_save = self.dialog_save()
if must_save == "Cancel":
return
def fn():
self._close_other_window()
if must_saved:
if must_save == "Save":
self._study.save()
self._undo.push(

View File

@ -281,6 +281,7 @@ class MainTranslate(UnitTranslate):
self._dict["No"] = _translate("MainWindow", "No")
self._dict["Cancel"] = _translate("MainWindow", "Cancel")
self._dict["Save"] = _translate("MainWindow", "Save")
self._dict["Don't save"] = _translate("MainWindow", "Don't save")
self._dict["Close"] = _translate("MainWindow", "Close")
self._dict["Solver"] = _translate("MainWindow", "Solver")