Fix material name update on sidebar

CURA-5084
This commit is contained in:
Lipu Fei 2018-03-13 17:00:30 +01:00
parent 7b3598e992
commit d2eb01d137
3 changed files with 5 additions and 24 deletions

View File

@ -50,7 +50,6 @@ class MachineManager(QObject):
self._global_container_stack = None # type: GlobalStack self._global_container_stack = None # type: GlobalStack
self._current_root_material_id = {} self._current_root_material_id = {}
self._current_root_material_name = {}
self._current_quality_group = None self._current_quality_group = None
self._current_quality_changes_group = None self._current_quality_changes_group = None
@ -926,28 +925,18 @@ class MachineManager(QObject):
return [] return []
return sorted(list(self._global_container_stack.extruders.keys())) return sorted(list(self._global_container_stack.extruders.keys()))
## Update _current_root_material_id and _current_root_material_name when ## Update _current_root_material_id when the current root material was changed.
# the current root material was changed.
def _onRootMaterialChanged(self): def _onRootMaterialChanged(self):
self._current_root_material_id = {} self._current_root_material_id = {}
if self._global_container_stack: if self._global_container_stack:
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")
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) @pyqtProperty("QVariant", notify = rootMaterialChanged)
def currentRootMaterialId(self): def currentRootMaterialId(self):
return self._current_root_material_id 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). ## Return the variant names in the extruder stack(s).
## For the variant in the global stack, use activeVariantBuildplateName ## For the variant in the global stack, use activeVariantBuildplateName
@pyqtProperty("QVariant", notify = activeVariantChanged) @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 # 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]: if root_material_id != self._current_root_material_id[position]:
self._current_root_material_id[position] = root_material_id self._current_root_material_id[position] = root_material_id
self._current_root_material_name[position] = root_material_name
self.rootMaterialChanged.emit() self.rootMaterialChanged.emit()
def activeMaterialsCompatible(self): def activeMaterialsCompatible(self):

View File

@ -346,15 +346,8 @@ Column
{ {
id: materialSelection id: materialSelection
property var currentRootMaterialName: property var activeExtruder: Cura.MachineManager.activeStack
{ property var currentRootMaterialName: activeExtruder.material.name
var materials = Cura.MachineManager.currentRootMaterialName;
var materialName = "";
if (base.currentExtruderIndex in materials) {
materialName = materials[base.currentExtruderIndex];
}
return materialName;
}
text: currentRootMaterialName text: currentRootMaterialName
tooltip: currentRootMaterialName tooltip: currentRootMaterialName
@ -373,7 +366,7 @@ Column
property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported property var valueWarning: ! Cura.MachineManager.isActiveQualitySupported
function isMaterialSupported () { function isMaterialSupported () {
return Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible") == "True" return Cura.ContainerManager.getContainerMetaDataEntry(activeExtruder.material.id, "compatible") == "True"
} }
} }
} }

View File

@ -173,7 +173,7 @@ UM.Dialog
} }
Label 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 width: (parent.width / 3) | 0
} }
} }