mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Always update root material even if not in QML
Previously the _current_root_material_id and _current_root_material_name dictionaries were only updated if they are used anywhere in QML. This is unreliable. We're now directly connecting to the signal so that they are always updated, even when not in use by the GUI. This way we can rely on it in other places than the GUI. Contributes to issue CURA-4606.
This commit is contained in:
parent
f40e9bffa9
commit
a87db2d721
1 changed files with 11 additions and 7 deletions
|
@ -125,6 +125,7 @@ class MachineManager(QObject):
|
||||||
# When the materials lookup table gets updated, it can mean that a material has its name changed, which should
|
# When the materials lookup table gets updated, it can mean that a material has its name changed, which should
|
||||||
# be reflected on the GUI. This signal emission makes sure that it happens.
|
# be reflected on the GUI. This signal emission makes sure that it happens.
|
||||||
self._material_manager.materialsUpdated.connect(self.rootMaterialChanged)
|
self._material_manager.materialsUpdated.connect(self.rootMaterialChanged)
|
||||||
|
self.rootMaterialChanged.connect(self._onRootMaterialChanged)
|
||||||
|
|
||||||
activeQualityGroupChanged = pyqtSignal()
|
activeQualityGroupChanged = pyqtSignal()
|
||||||
activeQualityChangesGroupChanged = pyqtSignal()
|
activeQualityChangesGroupChanged = pyqtSignal()
|
||||||
|
@ -876,23 +877,26 @@ class MachineManager(QObject):
|
||||||
def currentExtruderPositions(self):
|
def currentExtruderPositions(self):
|
||||||
return sorted(list(self._global_container_stack.extruders.keys()))
|
return sorted(list(self._global_container_stack.extruders.keys()))
|
||||||
|
|
||||||
@pyqtProperty("QVariant", notify = rootMaterialChanged)
|
## Update _current_root_material_id and _current_root_material_name when
|
||||||
def currentRootMaterialId(self):
|
# the current root material was changed.
|
||||||
# initial filling the current_root_material_id
|
def _onRootMaterialChanged(self):
|
||||||
self._current_root_material_id = {}
|
self._current_root_material_id = {}
|
||||||
for position in self._global_container_stack.extruders:
|
for position in self._global_container_stack.extruders:
|
||||||
self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
||||||
return self._current_root_material_id
|
|
||||||
|
|
||||||
@pyqtProperty("QVariant", notify = rootMaterialChanged)
|
|
||||||
def currentRootMaterialName(self):
|
|
||||||
# initial filling the current_root_material_name
|
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
self._current_root_material_name = {}
|
self._current_root_material_name = {}
|
||||||
for position in self._global_container_stack.extruders:
|
for position in self._global_container_stack.extruders:
|
||||||
if position not in self._current_root_material_name:
|
if position not in self._current_root_material_name:
|
||||||
material = self._global_container_stack.extruders[position].material
|
material = self._global_container_stack.extruders[position].material
|
||||||
self._current_root_material_name[position] = material.getName()
|
self._current_root_material_name[position] = material.getName()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariant", notify = rootMaterialChanged)
|
||||||
|
def currentRootMaterialId(self):
|
||||||
|
return self._current_root_material_id
|
||||||
|
|
||||||
|
@pyqtProperty("QVariant", notify = rootMaterialChanged)
|
||||||
|
def currentRootMaterialName(self):
|
||||||
return self._current_root_material_name
|
return self._current_root_material_name
|
||||||
|
|
||||||
## Return the variant names in the extruder stack(s).
|
## Return the variant names in the extruder stack(s).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue