diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ac3911504f..b2bf471aa3 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -387,9 +387,9 @@ class CuraApplication(QtApplication): self.exec_() ## Get the machine action manager - # We ignore any **kwargs given to this, as we also register the machine manager as qml singleton. + # We ignore any *args given to this, as we also register the machine manager as qml singleton. # It wants to give this function an engine and script engine, but we don't care about that. - def getMachineActionManager(self, **kwargs): + def getMachineActionManager(self, *args): return self._machine_action_manager ## Handle Qt events diff --git a/cura/MachineAction.py b/cura/MachineAction.py index ba40135916..67c4566f53 100644 --- a/cura/MachineAction.py +++ b/cura/MachineAction.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. -from PyQt5.QtCore import QObject, pyqtSlot +from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal from UM.PluginObject import PluginObject @@ -11,12 +11,20 @@ class MachineAction(QObject, PluginObject): self._key = key self._label = label + labelChanged = pyqtSignal() + def getKey(self): return self._key - def getLabel(self): + @pyqtProperty(str, notify = labelChanged) + def label(self): return self._label + def setLabel(self, label): + if self._label != label: + self._label = label + self.labelChanged.emit() + @pyqtSlot() def execute(self): self._execute() diff --git a/cura/MachineActionManager.py b/cura/MachineActionManager.py index af6e36353c..287ed89891 100644 --- a/cura/MachineActionManager.py +++ b/cura/MachineActionManager.py @@ -61,7 +61,7 @@ class MachineActionManager(QObject): else: self._required_actions[machine_id] = {self._machine_actions[action_key]} else: - raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id.getKey())) + raise UnknownMachineAction("Action %s, which is required for %s is not known." % (action_key, machine_id)) ## Add a supported action to a machine. def addSupportedAction(self, machine_id, action_key): @@ -71,7 +71,7 @@ class MachineActionManager(QObject): else: self._supported_actions[machine_id] = {self._machine_actions[action_key]} else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) ## Add an action to the first start list of a machine. def addFirstStartAction(self, machine_id, action_key, index = None): @@ -84,7 +84,7 @@ class MachineActionManager(QObject): else: self._first_start_actions[machine_id] = [self._machine_actions[action_key]] else: - Logger.log("W", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id.getKey()) + Logger.log("w", "Unable to add %s to %s, as the action is not recognised", action_key, machine_id) ## Add a (unique) MachineAction # if the Key of the action is not unique, an exception is raised. @@ -100,7 +100,7 @@ class MachineActionManager(QObject): @pyqtSlot(str, result = "QVariantList") def getSupportedActions(self, machine_id): if machine_id in self._supported_actions: - return self._supported_actions[machine_id] + return list(self._supported_actions[machine_id]) else: return set() diff --git a/resources/qml/Preferences/MachinesPage.qml b/resources/qml/Preferences/MachinesPage.qml index faef019deb..d12b4563f3 100644 --- a/resources/qml/Preferences/MachinesPage.qml +++ b/resources/qml/Preferences/MachinesPage.qml @@ -41,6 +41,19 @@ UM.ManagementPage anchors.fill: parent; spacing: UM.Theme.getSize("default_margin").height; + Row + { + Repeater + { + id: machineActionRepeater + model: Cura.MachineActionManager.getSupportedActions(Cura.MachineManager.activeDefinitionId) + Button + { + text: machineActionRepeater.model[index].label; + } + } + } + Label { text: base.currentItem && base.currentItem.name ? base.currentItem.name : ""