@@ -111,13 +111,27 @@ def __init__(self, filePath=None, parent=None):
111111 self .btnReplace .clicked .connect (self .replace )
112112 self .lastSearch = None
113113
114- self .filePath = filePath
115- if self . filePath is not None :
116- self ._loadFile (self . filePath )
114+ self .filePath = None
115+ if filePath is not None :
116+ self ._loadFile (filePath )
117117
118118 self .needUpdate = False
119119 self .setHasChanged (False )
120120
121+ def update_dialog_title (self ):
122+ """
123+ Updates the script editor dialog title
124+ """
125+ if self .filePath :
126+ path , file_name = os .path .split (self .filePath )
127+ else :
128+ file_name = self .tr ('Untitled Script' )
129+
130+ if self .hasChanged :
131+ file_name = '*' + file_name
132+
133+ self .setWindowTitle (self .tr ('{} - Processing Script Editor' ).format (file_name ))
134+
121135 def closeEvent (self , event ):
122136 settings = QgsSettings ()
123137 settings .setValue ("/Processing/stateScriptEditor" , self .saveState ())
@@ -165,7 +179,6 @@ def openScript(self):
165179
166180 with OverrideCursor (Qt .WaitCursor ):
167181 self ._loadFile (fileName )
168- self .filePath = fileName
169182
170183 def save (self ):
171184 self .saveScript (False )
@@ -205,6 +218,7 @@ def saveScript(self, saveAs):
205218 def setHasChanged (self , hasChanged ):
206219 self .hasChanged = hasChanged
207220 self .actionSaveScript .setEnabled (hasChanged )
221+ self .update_dialog_title ()
208222
209223 def runAlgorithm (self ):
210224 d = {}
@@ -275,3 +289,6 @@ def _loadFile(self, filePath):
275289 self .hasChanged = False
276290 self .editor .setModified (False )
277291 self .editor .recolor ()
292+
293+ self .filePath = filePath
294+ self .update_dialog_title ()
0 commit comments