mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 05:23:58 -06:00
Add signals to signal that a material got changed or removed
The material models need to know this. Contributes to issue CURA-6600.
This commit is contained in:
parent
b7213ad020
commit
6c6dd0efad
4 changed files with 22 additions and 3 deletions
|
@ -5,6 +5,7 @@ from typing import Any, TYPE_CHECKING
|
|||
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.Settings.Interfaces import ContainerInterface
|
||||
from UM.Signal import Signal
|
||||
from cura.Machines.ContainerNode import ContainerNode
|
||||
from cura.Machines.QualityNode import QualityNode
|
||||
|
||||
|
@ -20,6 +21,8 @@ class MaterialNode(ContainerNode):
|
|||
super().__init__(container_id)
|
||||
self.variant = variant
|
||||
self.qualities = {} # type: Dict[str, QualityNode] # Mapping container IDs to quality profiles.
|
||||
self.materialChanged = Signal() # Triggered when the material is removed or its metadata is updated.
|
||||
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
my_metadata = container_registry.findContainersMetadata(id = container_id)[0]
|
||||
self.base_file = my_metadata["base_file"]
|
||||
|
@ -59,6 +62,7 @@ class MaterialNode(ContainerNode):
|
|||
# Remove myself from my parent.
|
||||
if self.base_file in self.variant.materials:
|
||||
del self.variant.materials[self.base_file]
|
||||
self.materialChanged.emit(self)
|
||||
|
||||
## Triggered when any metadata changed in any container, but only handles
|
||||
# it when the metadata of this node is changed.
|
||||
|
@ -84,4 +88,5 @@ class MaterialNode(ContainerNode):
|
|||
self.guid = new_metadata["GUID"]
|
||||
if self.base_file != old_base_file or self.material_type != old_material_type or self.guid != old_guid: # List of quality profiles could've changed.
|
||||
self.qualities = {}
|
||||
self._loadAll() # Re-load the quality profiles for this node.
|
||||
self._loadAll() # Re-load the quality profiles for this node.
|
||||
self.materialChanged.emit(self)
|
Loading…
Add table
Add a link
Reference in a new issue