mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Added completed signal to machine action, so model can notify display that it is completed
CURA-1385
This commit is contained in:
parent
181d16aad8
commit
65751d7400
4 changed files with 29 additions and 8 deletions
|
@ -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))
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
resources/qml/MachineAction.qml
Normal file
10
resources/qml/MachineAction.qml
Normal 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()
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue