mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 16:28:59 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
c54ea00111
@ -34,10 +34,16 @@ class MachineSettingsAction(MachineAction):
|
|||||||
self._container_registry.containerRemoved.connect(self._onContainerRemoved)
|
self._container_registry.containerRemoved.connect(self._onContainerRemoved)
|
||||||
self._application.globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
self._application.globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
|
|
||||||
self._empty_container = self._container_registry.getEmptyInstanceContainer()
|
|
||||||
|
|
||||||
self._backend = self._application.getBackend()
|
self._backend = self._application.getBackend()
|
||||||
|
|
||||||
|
self._empty_definition_container_id_list = []
|
||||||
|
|
||||||
|
def _isEmptyDefinitionChanges(self, container_id: str):
|
||||||
|
if not self._empty_definition_container_id_list:
|
||||||
|
self._empty_definition_container_id_list = [self._application.empty_container.getId(),
|
||||||
|
self._application.empty_definition_changes_container.getId()]
|
||||||
|
return container_id in self._empty_definition_container_id_list
|
||||||
|
|
||||||
def _onContainerAdded(self, container):
|
def _onContainerAdded(self, container):
|
||||||
# Add this action as a supported action to all machine definitions
|
# Add this action as a supported action to all machine definitions
|
||||||
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
|
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
|
||||||
@ -46,19 +52,19 @@ class MachineSettingsAction(MachineAction):
|
|||||||
def _onContainerRemoved(self, container):
|
def _onContainerRemoved(self, container):
|
||||||
# Remove definition_changes containers when a stack is removed
|
# Remove definition_changes containers when a stack is removed
|
||||||
if container.getMetaDataEntry("type") in ["machine", "extruder_train"]:
|
if container.getMetaDataEntry("type") in ["machine", "extruder_train"]:
|
||||||
definition_changes_container = container.definitionChanges
|
definition_changes_id = container.definitionChanges.getId()
|
||||||
if definition_changes_container == self._empty_container:
|
if self._isEmptyDefinitionChanges(definition_changes_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
self._container_registry.removeContainer(definition_changes_container.getId())
|
self._container_registry.removeContainer(definition_changes_id)
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Make sure there is a definition_changes container to store the machine settings
|
# Make sure there is a definition_changes container to store the machine settings
|
||||||
definition_changes_container = self._global_container_stack.definitionChanges
|
definition_changes_id = self._global_container_stack.definitionChanges.getId()
|
||||||
if definition_changes_container == self._empty_container:
|
if self._isEmptyDefinitionChanges(definition_changes_id):
|
||||||
CuraStackBuilder.createDefinitionChangesContainer(self._global_container_stack,
|
CuraStackBuilder.createDefinitionChangesContainer(self._global_container_stack,
|
||||||
self._global_container_stack.getName() + "_settings")
|
self._global_container_stack.getName() + "_settings")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user