mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Also move remainder of NewPrinterDetected logic to it's own class
This should make the CloudOutputDeviceManager a bit more readable CURA-8463
This commit is contained in:
parent
a429a93e94
commit
7f9984cd16
2 changed files with 32 additions and 16 deletions
|
@ -237,7 +237,7 @@ class CloudOutputDeviceManager:
|
|||
new_devices_added = []
|
||||
|
||||
for idx, output_device in enumerate(new_output_devices):
|
||||
message.updateDisplayText(output_device)
|
||||
message.updateProgressText(output_device)
|
||||
|
||||
self._remote_clusters[output_device.getId()] = output_device
|
||||
|
||||
|
@ -247,21 +247,8 @@ class CloudOutputDeviceManager:
|
|||
if self._createMachineFromDiscoveredDevice(output_device.getId(), activate = activate):
|
||||
new_devices_added.append(output_device)
|
||||
|
||||
message.setProgress(None)
|
||||
message.finalize(new_devices_added, new_output_devices)
|
||||
|
||||
max_disp_devices = 3
|
||||
if len(new_devices_added) > max_disp_devices:
|
||||
num_hidden = len(new_devices_added) - max_disp_devices
|
||||
device_name_list = ["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in new_output_devices[0: max_disp_devices]]
|
||||
device_name_list.append("<li>" + self.i18n_catalog.i18ncp("info:{0} gets replaced by a number of printers", "... and {0} other", "... and {0} others", num_hidden) + "</li>")
|
||||
device_names = "".join(device_name_list)
|
||||
else:
|
||||
device_names = "".join(["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in new_devices_added])
|
||||
if new_devices_added:
|
||||
message_text = self.i18n_catalog.i18nc("info:status", "Printers added from Digital Factory:") + f"<ul>{device_names}</ul>"
|
||||
message.setText(message_text)
|
||||
else:
|
||||
message.hide()
|
||||
|
||||
def _updateOnlinePrinters(self, printer_responses: Dict[str, CloudClusterResponse]) -> None:
|
||||
"""
|
||||
|
|
|
@ -19,7 +19,12 @@ class NewPrinterDetectedMessage(Message):
|
|||
self._printers_added = 0
|
||||
self._num_printers_found = num_printers_found
|
||||
|
||||
def updateDisplayText(self, output_device):
|
||||
def updateProgressText(self, output_device):
|
||||
"""
|
||||
While the progress of adding printers is running, update the text displayed.
|
||||
:param output_device: The output device that is being added.
|
||||
:return:
|
||||
"""
|
||||
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)
|
||||
|
@ -29,3 +34,27 @@ class NewPrinterDetectedMessage(Message):
|
|||
self._printers_added += 1
|
||||
|
||||
CuraApplication.getInstance().processEvents()
|
||||
|
||||
def finalize(self, new_devices_added, new_output_devices):
|
||||
self.setProgress(None)
|
||||
num_devices_added = len(new_devices_added)
|
||||
max_disp_devices = 3
|
||||
|
||||
if num_devices_added > max_disp_devices:
|
||||
num_hidden = num_devices_added - max_disp_devices
|
||||
device_name_list = ["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in
|
||||
new_output_devices[0: max_disp_devices]]
|
||||
device_name_list.append(
|
||||
"<li>" + self.i18n_catalog.i18ncp("info:{0} gets replaced by a number of printers", "... and {0} other",
|
||||
"... and {0} others", num_hidden) + "</li>")
|
||||
device_names = "".join(device_name_list)
|
||||
else:
|
||||
device_names = "".join(
|
||||
["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in new_devices_added])
|
||||
|
||||
if new_devices_added:
|
||||
message_text = self.i18n_catalog.i18nc("info:status",
|
||||
"Printers added from Digital Factory:") + f"<ul>{device_names}</ul>"
|
||||
self.setText(message_text)
|
||||
else:
|
||||
self.hide()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue