From 084e80bcda30dd62873966a50f9998672e92d367 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 29 Apr 2020 13:48:06 +0200 Subject: [PATCH] Only connect a cloud printer if it's the active one By splitting up the correctly setting of metadata and actually connecting, the distinction can be made. CURA-7055 --- .../src/Cloud/CloudOutputDeviceManager.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py index 65625df3bc..cae585ffa4 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py @@ -226,11 +226,11 @@ class CloudOutputDeviceManager: return new_machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) + self._setOutputDeviceMetadata(device, new_machine) + if activate: CuraApplication.getInstance().getMachineManager().setActiveMachine(new_machine.getId()) - self._connectToOutputDevice(device, new_machine) - def _connectToActiveMachine(self) -> None: """Callback for when the active machine was changed by the user""" @@ -252,14 +252,17 @@ class CloudOutputDeviceManager: # Remove device if it is not meant for the active machine. output_device_manager.removeOutputDevice(device.key) - def _connectToOutputDevice(self, device: CloudOutputDevice, machine: GlobalStack) -> None: - """Connects to an output device and makes sure it is registered in the output device manager.""" - + def _setOutputDeviceMetadata(self, device: CloudOutputDevice, machine: GlobalStack): machine.setName(device.name) machine.setMetaDataEntry(self.META_CLUSTER_ID, device.key) machine.setMetaDataEntry("group_name", device.name) machine.addConfiguredConnectionType(device.connectionType.value) + def _connectToOutputDevice(self, device: CloudOutputDevice, machine: GlobalStack) -> None: + """Connects to an output device and makes sure it is registered in the output device manager.""" + + self._setOutputDeviceMetadata(device, machine) + if not device.isConnected(): device.connect()