diff --git a/cura/MachineAction.py b/cura/MachineAction.py index d3e0449fc6..8bdd02fe26 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -22,8 +22,10 @@ class MachineAction(QObject, PluginObject): self._component = None self._context = None self._view = None + self._finished = False labelChanged = pyqtSignal() + onFinished = pyqtSignal() def getKey(self): return self._key @@ -46,6 +48,7 @@ class MachineAction(QObject, PluginObject): # /sa _reset @pyqtSlot() def reset(self): + self._finished = False self._reset() ## Protected implementation of reset. @@ -53,9 +56,18 @@ class MachineAction(QObject, PluginObject): def _reset(self): pass + @pyqtSlot() + def setFinished(self): + self._finished = True + self.onFinished.emit() + def _execute(self): raise NotImplementedError("Execute() must be implemented") + @pyqtProperty(bool, notify = onFinished) + def finished(self): + return self._finished + def _createViewFromQML(self): path = QUrl.fromLocalFile( os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url)) diff --git a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml index b392358dd5..8a3bf8d96a 100644 --- a/plugins/UltimakerMachineActions/BedLevelMachineAction.qml +++ b/plugins/UltimakerMachineActions/BedLevelMachineAction.qml @@ -11,7 +11,7 @@ import Cura 1.0 as Cura // The action items always need to be wrapped in a component. -Component +Cura.MachineAction { Item { @@ -77,6 +77,7 @@ Component text: catalog.i18nc("@action:button","Skip bed leveling"); onClicked: { + manager.setFinished() } } } diff --git a/resources/qml/MachineAction.qml b/resources/qml/MachineAction.qml new file mode 100644 index 0000000000..ca8a22141d --- /dev/null +++ b/resources/qml/MachineAction.qml @@ -0,0 +1,10 @@ +import QtQuick 2.2 + +Item +{ + id: contentItem + // Connect the finished property change to completed signal. + property var finished: manager.finished + onFinishedChanged: if(manager.finished) {completed()} + signal completed() +} \ No newline at end of file diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index 3535bfbaf0..dcc5e3d9c1 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -53,7 +53,7 @@ UM.ManagementPage text: machineActionRepeater.model[index].label; onClicked: { - actionDialog.sourceComponent = machineActionRepeater.model[index].displayItem + actionDialog.content = machineActionRepeater.model[index].displayItem actionDialog.show() } } @@ -63,13 +63,11 @@ UM.ManagementPage UM.Dialog { id: actionDialog - - // We need to use a property because a window has it's own context. - property var sourceComponent - - Loader + property var content + onContentChanged: { - sourceComponent: actionDialog.sourceComponent + contents = content; + content.onCompleted.connect(hide) } }