Add the discovered printer functionality

This can be used in the add machine wizard to short circuit the creation of a printer.
So instead of first selecting a printer and then connecting it, it will be possible to have
a list that contains all network discovered printers (from all plugins that can do this).

This means we can select one of those printers and directly add it (thus no longer needing that step)

CURA-6179
This commit is contained in:
Jaime van Kessel 2019-02-27 11:05:54 +01:00
parent 5c354eb6a3
commit 21c6bba1ce
3 changed files with 33 additions and 4 deletions

View file

@ -213,6 +213,11 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self._checkManualDevice(address)
def _createMachineFromDiscoveredPrinter(self, key: str) -> None:
# TODO: This needs to be implemented. It's supposed to create a machine given a unique key as already discovered
# by this plugin.
pass
def _checkManualDevice(self, address):
# Check if a UM3 family device exists at this address.
# If a printer responds, it will replace the preliminary printer created above
@ -293,7 +298,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
except TypeError:
# Disconnect already happened.
pass
self._application.getMachineManager().removeDiscoveredPrinter(device.getId())
self.discoveredDevicesChanged.emit()
def _onAddDevice(self, name, address, properties):
@ -318,7 +323,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
device = ClusterUM3OutputDevice.ClusterUM3OutputDevice(name, address, properties)
else:
device = LegacyUM3OutputDevice.LegacyUM3OutputDevice(name, address, properties)
self._application.getMachineManager().addDiscoveredPrinter(device.getId(), name, self._createMachineFromDiscoveredPrinter, properties[b"printer_type"].decode("utf-8"))
self._discovered_devices[device.getId()] = device
self.discoveredDevicesChanged.emit()