mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
(WIP) Connect manual-device-added signals to AddPrinterByIP-page. [CURA-6294]
This commit is contained in:
parent
6d34a2abd0
commit
bb17ab14da
2 changed files with 43 additions and 9 deletions
|
@ -34,6 +34,8 @@ i18n_catalog = i18nCatalog("cura")
|
|||
# If we discover a printer that has the same key as the active machine instance a connection is made.
|
||||
@signalemitter
|
||||
class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||
addDeviceSignal = Signal()
|
||||
removeDeviceSignal = Signal()
|
||||
discoveredDevicesChanged = Signal()
|
||||
cloudFlowIsPossible = Signal()
|
||||
|
||||
|
@ -173,6 +175,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self.checkCloudFlowIsPossible()
|
||||
else:
|
||||
self.getOutputDeviceManager().removeOutputDevice(key)
|
||||
if key.startswith("manual:"):
|
||||
self.removeManualDeviceSignal.emit(self.getPluginId(), key, self._discovered_devices[key].address()) # TODO?
|
||||
|
||||
def stop(self):
|
||||
if self._zero_conf is not None:
|
||||
|
@ -195,6 +199,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._manual_instances.remove(address)
|
||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
||||
|
||||
self.removeManualDeviceSignal.emit(self.getPluginId(), key, address) # TODO?
|
||||
|
||||
def addManualDevice(self, address):
|
||||
if address not in self._manual_instances:
|
||||
self._manual_instances.append(address)
|
||||
|
@ -232,6 +238,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
def _onNetworkRequestFinished(self, reply):
|
||||
reply_url = reply.url().toString()
|
||||
|
||||
address = ""
|
||||
device = None
|
||||
properties = {} # type: Dict[bytes, bytes]
|
||||
|
||||
if "system" in reply_url:
|
||||
if reply.attribute(QNetworkRequest.HttpStatusCodeAttribute) != 200:
|
||||
# Something went wrong with checking the firmware version!
|
||||
|
@ -291,6 +301,9 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
|||
self._onRemoveDevice(instance_name)
|
||||
self._onAddDevice(instance_name, address, properties)
|
||||
|
||||
if device:
|
||||
self.addManualDeviceSignal.emit(self.getPluginId(), device.getId(), address, properties)
|
||||
|
||||
def _onRemoveDevice(self, device_id):
|
||||
device = self._discovered_devices.pop(device_id, None)
|
||||
if device:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue