Added materialspage Display Name field and made it work. CURA-1969

This commit is contained in:
Jack Ha 2016-08-25 09:54:22 +02:00
parent 8df5bba6e9
commit 2ae998737f
4 changed files with 60 additions and 2 deletions

View file

@ -181,7 +181,7 @@ class ContainerManager(QObject):
def setContainerMetaDataEntry(self, container_id, entry_name, entry_value):
containers = UM.Settings.ContainerRegistry.getInstance().findContainers(None, id = container_id)
if not containers:
UM.Logger.log("w", "Could set metadata of container %s because it was not found.", container_id)
UM.Logger.log("w", "Could not set metadata of container %s because it was not found.", container_id)
return False
container = containers[0]
@ -210,6 +210,24 @@ class ContainerManager(QObject):
return True
## Set the name of the specified container.
@pyqtSlot(str, str, result = bool)
def setContainerName(self, container_id, new_name):
containers = UM.Settings.ContainerRegistry.getInstance().findContainers(None, id = container_id)
if not containers:
UM.Logger.log("w", "Could not set name of container %s because it was not found.", container_id)
return False
container = containers[0]
if container.isReadOnly():
UM.Logger.log("w", "Cannot set name of read-only container %s.", container_id)
return False
container.setName(new_name)
return True
## Find instance containers matching certain criteria.
#
# This effectively forwards to ContainerRegistry::findInstanceContainers.