UpgradeFirmwareMachineAction.py 1.1 KB

12345678910111213141516171819
  1. from UM.Application import Application
  2. from UM.Settings.DefinitionContainer import DefinitionContainer
  3. from cura.MachineAction import MachineAction
  4. from UM.i18n import i18nCatalog
  5. from UM.Settings.ContainerRegistry import ContainerRegistry
  6. catalog = i18nCatalog("cura")
  7. ## Upgrade the firmware of a machine by USB with this action.
  8. class UpgradeFirmwareMachineAction(MachineAction):
  9. def __init__(self):
  10. super().__init__("UpgradeFirmware", catalog.i18nc("@action", "Upgrade Firmware"))
  11. self._qml_url = "UpgradeFirmwareMachineAction.qml"
  12. ContainerRegistry.getInstance().containerAdded.connect(self._onContainerAdded)
  13. def _onContainerAdded(self, container):
  14. # Add this action as a supported action to all machine definitions if they support USB connection
  15. if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine" and container.getMetaDataEntry("supports_usb_connection"):
  16. Application.getInstance().getMachineActionManager().addSupportedAction(container.getId(), self.getKey())