|
@@ -65,7 +65,7 @@ class DiscoveredPrinter(QObject):
|
|
|
# Checks if the given machine type name in the available machine list.
|
|
|
# The machine type is a code name such as "ultimaker_3", while the machine type name is the human-readable name of
|
|
|
# the machine type, which is "Ultimaker 3" for "ultimaker_3".
|
|
|
- def hasHumanReadableMachineTypeName(self, machine_type_name: str) -> bool:
|
|
|
+ def _hasHumanReadableMachineTypeName(self, machine_type_name: str) -> bool:
|
|
|
from cura.CuraApplication import CuraApplication
|
|
|
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(name = machine_type_name)
|
|
|
return len(results) > 0
|
|
@@ -78,24 +78,30 @@ class DiscoveredPrinter(QObject):
|
|
|
# In ClusterUM3OutputDevice, when it updates a printer information, it updates the machine type using the field
|
|
|
# "machine_variant", and for some reason, it's not the machine type ID/codename/... but a human-readable string
|
|
|
# like "Ultimaker 3". The code below handles this case.
|
|
|
- if self.hasHumanReadableMachineTypeName(self._machine_type):
|
|
|
+ if self._hasHumanReadableMachineTypeName(self._machine_type):
|
|
|
readable_type = self._machine_type
|
|
|
else:
|
|
|
- readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
|
|
+ readable_type = self._getMachineTypeNameFromId(self._machine_type)
|
|
|
if not readable_type:
|
|
|
readable_type = catalog.i18nc("@label", "Unknown")
|
|
|
return readable_type
|
|
|
|
|
|
@pyqtProperty(bool, notify = machineTypeChanged)
|
|
|
def isUnknownMachineType(self) -> bool:
|
|
|
- from cura.CuraApplication import CuraApplication
|
|
|
- machine_manager = CuraApplication.getInstance().getMachineManager()
|
|
|
- if self.hasHumanReadableMachineTypeName(self._machine_type):
|
|
|
+ if self._hasHumanReadableMachineTypeName(self._machine_type):
|
|
|
readable_type = self._machine_type
|
|
|
else:
|
|
|
- readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
|
|
+ readable_type = self._getMachineTypeNameFromId(self._machine_type)
|
|
|
return not readable_type
|
|
|
|
|
|
+ def _getMachineTypeNameFromId(self, machine_type_id: str) -> str:
|
|
|
+ machine_type_name = ""
|
|
|
+ from cura.CuraApplication import CuraApplication
|
|
|
+ results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(id = machine_type_id)
|
|
|
+ if results:
|
|
|
+ machine_type_name = results[0]["name"]
|
|
|
+ return machine_type_name
|
|
|
+
|
|
|
@pyqtProperty(QObject, constant = True)
|
|
|
def device(self) -> "NetworkedPrinterOutputDevice":
|
|
|
return self._device
|