diff --git a/cura/Settings/CuraStackBuilder.py b/cura/Settings/CuraStackBuilder.py index 7ede6950d7..ff9a795c43 100644 --- a/cura/Settings/CuraStackBuilder.py +++ b/cura/Settings/CuraStackBuilder.py @@ -17,7 +17,7 @@ class CuraStackBuilder: """Contains helper functions to create new machines.""" @classmethod - def createMachine(cls, name: str, definition_id: str, machine_extruder_count: Optional[int] = None) -> Optional[GlobalStack]: + def createMachine(cls, name: str, definition_id: str, machine_extruder_count: Optional[int] = None, show_warning_message: bool = True) -> Optional[GlobalStack]: """Create a new instance of a machine. :param name: The name of the new machine. @@ -34,7 +34,8 @@ class CuraStackBuilder: definitions = registry.findDefinitionContainers(id = definition_id) if not definitions: - ConfigurationErrorMessage.getInstance().addFaultyContainers(definition_id) + if show_warning_message: + ConfigurationErrorMessage.getInstance().addFaultyContainers(definition_id) Logger.log("w", "Definition {definition} was not found!", definition = definition_id) return None diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index d88814818a..f7f659124c 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -236,6 +236,8 @@ class CloudOutputDeviceManager: ) message.show() + new_devices_added = [] + for idx, device in enumerate(new_devices): 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 = device.name, model = device.printerTypeName) message.setText(message_text) @@ -246,21 +248,25 @@ class CloudOutputDeviceManager: # If there is no active machine, activate the first available cloud printer activate = not CuraApplication.getInstance().getMachineManager().activeMachine - self._createMachineFromDiscoveredDevice(device.getId(), activate = activate) + + if self._createMachineFromDiscoveredDevice(device.getId(), activate = activate): + new_devices_added.append(device) message.setProgress(None) max_disp_devices = 3 - if len(new_devices) > max_disp_devices: - num_hidden = len(new_devices) - max_disp_devices + if len(new_devices_added) > max_disp_devices: + num_hidden = len(new_devices_added) - max_disp_devices device_name_list = ["
  • {} ({})
  • ".format(device.name, device.printerTypeName) for device in new_devices[0:max_disp_devices]] device_name_list.append("
  • " + self.i18n_catalog.i18ncp("info:{0} gets replaced by a number of printers", "... and {0} other", "... and {0} others", num_hidden) + "
  • ") device_names = "".join(device_name_list) else: - device_names = "".join(["
  • {} ({})
  • ".format(device.name, device.printerTypeName) for device in new_devices]) - - message_text = self.i18n_catalog.i18nc("info:status", "Printers added from Digital Factory:") + "" - message.setText(message_text) + device_names = "".join(["
  • {} ({})
  • ".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:") + "" + message.setText(message_text) + else: + message.hide() def _updateOnlinePrinters(self, printer_responses: Dict[str, CloudClusterResponse]) -> None: """ @@ -385,23 +391,25 @@ class CloudOutputDeviceManager: if device.key in output_device_manager.getOutputDeviceIds(): output_device_manager.removeOutputDevice(device.key) - def _createMachineFromDiscoveredDevice(self, key: str, activate: bool = True) -> None: + def _createMachineFromDiscoveredDevice(self, key: str, activate: bool = True) -> bool: device = self._remote_clusters[key] if not device: - return + return False # Create a new machine. # We do not use use MachineManager.addMachine here because we need to set the cluster ID before activating it. - new_machine = CuraStackBuilder.createMachine(device.name, device.printerType) + new_machine = CuraStackBuilder.createMachine(device.name, device.printerType, show_warning_message=False) if not new_machine: Logger.log("e", "Failed creating a new machine") - return + return False self._setOutputDeviceMetadata(device, new_machine) if activate: CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) + return True + def _connectToActiveMachine(self) -> None: """Callback for when the active machine was changed by the user"""