mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 07:25:56 +08:00
Move hasHumanReadableMachienTypeName to discovered printers
This commit is contained in:
parent
05a5f66856
commit
5eee3fc368
@ -62,6 +62,14 @@ class DiscoveredPrinter(QObject):
|
|||||||
self._machine_type = machine_type
|
self._machine_type = machine_type
|
||||||
self.machineTypeChanged.emit()
|
self.machineTypeChanged.emit()
|
||||||
|
|
||||||
|
# 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:
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
results = CuraApplication.getInstance().getContainerRegistry().findDefinitionContainersMetadata(name = machine_type_name)
|
||||||
|
return len(results) > 0
|
||||||
|
|
||||||
# Human readable machine type string
|
# Human readable machine type string
|
||||||
@pyqtProperty(str, notify = machineTypeChanged)
|
@pyqtProperty(str, notify = machineTypeChanged)
|
||||||
def readableMachineType(self) -> str:
|
def readableMachineType(self) -> str:
|
||||||
@ -70,7 +78,7 @@ 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 machine_manager.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 = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
||||||
@ -82,7 +90,7 @@ class DiscoveredPrinter(QObject):
|
|||||||
def isUnknownMachineType(self) -> bool:
|
def isUnknownMachineType(self) -> bool:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
machine_manager = CuraApplication.getInstance().getMachineManager()
|
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||||
if machine_manager.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 = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
||||||
|
@ -1648,13 +1648,6 @@ class MachineManager(QObject):
|
|||||||
|
|
||||||
return abbr_machine
|
return abbr_machine
|
||||||
|
|
||||||
# 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:
|
|
||||||
results = self._container_registry.findDefinitionContainersMetadata(name = machine_type_name)
|
|
||||||
return len(results) > 0
|
|
||||||
|
|
||||||
@pyqtSlot(str, result = str)
|
@pyqtSlot(str, result = str)
|
||||||
def getMachineTypeNameFromId(self, machine_type_id: str) -> str:
|
def getMachineTypeNameFromId(self, machine_type_id: str) -> str:
|
||||||
machine_type_name = ""
|
machine_type_name = ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user