diff --git a/cura/MachineAction.py b/cura/MachineAction.py index 98e156d834..8ca9b63679 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -33,6 +33,7 @@ class MachineAction(QObject, PluginObject): self._qml_url = "" self._view = None self._finished = False + self._open_as_dialog = True labelChanged = pyqtSignal() onFinished = pyqtSignal() @@ -79,6 +80,15 @@ class MachineAction(QObject, PluginObject): pass + @pyqtSlot() + def execute(self) -> None: + self._execute() + + def _execute(self) -> None: + """Protected implementation of execute.""" + + pass + @pyqtSlot() def setFinished(self) -> None: self._finished = True @@ -115,6 +125,17 @@ class MachineAction(QObject, PluginObject): def getDisplayItem(self) -> Optional["QObject"]: return self._createViewFromQML() + @pyqtSlot(result = bool) + def openAsDialog(self) -> bool: + """Whether this action will show a dialog. + + If not, the action will directly run the function inside execute(). + + :return: Defaults to true to be in line with the old behaviour. + """ + + return self._open_as_dialog + @pyqtSlot(result = bool) def isVisible(self) -> bool: """Whether this action button will be visible. diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index d728be6dfa..4ecc70b404 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -74,10 +74,14 @@ UM.ManagementPage onClicked: { var currentItem = machineActionRepeater.model[index] - actionDialog.loader.manager = currentItem - actionDialog.loader.source = currentItem.qmlPath - actionDialog.title = currentItem.label - actionDialog.show() + if (currentItem.openAsDialog()) { + actionDialog.loader.manager = currentItem + actionDialog.loader.source = currentItem.qmlPath + actionDialog.title = currentItem.label + actionDialog.show() + } else { + currentItem.execute() + } } } }