Rename usage of printer to more generic device.

The usage of "printer" is a bit confusing, as in the case of CuraConnect
it's a device that can acces multiple printers.

CL-541
This commit is contained in:
Jaime van Kessel 2017-11-20 13:18:08 +01:00
parent 9202bb11fe
commit 68e80a88bc

View file

@ -27,24 +27,26 @@ class DiscoverUM3Action(MachineAction):
Application.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView) Application.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView)
self._last_zeroconf_event_time = time.time() self._last_zero_conf_event_time = time.time()
self._zeroconf_change_grace_period = 0.25 # Time to wait after a zeroconf service change before allowing a zeroconf reset
printersChanged = pyqtSignal() # Time to wait after a zero-conf service change before allowing a zeroconf reset
self._zero_conf_change_grace_period = 0.25
discoveredDevicesChanged = pyqtSignal()
@pyqtSlot() @pyqtSlot()
def startDiscovery(self): def startDiscovery(self):
if not self._network_plugin: if not self._network_plugin:
Logger.log("d", "Starting printer discovery.") Logger.log("d", "Starting device discovery.")
self._network_plugin = Application.getInstance().getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting") self._network_plugin = Application.getInstance().getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting")
self._network_plugin.discoveredDevicesChanged.connect(self._onPrinterDiscoveryChanged) self._network_plugin.discoveredDevicesChanged.connect(self._onDeviceDiscoveryChanged)
self.printersChanged.emit() self.discoveredDevicesChanged.emit()
## Re-filters the list of printers. ## Re-filters the list of devices.
@pyqtSlot() @pyqtSlot()
def reset(self): def reset(self):
Logger.log("d", "Reset the list of found printers.") Logger.log("d", "Reset the list of found devices.")
self.printersChanged.emit() self.discoveredDevicesChanged.emit()
@pyqtSlot() @pyqtSlot()
def restartDiscovery(self): def restartDiscovery(self):
@ -53,35 +55,36 @@ class DiscoverUM3Action(MachineAction):
# It's most likely that the QML engine is still creating delegates, where the python side already deleted or # It's most likely that the QML engine is still creating delegates, where the python side already deleted or
# garbage collected the data. # garbage collected the data.
# Whatever the case, waiting a bit ensures that it doesn't crash. # Whatever the case, waiting a bit ensures that it doesn't crash.
if time.time() - self._last_zeroconf_event_time > self._zeroconf_change_grace_period: if time.time() - self._last_zero_conf_event_time > self._zero_conf_change_grace_period:
if not self._network_plugin: if not self._network_plugin:
self.startDiscovery() self.startDiscovery()
else: else:
self._network_plugin.startDiscovery() self._network_plugin.startDiscovery()
@pyqtSlot(str, str) @pyqtSlot(str, str)
def removeManualPrinter(self, key, address): def removeManualDevice(self, key, address):
if not self._network_plugin: if not self._network_plugin:
return return
self._network_plugin.removeManualPrinter(key, address) self._network_plugin.removeManualDevice(key, address)
@pyqtSlot(str, str) @pyqtSlot(str, str)
def setManualPrinter(self, key, address): def setManualDevice(self, key, address):
if key != "": if key != "":
# This manual printer replaces a current manual printer # This manual printer replaces a current manual printer
self._network_plugin.removeManualPrinter(key) self._network_plugin.removeManualDevice(key)
if address != "": if address != "":
self._network_plugin.addManualPrinter(address) self._network_plugin.addManualPrinter(address)
def _onPrinterDiscoveryChanged(self, *args): def _onDeviceDiscoveryChanged(self, *args):
self._last_zeroconf_event_time = time.time() self._last_zero_conf_event_time = time.time()
self.printersChanged.emit() self.discoveredDevicesChanged.emit()
@pyqtProperty("QVariantList", notify = printersChanged) @pyqtProperty("QVariantList", notify = discoveredDevicesChanged)
def foundDevices(self): def foundDevices(self):
if self._network_plugin: if self._network_plugin:
# TODO: Check if this needs to stay.
if Application.getInstance().getGlobalContainerStack(): if Application.getInstance().getGlobalContainerStack():
global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId() global_printer_type = Application.getInstance().getGlobalContainerStack().getBottom().getId()
else: else: