Add getContainerProperty function

The opposite of setContainerProperty.

Contributes to issue CURA-2822.
This commit is contained in:
Ghostkeeper 2017-06-22 13:50:35 +02:00
parent f041473465
commit 7ea1d4cc5a
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -235,7 +235,7 @@ class ContainerManager(QObject):
return True return True
## Set a setting property value of the specified container. ## Set a setting property of the specified container.
# #
# This will set the specified property of the specified setting of the container # This will set the specified property of the specified setting of the container
# and all containers that share the same base_file (if any). The latter only # and all containers that share the same base_file (if any). The latter only
@ -269,6 +269,29 @@ class ContainerManager(QObject):
return True return True
## Get a setting property of the specified container.
#
# This will get the specified property of the specified setting of the
# specified container.
#
# \param container_id The ID of the container to get the setting property
# of.
# \param setting_key The key of the setting to get the property of.
# \param property_name The property to obtain.
# \return The value of the specified property. The type of this property
# value depends on the type of the property. For instance, the "value"
# property of an integer setting will be a Python int, but the "value"
# property of an enum setting will be a Python str.
@pyqtSlot(str, str, str, result = QVariant)
def getContainerProperty(self, container_id: str, setting_key: str, property_name: str):
containers = self._container_registry.findContainers(id = container_id)
if not containers:
Logger.log("w", "Could not get properties of container %s because it was not found.", container_id)
return ""
container = containers[0]
return container.getProperty(setting_key, property_name)
## Set the name of the specified container. ## Set the name of the specified container.
@pyqtSlot(str, str, result = bool) @pyqtSlot(str, str, result = bool)
def setContainerName(self, container_id, new_name): def setContainerName(self, container_id, new_name):