UMOUpgradeSelection.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 PyQt6.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. class UMOUpgradeSelection(MachineAction):
  11. """The Ultimaker Original can have a few revisions & upgrades.
  12. This action helps with selecting them, so they are added as a variant.
  13. """
  14. def __init__(self):
  15. super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
  16. self._qml_url = "UMOUpgradeSelectionMachineAction.qml"
  17. def _reset(self):
  18. self.heatedBedChanged.emit()
  19. heatedBedChanged = pyqtSignal()
  20. @pyqtProperty(bool, notify = heatedBedChanged)
  21. def hasHeatedBed(self):
  22. global_container_stack = Application.getInstance().getGlobalContainerStack()
  23. if global_container_stack:
  24. return global_container_stack.getProperty("machine_heated_bed", "value")
  25. @pyqtSlot(bool)
  26. def setHeatedBed(self, heated_bed = True):
  27. global_container_stack = Application.getInstance().getGlobalContainerStack()
  28. if global_container_stack:
  29. # Make sure there is a definition_changes container to store the machine settings
  30. definition_changes_container = global_container_stack.definitionChanges
  31. if definition_changes_container == ContainerRegistry.getInstance().getEmptyInstanceContainer():
  32. definition_changes_container = CuraStackBuilder.createDefinitionChangesContainer(
  33. global_container_stack, global_container_stack.getId() + "_settings")
  34. definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
  35. self.heatedBedChanged.emit()