mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 00:37:50 -06:00
Add materialNames property to get user-facing texts from printer
inb4 string-freeze CURA-2276
This commit is contained in:
parent
8d6f7c06c1
commit
224e6d37a8
1 changed files with 16 additions and 0 deletions
|
@ -24,6 +24,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
||||||
def __init__(self, device_id, parent = None):
|
def __init__(self, device_id, parent = None):
|
||||||
super().__init__(device_id = device_id, parent = parent)
|
super().__init__(device_id = device_id, parent = parent)
|
||||||
|
|
||||||
|
self._container_registry = UM.Settings.ContainerRegistry.getInstance()
|
||||||
self._target_bed_temperature = 0
|
self._target_bed_temperature = 0
|
||||||
self._bed_temperature = 0
|
self._bed_temperature = 0
|
||||||
self._num_extruders = 1
|
self._num_extruders = 1
|
||||||
|
@ -276,6 +277,21 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
||||||
def materialIds(self):
|
def materialIds(self):
|
||||||
return self._material_ids
|
return self._material_ids
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = materialIdChanged)
|
||||||
|
def materialNames(self):
|
||||||
|
result = []
|
||||||
|
for material_id in self._material_ids:
|
||||||
|
if material_id is None:
|
||||||
|
result.append(i18n_catalog.i18nc("@item:material", "No material loaded"))
|
||||||
|
continue
|
||||||
|
|
||||||
|
containers = self._container_registry.findInstanceContainers(type = "material", guid = material_id)
|
||||||
|
if containers:
|
||||||
|
result.append(containers[0].getName())
|
||||||
|
else:
|
||||||
|
result.append(i18n_catalog.i18nc("@item:material", "Unknown material"))
|
||||||
|
return result
|
||||||
|
|
||||||
## Protected setter for the current material id.
|
## Protected setter for the current material id.
|
||||||
# /param index Index of the extruder
|
# /param index Index of the extruder
|
||||||
# /param material_id id of the material
|
# /param material_id id of the material
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue