Skip to content
Permalink
Browse files

[processing] better unsaved change dialog upon closing script editor

  • Loading branch information
nirvn committed May 20, 2018
1 parent 5a4d33f commit 2ad74b9d9798a05346ad0a0afd637ca1f26f914c
Showing with 14 additions and 8 deletions.
  1. +14 −8 python/plugins/processing/script/ScriptEditorDialog.py
@@ -119,20 +119,26 @@ def __init__(self, filePath=None, parent=None):
self.setHasChanged(False)

def closeEvent(self, event):
settings = QgsSettings()
settings.setValue("/Processing/stateScriptEditor", self.saveState())
settings.setValue("/Processing/geometryScriptEditor", self.saveGeometry())

if self.hasChanged:
ret = QMessageBox.question(self,
self.tr("Unsaved changes"),
self.tr("There are unsaved changes in the script. Continue?"),
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No
)
if ret == QMessageBox.Yes:
ret = QMessageBox.question(
self, self.tr('Save Script?'),
self.tr('There are unsaved changes in this script. Do you want to keep those?'),
QMessageBox.Save | QMessageBox.Cancel | QMessageBox.Discard, QMessageBox.Cancel)

if ret == QMessageBox.Save:
self.updateProvider()
self.saveScript(False)
event.accept()
elif ret == QMessageBox.Discard:
self.updateProvider()
event.accept()
else:
event.ignore()
else:
self.updateProvider()
event.accept()

def updateProvider(self):

0 comments on commit 2ad74b9

Please sign in to comment.
You can’t perform that action at this time.