mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 06:33:55 -06:00
Move setMaterialName() into MaterialManager
This commit is contained in:
parent
f7377e6321
commit
c6128ef5ba
4 changed files with 22 additions and 13 deletions
|
@ -859,6 +859,7 @@ class CuraApplication(QtApplication):
|
|||
def getVariantManager(self, *args):
|
||||
return self._variant_manager
|
||||
|
||||
@pyqtSlot(result = QObject)
|
||||
def getMaterialManager(self, *args):
|
||||
return self._material_manager
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
from collections import defaultdict, OrderedDict
|
||||
from typing import Optional
|
||||
|
||||
from PyQt5.Qt import QTimer, QObject, pyqtSignal
|
||||
from PyQt5.Qt import QTimer, QObject, pyqtSignal, pyqtSlot
|
||||
|
||||
from UM.Logger import Logger
|
||||
from UM.Settings import ContainerRegistry
|
||||
|
@ -339,3 +339,20 @@ class MaterialManager(QObject):
|
|||
return self.getRootMaterialIDWithoutDiameter(fallback_material["id"])
|
||||
else:
|
||||
return None
|
||||
|
||||
#
|
||||
# Methods for GUI
|
||||
#
|
||||
|
||||
#
|
||||
# Sets the new name for the given material.
|
||||
#
|
||||
@pyqtSlot("QVariant", str)
|
||||
def setMaterialName(self, material_node: "MaterialNode", name: str):
|
||||
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
|
||||
|
||||
material_group = self.getMaterialGroup(root_material_id)
|
||||
material_group.root_material_node.getContainer().setName(name)
|
||||
|
|
|
@ -160,17 +160,6 @@ class ContainerManager(QObject):
|
|||
|
||||
return container.getProperty(setting_key, property_name)
|
||||
|
||||
## 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
|
||||
|
||||
material_group = self._material_manager.getMaterialGroup(root_material_id)
|
||||
material_group.root_material_node.getContainer().setName(new_name)
|
||||
|
||||
@pyqtSlot(str, result = str)
|
||||
def makeUniqueName(self, original_name):
|
||||
return self._container_registry.uniqueName(original_name)
|
||||
|
|
|
@ -12,6 +12,8 @@ TabView
|
|||
{
|
||||
id: base
|
||||
|
||||
property QtObject materialManager: CuraApplication.getMaterialManager()
|
||||
|
||||
property QtObject properties
|
||||
property var currentMaterialNode: null
|
||||
|
||||
|
@ -497,7 +499,7 @@ TabView
|
|||
}
|
||||
|
||||
// update the values
|
||||
Cura.ContainerManager.setMaterialName(base.currentMaterialNode, new_name)
|
||||
base.materialManager.setMaterialName(base.currentMaterialNode, new_name)
|
||||
materialProperties.name = new_name
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue