diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 0df7f4ba05..c420f5b49e 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -160,21 +160,16 @@ class ContainerManager(QObject): return container.getProperty(setting_key, property_name) - ## Set the name of the specified container. - @pyqtSlot(str, str, result = bool) - def setContainerName(self, container_id, new_name): - if self._container_registry.isReadOnly(container_id): - Logger.log("w", "Cannot set name of read-only container %s.", container_id) - return False + ## Set the name of the specified material. + @pyqtSlot("QVariant", str) + def setMaterialName(self, material_node, new_name): + root_material_id = material_node.metadata["base_file"] + if self._container_registry.isReadOnly(root_material_id): + Logger.log("w", "Cannot set name of read-only container %s.", root_material_id) + return - containers = self._container_registry.findContainers(id = container_id) #We need to get the full container, not just metadata, since we need to know whether it's read-only. - if not containers: - Logger.log("w", "Could not set name of container %s because it was not found.", container_id) - return False - - containers[0].setName(new_name) - - return True + material_group = self._material_manager.getMaterialGroup(root_material_id) + material_group.root_material_node.getContainer().setName(new_name) ## Find instance containers matching certain criteria. # diff --git a/resources/qml/Preferences/MaterialView.qml b/resources/qml/Preferences/MaterialView.qml index 0c3063ff41..6e3d04fa2c 100644 --- a/resources/qml/Preferences/MaterialView.qml +++ b/resources/qml/Preferences/MaterialView.qml @@ -454,14 +454,13 @@ TabView // update the display name of the material function updateMaterialDisplayName (old_name, new_name) { - // don't change when new name is the same if (old_name == new_name) { return } // update the values - Cura.ContainerManager.setContainerName(base.containerId, new_name) + Cura.ContainerManager.setMaterialName(base.currentMaterialNode, new_name) materialProperties.name = new_name }