mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Also move _getMachineTypeNameFromId to DiscoveredPrintersModel
As this is only used by that model, there is no point in keeping it in the machine manager
This commit is contained in:
parent
5eee3fc368
commit
a98f88e6a3
2 changed files with 13 additions and 15 deletions
|
@ -65,7 +65,7 @@ class DiscoveredPrinter(QObject):
|
||||||
# Checks if the given machine type name in the available machine list.
|
# 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 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".
|
# 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
|
from cura.CuraApplication import CuraApplication
|
||||||
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(name = machine_type_name)
|
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(name = machine_type_name)
|
||||||
return len(results) > 0
|
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
|
# 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
|
# "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.
|
# 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
|
readable_type = self._machine_type
|
||||||
else:
|
else:
|
||||||
readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
readable_type = self._getMachineTypeNameFromId(self._machine_type)
|
||||||
if not readable_type:
|
if not readable_type:
|
||||||
readable_type = catalog.i18nc("@label", "Unknown")
|
readable_type = catalog.i18nc("@label", "Unknown")
|
||||||
return readable_type
|
return readable_type
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = machineTypeChanged)
|
@pyqtProperty(bool, notify = machineTypeChanged)
|
||||||
def isUnknownMachineType(self) -> bool:
|
def isUnknownMachineType(self) -> bool:
|
||||||
from cura.CuraApplication import CuraApplication
|
if self._hasHumanReadableMachineTypeName(self._machine_type):
|
||||||
machine_manager = CuraApplication.getInstance().getMachineManager()
|
|
||||||
if self.hasHumanReadableMachineTypeName(self._machine_type):
|
|
||||||
readable_type = self._machine_type
|
readable_type = self._machine_type
|
||||||
else:
|
else:
|
||||||
readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
readable_type = self._getMachineTypeNameFromId(self._machine_type)
|
||||||
return not readable_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)
|
@pyqtProperty(QObject, constant = True)
|
||||||
def device(self) -> "NetworkedPrinterOutputDevice":
|
def device(self) -> "NetworkedPrinterOutputDevice":
|
||||||
return self._device
|
return self._device
|
||||||
|
|
|
@ -1648,14 +1648,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
return abbr_machine
|
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.
|
# Gets all machines that belong to the given group_id.
|
||||||
def getMachinesInGroup(self, group_id: str) -> List["GlobalStack"]:
|
def getMachinesInGroup(self, group_id: str) -> List["GlobalStack"]:
|
||||||
return self._container_registry.findContainerStacks(type = "machine", group_id = group_id)
|
return self._container_registry.findContainerStacks(type = "machine", group_id = group_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue