Skip to content
Permalink
Browse files

[processing] Improved script editor dialog title

- show filename in title, or 'Untitled Script' for new
scripts
- show unsaved ('*') indicator when unsaved changes present
  • Loading branch information
nyalldawson committed May 20, 2018
1 parent 28b23d0 commit 84163841dfd8addcfefa6efd760b217dbd3d07e7
Showing with 21 additions and 4 deletions.
  1. +21 −4 python/plugins/processing/script/ScriptEditorDialog.py
@@ -111,13 +111,27 @@ def __init__(self, filePath=None, parent=None):
self.btnReplace.clicked.connect(self.replace)
self.lastSearch = None

self.filePath = filePath
if self.filePath is not None:
self._loadFile(self.filePath)
self.filePath = None
if filePath is not None:
self._loadFile(filePath)

self.needUpdate = False
self.setHasChanged(False)

def update_dialog_title(self):
"""
Updates the script editor dialog title
"""
if self.filePath:
path, file_name = os.path.split(self.filePath)
else:
file_name = self.tr('Untitled Script')

if self.hasChanged:
file_name = '*' + file_name

self.setWindowTitle(self.tr('{} - Processing Script Editor').format(file_name))

def closeEvent(self, event):
settings = QgsSettings()
settings.setValue("/Processing/stateScriptEditor", self.saveState())
@@ -165,7 +179,6 @@ def openScript(self):

with OverrideCursor(Qt.WaitCursor):
self._loadFile(fileName)
self.filePath = fileName

def save(self):
self.saveScript(False)
@@ -205,6 +218,7 @@ def saveScript(self, saveAs):
def setHasChanged(self, hasChanged):
self.hasChanged = hasChanged
self.actionSaveScript.setEnabled(hasChanged)
self.update_dialog_title()

def runAlgorithm(self):
d = {}
@@ -275,3 +289,6 @@ def _loadFile(self, filePath):
self.hasChanged = False
self.editor.setModified(False)
self.editor.recolor()

self.filePath = filePath
self.update_dialog_title()

0 comments on commit 8416384

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