From 9aef692082ad244870ee311b4ee12534a1bfa5a6 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 22 Mar 2019 14:52:11 +0100 Subject: [PATCH 1/3] Emit added or removed clusters Useful to whomever is listening in on those signals to know _what_ was added or removed. Contributes to CL-1267 --- .../UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index e081beb99c..67245eb357 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -86,7 +86,7 @@ class CloudOutputDeviceManager: removed_cluster.disconnect() removed_cluster.close() self._output_device_manager.removeOutputDevice(removed_cluster.key) - self.removedCloudCluster.emit() + self.removedCloudCluster.emit(removed_cluster) del self._remote_clusters[removed_cluster.key] # Add an output device for each new remote cluster. @@ -94,7 +94,7 @@ class CloudOutputDeviceManager: for added_cluster in added_clusters: device = CloudOutputDevice(self._api, added_cluster) self._remote_clusters[added_cluster.cluster_id] = device - self.addedCloudCluster.emit() + self.addedCloudCluster.emit(added_cluster) for device, cluster in updates: device.clusterData = cluster From 223354378093afd04af7a9861f010bd4e74c7a7e Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 22 Mar 2019 14:53:55 +0100 Subject: [PATCH 2/3] Only set "do not show cloud message" metadata if active machine is the added cloud cluster Contributes to CL-1267 --- .../UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index a32193849e..9dedf4bca2 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -458,7 +458,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): if self._start_cloud_flow_message and not self._start_cloud_flow_message.visible: self._start_cloud_flow_message.show() - def _onCloudPrintingConfigured(self) -> None: + def _onCloudPrintingConfigured(self, device) -> None: # Hide the cloud flow start message if it was hanging around already # For example: if the user already had the browser openen and made the association themselves if self._start_cloud_flow_message and self._start_cloud_flow_message.visible: @@ -473,7 +473,16 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): # Set the machine's cloud flow as complete so we don't ask the user again and again for cloud connected printers active_machine = self._application.getMachineManager().activeMachine if active_machine: - active_machine.setMetaDataEntry("do_not_show_cloud_message", True) + + # The active machine _might_ not be the machine that was in the added cloud cluster and + # then this will hide the cloud message for the wrong machine. So we only set it if the + # host names match between the active machine and the newly added cluster + saved_host_name = active_machine.getMetaDataEntry("um_network_key", "").split('.')[0] + added_host_name = device.toDict()["host_name"] + + if added_host_name == saved_host_name: + active_machine.setMetaDataEntry("do_not_show_cloud_message", True) + return def _onDontAskMeAgain(self, checked: bool) -> None: From feec1ffb5643b2ce6ece7d2a54e9ca32fdad02f4 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 1 Apr 2019 12:17:01 +0200 Subject: [PATCH 3/3] Improve signals Contributes to CL-1267 --- .../UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 67245eb357..680caa568a 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -32,8 +32,8 @@ class CloudOutputDeviceManager: # The translation catalog for this device. I18N_CATALOG = i18nCatalog("cura") - addedCloudCluster = Signal() - removedCloudCluster = Signal() + addedCloudCluster = Signal(CloudOutputDevice) + removedCloudCluster = Signal(CloudOutputDevice) def __init__(self) -> None: # Persistent dict containing the remote clusters for the authenticated user.