mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 02:29:02 +08: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
@ -22,8 +22,10 @@ class MachineAction(QObject, PluginObject):
|
|||||||
self._component = None
|
self._component = None
|
||||||
self._context = None
|
self._context = None
|
||||||
self._view = None
|
self._view = None
|
||||||
|
self._finished = False
|
||||||
|
|
||||||
labelChanged = pyqtSignal()
|
labelChanged = pyqtSignal()
|
||||||
|
onFinished = pyqtSignal()
|
||||||
|
|
||||||
def getKey(self):
|
def getKey(self):
|
||||||
return self._key
|
return self._key
|
||||||
@ -46,6 +48,7 @@ class MachineAction(QObject, PluginObject):
|
|||||||
# /sa _reset
|
# /sa _reset
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
self._finished = False
|
||||||
self._reset()
|
self._reset()
|
||||||
|
|
||||||
## Protected implementation of reset.
|
## Protected implementation of reset.
|
||||||
@ -53,9 +56,18 @@ class MachineAction(QObject, PluginObject):
|
|||||||
def _reset(self):
|
def _reset(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def setFinished(self):
|
||||||
|
self._finished = True
|
||||||
|
self.onFinished.emit()
|
||||||
|
|
||||||
def _execute(self):
|
def _execute(self):
|
||||||
raise NotImplementedError("Execute() must be implemented")
|
raise NotImplementedError("Execute() must be implemented")
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = onFinished)
|
||||||
|
def finished(self):
|
||||||
|
return self._finished
|
||||||
|
|
||||||
def _createViewFromQML(self):
|
def _createViewFromQML(self):
|
||||||
path = QUrl.fromLocalFile(
|
path = QUrl.fromLocalFile(
|
||||||
os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), self._qml_url))
|
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.
|
// The action items always need to be wrapped in a component.
|
||||||
Component
|
Cura.MachineAction
|
||||||
{
|
{
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
@ -77,6 +77,7 @@ Component
|
|||||||
text: catalog.i18nc("@action:button","Skip bed leveling");
|
text: catalog.i18nc("@action:button","Skip bed leveling");
|
||||||
onClicked:
|
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;
|
text: machineActionRepeater.model[index].label;
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
actionDialog.sourceComponent = machineActionRepeater.model[index].displayItem
|
actionDialog.content = machineActionRepeater.model[index].displayItem
|
||||||
actionDialog.show()
|
actionDialog.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,13 +63,11 @@ UM.ManagementPage
|
|||||||
UM.Dialog
|
UM.Dialog
|
||||||
{
|
{
|
||||||
id: actionDialog
|
id: actionDialog
|
||||||
|
property var content
|
||||||
// We need to use a property because a window has it's own context.
|
onContentChanged:
|
||||||
property var sourceComponent
|
|
||||||
|
|
||||||
Loader
|
|
||||||
{
|
{
|
||||||
sourceComponent: actionDialog.sourceComponent
|
contents = content;
|
||||||
|
content.onCompleted.connect(hide)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user