mirror of https://gitlab.com/pamhyr/pamhyr2
add 'cancel' button when closing Pamhyr2 from x button
parent
6bcbd006f1
commit
e3315c8f81
|
|
@ -348,10 +348,12 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
def closeEvent(self, event):
|
||||
if not self._close_question:
|
||||
if self._study is not None and not self._study.is_saved:
|
||||
if self.dialog_close(cancel=False):
|
||||
if self.dialog_close():
|
||||
# PAMHYR is close correctly (no crash)
|
||||
self.conf.set_close_correctly()
|
||||
super(ApplicationWindow, self).closeEvent(event)
|
||||
else:
|
||||
event.ignore()
|
||||
else:
|
||||
super(ApplicationWindow, self).closeEvent(event)
|
||||
|
||||
|
|
@ -531,7 +533,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
self.update()
|
||||
|
||||
def close_model(self):
|
||||
if not self.dialog_close(cancel=True):
|
||||
if not self.dialog_close():
|
||||
return
|
||||
|
||||
self._study = None
|
||||
|
|
@ -833,20 +835,18 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
return file
|
||||
|
||||
def dialog_close(self, cancel=True):
|
||||
def dialog_close(self):
|
||||
dlg = QMessageBox(self)
|
||||
|
||||
dlg.setWindowTitle(self._trad["mb_close_title"])
|
||||
dlg.setText(self._trad["mb_close_msg"])
|
||||
opt = QMessageBox.Save | QMessageBox.Close
|
||||
if cancel:
|
||||
opt |= QMessageBox.Cancel
|
||||
|
||||
dlg.setStandardButtons(opt)
|
||||
dlg.setIcon(QMessageBox.Warning)
|
||||
dlg.button(QMessageBox.Save).setText(self._trad["Save"])
|
||||
dlg.button(QMessageBox.Close).setText(self._trad["Close"])
|
||||
if cancel:
|
||||
dlg.button(QMessageBox.Cancel).setText(self._trad["Cancel"])
|
||||
|
||||
res = dlg.exec()
|
||||
|
|
|
|||
Loading…
Reference in New Issue