Added completed signal to machine action, so model can notify display that it is completed

CURA-1385
This commit is contained in:
Jaime van Kessel 2016-06-21 16:19:44 +02:00
parent 181d16aad8
commit 65751d7400
4 changed files with 29 additions and 8 deletions

View file

@ -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))

View file

@ -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()
}
}
}

View file

@ -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()
}

View file

@ -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)
}
}