UMOUpgradeSelection.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Uranium is released under the terms of the LGPLv3 or higher.
  3. from UM.Settings.ContainerRegistry import ContainerRegistry
  4. from cura.MachineAction import MachineAction
  5. from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
  6. from UM.i18n import i18nCatalog
  7. from UM.Application import Application
  8. catalog = i18nCatalog("cura")
  9. from cura.Settings.CuraStackBuilder import CuraStackBuilder
  10. ## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added
  11. # as a variant.
  12. class UMOUpgradeSelection(MachineAction):
  13. def __init__(self):
  14. super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
  15. self._qml_url = "UMOUpgradeSelectionMachineAction.qml"
  16. def _reset(self):
  17. self.heatedBedChanged.emit()
  18. heatedBedChanged = pyqtSignal()
  19. @pyqtProperty(bool, notify = heatedBedChanged)
  20. def hasHeatedBed(self):
  21. global_container_stack = Application.getInstance().getGlobalContainerStack()
  22. if global_container_stack:
  23. return global_container_stack.getProperty("machine_heated_bed", "value")
  24. @pyqtSlot(bool)
  25. def setHeatedBed(self, heated_bed = True):
  26. global_container_stack = Application.getInstance().getGlobalContainerStack()
  27. if global_container_stack:
  28. # Make sure there is a definition_changes container to store the machine settings
  29. definition_changes_container = global_container_stack.definitionChanges
  30. if definition_changes_container == ContainerRegistry.getInstance().getEmptyInstanceContainer():
  31. definition_changes_container = CuraStackBuilder.createDefinitionChangesContainer(
  32. global_container_stack, global_container_stack.getId() + "_settings")
  33. definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
  34. self.heatedBedChanged.emit()