mirror of https://gitlab.com/pamhyr/pamhyr2
Scenario: Save dialog at scenarios switch.
parent
2a926a8d73
commit
fa8fe508a7
|
|
@ -31,7 +31,7 @@ from PyQt5.QtGui import (
|
||||||
)
|
)
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QApplication, QGraphicsScene, QGraphicsView,
|
QApplication, QGraphicsScene, QGraphicsView,
|
||||||
QGraphicsItem, QGraphicsTextItem, QMenu,
|
QGraphicsItem, QGraphicsTextItem, QMenu, QMessageBox,
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.WaitingDialog import WaitingDialog
|
from View.WaitingDialog import WaitingDialog
|
||||||
|
|
@ -410,13 +410,37 @@ class GraphWidget(QGraphicsView):
|
||||||
)
|
)
|
||||||
m.run()
|
m.run()
|
||||||
|
|
||||||
|
def dialog_save(self):
|
||||||
|
dlg = QMessageBox(self)
|
||||||
|
|
||||||
|
dlg.setWindowTitle(self._trad["mb_save_title"])
|
||||||
|
dlg.setText(self._trad["mb_save_msg"])
|
||||||
|
opt = QMessageBox.Save | QMessageBox.Cancel
|
||||||
|
|
||||||
|
dlg.setStandardButtons(opt)
|
||||||
|
dlg.setIcon(QMessageBox.Warning)
|
||||||
|
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
|
||||||
|
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
|
||||||
|
|
||||||
|
res = dlg.exec()
|
||||||
|
|
||||||
|
if res == QMessageBox.Save:
|
||||||
|
return True
|
||||||
|
elif res == QMessageBox.Cancel:
|
||||||
|
return False
|
||||||
|
|
||||||
def select_scenario(self, item):
|
def select_scenario(self, item):
|
||||||
if type(item) is not ScenarioItem:
|
if type(item) is not ScenarioItem:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
must_saved = self.dialog_save()
|
||||||
|
|
||||||
def fn():
|
def fn():
|
||||||
self._close_other_window()
|
self._close_other_window()
|
||||||
|
|
||||||
|
if must_saved:
|
||||||
self._study.save()
|
self._study.save()
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SelectScenariosCommand(
|
SelectScenariosCommand(
|
||||||
self._study,
|
self._study,
|
||||||
|
|
|
||||||
|
|
@ -66,3 +66,10 @@ class ScenariosTranslate(MainTranslate):
|
||||||
self._dict["redo_waiting"] = _translate(
|
self._dict["redo_waiting"] = _translate(
|
||||||
"Scenarios", "Redo ..."
|
"Scenarios", "Redo ..."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._dict["mb_save_title"] = _translate(
|
||||||
|
"Scenarios", "Save scenarios before scenarios switching"
|
||||||
|
)
|
||||||
|
self._dict["mb_save_msg"] = _translate(
|
||||||
|
"Scenarios", "Save scenarios before scenarios switching ?"
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue