diff --git a/cura/Machines/Models/DiscoveredPrintersModel.py b/cura/Machines/Models/DiscoveredPrintersModel.py index 267c46457c..803e1d21ba 100644 --- a/cura/Machines/Models/DiscoveredPrintersModel.py +++ b/cura/Machines/Models/DiscoveredPrintersModel.py @@ -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 diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index c85e90ab72..643844392c 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1648,14 +1648,6 @@ class MachineManager(QObject): return abbr_machine - @pyqtSlot(str, result = str) - def getMachineTypeNameFromId(self, machine_type_id: str) -> str: - machine_type_name = "" - results = self._container_registry.findDefinitionContainersMetadata(id = machine_type_id) - if results: - machine_type_name = results[0]["name"] - return machine_type_name - # Gets all machines that belong to the given group_id. def getMachinesInGroup(self, group_id: str) -> List["GlobalStack"]: return self._container_registry.findContainerStacks(type = "machine", group_id = group_id)