UMOUpgradeSelection.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) 2017 Ultimaker B.V.
  2. # Uranium is released under the terms of the AGPLv3 or higher.
  3. from UM.Settings.ContainerRegistry import ContainerRegistry
  4. from UM.Settings.InstanceContainer import InstanceContainer
  5. from cura.MachineAction import MachineAction
  6. from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
  7. from UM.i18n import i18nCatalog
  8. from UM.Application import Application
  9. catalog = i18nCatalog("cura")
  10. import UM.Settings.InstanceContainer
  11. from cura.CuraApplication import CuraApplication
  12. ## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added
  13. # as a variant.
  14. class UMOUpgradeSelection(MachineAction):
  15. def __init__(self):
  16. super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
  17. self._qml_url = "UMOUpgradeSelectionMachineAction.qml"
  18. def _reset(self):
  19. self.heatedBedChanged.emit()
  20. heatedBedChanged = pyqtSignal()
  21. @pyqtProperty(bool, notify = heatedBedChanged)
  22. def hasHeatedBed(self):
  23. global_container_stack = Application.getInstance().getGlobalContainerStack()
  24. if global_container_stack:
  25. return global_container_stack.getProperty("machine_heated_bed", "value")
  26. @pyqtSlot(bool)
  27. def setHeatedBed(self, heated_bed = True):
  28. global_container_stack = Application.getInstance().getGlobalContainerStack()
  29. if global_container_stack:
  30. # Make sure there is a definition_changes container to store the machine settings
  31. definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"})
  32. if not definition_changes_container:
  33. definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
  34. definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
  35. self.heatedBedChanged.emit()
  36. def _createDefinitionChangesContainer(self, global_container_stack):
  37. # Create a definition_changes container to store the settings in and add it to the stack
  38. definition_changes_container = UM.Settings.InstanceContainer.InstanceContainer(global_container_stack.getName() + "_settings")
  39. definition = global_container_stack.getBottom()
  40. definition_changes_container.setDefinition(definition)
  41. definition_changes_container.addMetaDataEntry("type", "definition_changes")
  42. definition_changes_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
  43. UM.Settings.ContainerRegistry.ContainerRegistry.getInstance().addContainer(definition_changes_container)
  44. global_container_stack.definitionChanges = definition_changes_container
  45. return definition_changes_container