Improve MessageBox when clicking Next/Prev without saving image

This commit is contained in:
Chris Rapson (AT) 2020-08-24 14:13:16 +12:00 committed by darrenl
parent 544cfb9e3c
commit 39b0d68f09

View File

@ -1392,12 +1392,22 @@ class MainWindow(QMainWindow, WindowMixin):
proc.startDetached(os.path.abspath(__file__)) proc.startDetached(os.path.abspath(__file__))
def mayContinue(self): def mayContinue(self):
return not (self.dirty and not self.discardChangesDialog()) if not self.dirty:
return True
else:
discardChanges = self.discardChangesDialog()
if discardChanges == QMessageBox.No:
return True
elif discardChanges == QMessageBox.Yes:
self.saveFile()
return True
else:
return False
def discardChangesDialog(self): def discardChangesDialog(self):
yes, no = QMessageBox.Yes, QMessageBox.No yes, no, cancel = QMessageBox.Yes, QMessageBox.No, QMessageBox.Cancel
msg = u'You have unsaved changes, proceed anyway?' msg = u'You have unsaved changes, would you like to save them and proceed?\nClick "No" to undo all changes.'
return yes == QMessageBox.warning(self, u'Attention', msg, yes | no) return QMessageBox.warning(self, u'Attention', msg, yes | no | cancel)
def errorMessage(self, title, message): def errorMessage(self, title, message):
return QMessageBox.critical(self, title, return QMessageBox.critical(self, title,