mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-30 04:15:12 +08:00
Fix material name update on sidebar
CURA-5084
This commit is contained in:
parent
7b3598e992
commit
d2eb01d137
@ -50,7 +50,6 @@ class MachineManager(QObject):
|
||||
self._global_container_stack = None # type: GlobalStack
|
||||
|
||||
self._current_root_material_id = {}
|
||||
self._current_root_material_name = {}
|
||||
self._current_quality_group = None
|
||||
self._current_quality_changes_group = None
|
||||
|
||||
@ -926,28 +925,18 @@ class MachineManager(QObject):
|
||||
return []
|
||||
return sorted(list(self._global_container_stack.extruders.keys()))
|
||||
|
||||
## Update _current_root_material_id and _current_root_material_name when
|
||||
# the current root material was changed.
|
||||
## Update _current_root_material_id when the current root material was changed.
|
||||
def _onRootMaterialChanged(self):
|
||||
self._current_root_material_id = {}
|
||||
|
||||
if self._global_container_stack:
|
||||
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_name = {}
|
||||
for position in self._global_container_stack.extruders:
|
||||
if position not in self._current_root_material_name:
|
||||
material = self._global_container_stack.extruders[position].material
|
||||
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 the variant names in the extruder stack(s).
|
||||
## For the variant in the global stack, use activeVariantBuildplateName
|
||||
@pyqtProperty("QVariant", notify = activeVariantChanged)
|
||||
@ -1052,7 +1041,6 @@ class MachineManager(QObject):
|
||||
# The _current_root_material_id is used in the MaterialMenu to see which material is selected
|
||||
if root_material_id != self._current_root_material_id[position]:
|
||||
self._current_root_material_id[position] = root_material_id
|
||||
self._current_root_material_name[position] = root_material_name
|
||||
self.rootMaterialChanged.emit()
|
||||
|
||||
def activeMaterialsCompatible(self):
|
||||
|
@ -346,15 +346,8 @@ Column
|
||||
{
|
||||
id: materialSelection
|
||||
|
||||
property var currentRootMaterialName:
|
||||
{
|
||||
var materials = Cura.MachineManager.currentRootMaterialName;
|
||||
var materialName = "";
|
||||
if (base.currentExtruderIndex in materials) {
|
||||
materialName = materials[base.currentExtruderIndex];
|
||||
}
|
||||
return materialName;
|
||||
}
|
||||
property var activeExtruder: Cura.MachineManager.activeStack
|
||||
property var currentRootMaterialName: activeExtruder.material.name
|
||||
|
||||
text: currentRootMaterialName
|
||||
tooltip: currentRootMaterialName
|
||||
@ -373,7 +366,7 @@ Column
|
||||
property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
|
||||
|
||||
function isMaterialSupported () {
|
||||
return Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible") == "True"
|
||||
return Cura.ContainerManager.getContainerMetaDataEntry(activeExtruder.material.id, "compatible") == "True"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ UM.Dialog
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: Cura.MachineManager.activeVariantNames[modelData] + ", " + Cura.MachineManager.currentRootMaterialName[modelData]
|
||||
text: Cura.MachineManager.activeVariantNames[modelData] + ", " + Cura.MachineManager.getExtruder(modelData).material.name
|
||||
width: (parent.width / 3) | 0
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user