mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Better refresh button: now emits signal and re-instantiates zeroconf.
Signal emits let the UI display an empty list. Re-instantiation copes with network changes. Contributes to CURA-2372
This commit is contained in:
parent
1ed3fc7c37
commit
da4ea2e450
2 changed files with 8 additions and 4 deletions
|
@ -104,7 +104,6 @@ class DiscoverUM3Action(MachineAction):
|
|||
|
||||
def _createAdditionalComponentsView(self):
|
||||
Logger.log("d", "Creating additional ui components for UM3.")
|
||||
|
||||
path = QUrl.fromLocalFile(os.path.join(PluginRegistry.getInstance().getPluginPath("UM3NetworkPrinting"), "UM3InfoComponents.qml"))
|
||||
self.__additional_component = QQmlComponent(Application.getInstance()._engine, path)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import time
|
|||
class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._zero_conf = Zeroconf()
|
||||
self._zero_conf = None
|
||||
self._browser = None
|
||||
self._printers = {}
|
||||
|
||||
|
@ -37,16 +37,21 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
|||
self.startDiscovery()
|
||||
|
||||
def startDiscovery(self):
|
||||
self.stop()
|
||||
if self._browser:
|
||||
self._browser.cancel()
|
||||
self._browser = None
|
||||
self._old_printers = [printer_name for printer_name in self._printers]
|
||||
self._printers = {}
|
||||
|
||||
self.printerListChanged.emit()
|
||||
# After network switching, one must make a new instance of Zeroconf
|
||||
# On windows, the instance creation is very fast (unnoticable). Other platforms?
|
||||
self._zero_conf = Zeroconf()
|
||||
self._browser = ServiceBrowser(self._zero_conf, u'_ultimaker._tcp.local.', [self._onServiceChanged])
|
||||
|
||||
## Stop looking for devices on network.
|
||||
def stop(self):
|
||||
if self._zero_conf is not None:
|
||||
self._zero_conf.close()
|
||||
|
||||
def getPrinters(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue