mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-17 17:16:41 +08:00

Recently we changed the empty containers such that there is only one empty container instance and it doesn't have the proper type any more. Instead we have properties on the stack that allows us to find the container with the proper type. It's faster and easier to use. We've had a few bugs about this so I decided to update all of them to remove those for the future, except the ones in plugins/MachineSettingsAction/MachineSettingsAction.py because we have a pending pull request that fixes those. Fixing them would give merge conflicts for fieldOfView. It doesn't really belong to CURA-4024 but I'm sticking it under that nomer anyway to get it reviewed.
58 lines
2.7 KiB
Python
58 lines
2.7 KiB
Python
# Copyright (c) 2017 Ultimaker B.V.
|
|
# Uranium is released under the terms of the AGPLv3 or higher.
|
|
|
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
|
from UM.Settings.InstanceContainer import InstanceContainer
|
|
from cura.MachineAction import MachineAction
|
|
from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
|
|
|
|
from UM.i18n import i18nCatalog
|
|
from UM.Application import Application
|
|
catalog = i18nCatalog("cura")
|
|
|
|
import UM.Settings.InstanceContainer
|
|
from cura.CuraApplication import CuraApplication
|
|
|
|
## The Ultimaker Original can have a few revisions & upgrades. This action helps with selecting them, so they are added
|
|
# as a variant.
|
|
class UMOUpgradeSelection(MachineAction):
|
|
def __init__(self):
|
|
super().__init__("UMOUpgradeSelection", catalog.i18nc("@action", "Select upgrades"))
|
|
self._qml_url = "UMOUpgradeSelectionMachineAction.qml"
|
|
|
|
def _reset(self):
|
|
self.heatedBedChanged.emit()
|
|
|
|
heatedBedChanged = pyqtSignal()
|
|
|
|
@pyqtProperty(bool, notify = heatedBedChanged)
|
|
def hasHeatedBed(self):
|
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
|
if global_container_stack:
|
|
return global_container_stack.getProperty("machine_heated_bed", "value")
|
|
|
|
@pyqtSlot(bool)
|
|
def setHeatedBed(self, heated_bed = True):
|
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
|
if global_container_stack:
|
|
# Make sure there is a definition_changes container to store the machine settings
|
|
definition_changes_container = global_container_stack.definition_changes
|
|
if not definition_changes_container:
|
|
definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)
|
|
|
|
definition_changes_container.setProperty("machine_heated_bed", "value", heated_bed)
|
|
self.heatedBedChanged.emit()
|
|
|
|
def _createDefinitionChangesContainer(self, global_container_stack):
|
|
# Create a definition_changes container to store the settings in and add it to the stack
|
|
definition_changes_container = UM.Settings.InstanceContainer.InstanceContainer(global_container_stack.getName() + "_settings")
|
|
definition = global_container_stack.getBottom()
|
|
definition_changes_container.setDefinition(definition)
|
|
definition_changes_container.addMetaDataEntry("type", "definition_changes")
|
|
definition_changes_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
|
|
|
UM.Settings.ContainerRegistry.ContainerRegistry.getInstance().addContainer(definition_changes_container)
|
|
global_container_stack.definitionChanges = definition_changes_container
|
|
|
|
return definition_changes_container
|