Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing]improved script editor dialog
  • Loading branch information
volaya committed Apr 24, 2014
1 parent 79757fa commit 1610d63
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/plugins/processing/gui/ScriptEditorDialog.py
Expand Up @@ -52,6 +52,8 @@ class ScriptEditorDialog(QDialog, Ui_DlgScriptEditor):

SCRIPT_PYTHON = 0
SCRIPT_R = 1

hasChanged = False

def __init__(self, algType, alg):
QDialog.__init__(self)
Expand Down Expand Up @@ -86,6 +88,7 @@ def __init__(self, algType, alg):
self.btnPaste.clicked.connect(self.editor.paste)
self.btnUndo.clicked.connect(self.editor.undo)
self.btnRedo.clicked.connect(self.editor.redo)
self.editor.textChanged.connect(lambda: self.setHasChanged(True))

self.alg = alg
self.algType = algType
Expand All @@ -98,6 +101,8 @@ def __init__(self, algType, alg):

self.update = False
self.help = None

self.setHasChanged(False)

self.editor.setLexerType(self.algType)

Expand Down Expand Up @@ -165,11 +170,14 @@ def saveScript(self, saveAs):
pickle.dump(self.help, f)
f.close()
self.help = None
QMessageBox.information(self, self.tr('Script saving'),
self.tr('Script was correctly saved.'))
self.setHasChanged(False)
else:
self.filename = None

def setHasChanged(self, hasChanged):
self.hasChanged = hasChanged
self.btnSave.setEnabled(hasChanged)

def runAlgorithm(self):
if self.algType == self.SCRIPT_PYTHON:
alg = ScriptAlgorithm(None, unicode(self.editor.text()))
Expand Down

0 comments on commit 1610d63

Please sign in to comment.