WIP: Show full name of network printer types

This commit is contained in:
Lipu Fei 2019-03-13 13:03:41 +01:00
parent de9f6f47bd
commit 764f7281c2
4 changed files with 30 additions and 7 deletions

View file

@ -1,15 +1,20 @@
# Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Callable, List, Optional, TYPE_CHECKING
from PyQt5.QtCore import pyqtSlot, pyqtProperty, pyqtSignal, QObject
from UM.i18n import i18nCatalog
from UM.Logger import Logger
if TYPE_CHECKING:
from PyQt5.QtCore import QObject
catalog = i18nCatalog("cura")
class DiscoveredPrinter(QObject):
def __init__(self, ip_address: str, key: str, name: str, create_callback: Callable[[str], None], machine_type: str,
@ -43,11 +48,19 @@ class DiscoveredPrinter(QObject):
def machine_type(self) -> str:
return self._machine_type
# Machine type string with underscores "_" replaced with spaces " "
def setMachineType(self, machine_type: str) -> None:
if self._machine_type != machine_type:
self._machine_type = machine_type
self.machineTypeChanged.emit()
# Human readable machine type string
@pyqtProperty(str, notify = machineTypeChanged)
def machine_type_with_spaces(self) -> str:
def readable_machine_type(self) -> str:
from cura.CuraApplication import CuraApplication
return CuraApplication.getInstance().getMachineManager().getMachineTypeNameFromId(self._machine_type)
readable_type = CuraApplication.getInstance().getMachineManager().getMachineTypeNameFromId(self._machine_type)
if not readable_type:
readable_type = catalog.i18nc("@label", "Unknown")
return readable_type
@pyqtProperty(QObject, constant = True)
def device(self):