From b4ba7a64a98bb5a6514433f4cf6b9b49d9872c4f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 26 Sep 2016 12:01:54 +0200 Subject: [PATCH] Only update printer list after printer is added/removed This makes it emit a signal only after addPrinter and removePrinter has completed executing, so we know that updating the list is done by the time it refreshes the list view in QML. Contributes to issue CURA-2393. --- DiscoverUM3Action.py | 3 +-- NetworkPrinterOutputDevicePlugin.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DiscoverUM3Action.py b/DiscoverUM3Action.py index 0d8c0ad060..95105425c1 100644 --- a/DiscoverUM3Action.py +++ b/DiscoverUM3Action.py @@ -36,8 +36,7 @@ class DiscoverUM3Action(MachineAction): def startDiscovery(self): if not self._network_plugin: self._network_plugin = Application.getInstance().getOutputDeviceManager().getOutputDevicePlugin("JediWifiPrintingPlugin") - self._network_plugin.addPrinterSignal.connect(self._onPrinterDiscoveryChanged) - self._network_plugin.removePrinterSignal.connect(self._onPrinterDiscoveryChanged) + self._network_plugin.printerListChanged.connect(self._onPrinterDiscoveryChanged) self.printersChanged.emit() @pyqtSlot() diff --git a/NetworkPrinterOutputDevicePlugin.py b/NetworkPrinterOutputDevicePlugin.py index edcd406fab..a168f2ae43 100644 --- a/NetworkPrinterOutputDevicePlugin.py +++ b/NetworkPrinterOutputDevicePlugin.py @@ -30,6 +30,7 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): addPrinterSignal = Signal() removePrinterSignal = Signal() + printerListChanged = Signal() ## Start looking for devices on network. def start(self): @@ -73,6 +74,7 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): if printer.getKey() not in self._old_printers: # Was the printer already connected, but a re-scan forced? self._printers[printer.getKey()].connect() printer.connectionStateChanged.connect(self._onPrinterConnectionStateChanged) + self.printerListChanged.emit() def removePrinter(self, name): printer = self._printers.pop(name, None) @@ -80,6 +82,7 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): if printer.isConnected(): printer.connectionStateChanged.disconnect(self._onPrinterConnectionStateChanged) printer.disconnect() + self.printerListChanged.emit() ## Handler for when the connection state of one of the detected printers changes def _onPrinterConnectionStateChanged(self, key):