Move new printers detected message to it's own class

CURA-8463
This commit is contained in:
Jaime van Kessel 2022-08-30 11:26:09 +02:00
parent 8e9056df71
commit a429a93e94
No known key found for this signature in database
GPG key ID: C85F7A3AF1BAA7C4
2 changed files with 35 additions and 16 deletions

View file

@ -0,0 +1,31 @@
# Copyright (c) 2022 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from UM import i18nCatalog
from UM.Message import Message
from cura.CuraApplication import CuraApplication
class NewPrinterDetectedMessage(Message):
i18n_catalog = i18nCatalog("cura")
def __init__(self, num_printers_found: int) -> None:
super().__init__(title = self.i18n_catalog.i18ncp("info:status",
"New printer detected from your Ultimaker account",
"New printers detected from your Ultimaker account",
num_printers_found),
progress = 0,
lifetime = 0,
message_type = Message.MessageType.POSITIVE)
self._printers_added = 0
self._num_printers_found = num_printers_found
def updateDisplayText(self, output_device):
message_text = self.i18n_catalog.i18nc("info:status Filled in with printer name and printer model.",
"Adding printer {name} ({model}) from your account").format(
name=output_device.name, model=output_device.printerTypeName)
self.setText(message_text)
if self._num_printers_found > 1:
self.setProgress((self._printers_added / self._num_printers_found) * 100)
self._printers_added += 1
CuraApplication.getInstance().processEvents()