From d2eb01d13778372590e81339820f0b01670008d9 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 13 Mar 2018 17:00:30 +0100 Subject: [PATCH] Fix material name update on sidebar CURA-5084 --- cura/Settings/MachineManager.py | 14 +------------- resources/qml/SidebarHeader.qml | 13 +++---------- resources/qml/WorkspaceSummaryDialog.qml | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index cd9e75f33d..a6c70ee15f 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -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): diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index baceb5f683..74e189789d 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -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" } } } diff --git a/resources/qml/WorkspaceSummaryDialog.qml b/resources/qml/WorkspaceSummaryDialog.qml index 1cfe36d14b..12eba13dd9 100644 --- a/resources/qml/WorkspaceSummaryDialog.qml +++ b/resources/qml/WorkspaceSummaryDialog.qml @@ -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 } }