mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
Handle case that printer type can be human readable string
CURA-6449
This commit is contained in:
parent
cf9ab5a5cd
commit
0501ae2fbc
2 changed files with 19 additions and 4 deletions
|
@ -60,7 +60,14 @@ class DiscoveredPrinter(QObject):
|
||||||
@pyqtProperty(str, notify = machineTypeChanged)
|
@pyqtProperty(str, notify = machineTypeChanged)
|
||||||
def readableMachineType(self) -> str:
|
def readableMachineType(self) -> str:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
readable_type = CuraApplication.getInstance().getMachineManager().getMachineTypeNameFromId(self._machine_type)
|
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||||
|
# 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 machine_manager.hasMachineTypeName(self._machine_type):
|
||||||
|
readable_type = self._machine_type
|
||||||
|
else:
|
||||||
|
readable_type = machine_manager.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
|
||||||
|
@ -68,7 +75,11 @@ class DiscoveredPrinter(QObject):
|
||||||
@pyqtProperty(bool, notify = machineTypeChanged)
|
@pyqtProperty(bool, notify = machineTypeChanged)
|
||||||
def isUnknownMachineType(self) -> bool:
|
def isUnknownMachineType(self) -> bool:
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
readable_type = CuraApplication.getInstance().getMachineManager().getMachineTypeNameFromId(self._machine_type)
|
machine_manager = CuraApplication.getInstance().getMachineManager()
|
||||||
|
if machine_manager.hasMachineTypeName(self._machine_type):
|
||||||
|
readable_type = self._machine_type
|
||||||
|
else:
|
||||||
|
readable_type = machine_manager.getMachineTypeNameFromId(self._machine_type)
|
||||||
return not readable_type
|
return not readable_type
|
||||||
|
|
||||||
@pyqtProperty(QObject, constant = True)
|
@pyqtProperty(QObject, constant = True)
|
||||||
|
|
|
@ -1640,6 +1640,10 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
return abbr_machine
|
return abbr_machine
|
||||||
|
|
||||||
|
def hasMachineTypeName(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…
Add table
Add a link
Reference in a new issue