From 927f19327044e4d0fa0205b76b9d4a007f5db7bc Mon Sep 17 00:00:00 2001 From: Ruben D Date: Sun, 4 Feb 2018 01:26:34 +0100 Subject: [PATCH] Only write scripts to stack upon pressing close button This is more efficient, because we're not writing every time you modify the list of scripts. It's also more complete, since if you don't modify the list of scripts but just modify one of the settings, that setting change also gets written to the stack after closing the window. --- plugins/PostProcessingPlugin/PostProcessingPlugin.py | 5 +++-- plugins/PostProcessingPlugin/PostProcessingPlugin.qml | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 7f53ab4672..9cc369a0d9 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -39,7 +39,7 @@ class PostProcessingPlugin(QObject, Extension): Application.getInstance().getOutputDeviceManager().writeStarted.connect(self.execute) Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged) #When the current printer changes, update the list of scripts. Application.getInstance().mainWindowChanged.connect(self._createView) #When the main window is created, create the view so that we can display the post-processing icon if necessary. - self.scriptListChanged.connect(self._writeScriptsToStack) #Whenever there is a change, save it into the stack. + #self.scriptListChanged.connect(self.writeScriptsToStack) #Whenever there is a change, save it into the stack. selectedIndexChanged = pyqtSignal() @pyqtProperty("QVariant", notify = selectedIndexChanged) @@ -219,7 +219,8 @@ class PostProcessingPlugin(QObject, Extension): self.setSelectedScriptIndex(0) self.scriptListChanged.emit() - def _writeScriptsToStack(self): + @pyqtSlot() + def writeScriptsToStack(self): script_list_strs = [] for script in self._script_list: parser = configparser.ConfigParser(interpolation = None) #We'll encode the script as a config with one section. The section header is the key and its values are the settings. diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.qml b/plugins/PostProcessingPlugin/PostProcessingPlugin.qml index d64d60a04a..d2508f0cad 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.qml +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.qml @@ -21,6 +21,14 @@ UM.Dialog minimumWidth: 400 * screenScaleFactor; minimumHeight: 250 * screenScaleFactor; + onVisibleChanged: + { + if(!visible) //Whenever the window is closed (either via the "Close" button or the X on the window frame), we want to update it in the stack. + { + manager.writeScriptsToStack(); + } + } + Item { UM.I18nCatalog{id: catalog; name:"cura"}