diff --git a/cura/Machines/Models/DiscoveredPrintersModel.py b/cura/Machines/Models/DiscoveredPrintersModel.py index 0dd07eb9ce..e31b8133a8 100644 --- a/cura/Machines/Models/DiscoveredPrintersModel.py +++ b/cura/Machines/Models/DiscoveredPrintersModel.py @@ -126,3 +126,11 @@ class DiscoveredPrintersModel(QObject): @pyqtSlot("QVariant") def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None: discovered_printer.create_callback(discovered_printer.getKey()) + + @pyqtSlot(str) + def createMachineFromDiscoveredPrinterAddress(self, ip_address: str) -> None: + if ip_address not in self._discovered_printer_dict: + Logger.log("i", "Key [%s] does not exist in the discovered printers list.", ip_address) + return + + self.createMachineFromDiscoveredPrinter(self._discovered_printer_dict[ip_address]) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index c99b12de55..4c775572f3 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -179,7 +179,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): else: self.getOutputDeviceManager().removeOutputDevice(key) if key.startswith("manual:"): - self.removeManualDeviceSignal.emit(self.getPluginId(), key, self._discovered_devices[key].address()) # TODO? + self.removeManualDeviceSignal.emit(self.getPluginId(), key, self._discovered_devices[key].address) def stop(self): if self._zero_conf is not None: @@ -188,8 +188,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._cloud_output_device_manager.stop() def canAddManualDevice(self, address: str) -> ManualDeviceAdditionAttempt: + # This plugin should always be the fallback option (at least try it): return ManualDeviceAdditionAttempt.POSSIBLE - # TODO?: Check if address is a valid IP (by regexp?). def removeManualDevice(self, key, address = None): if key in self._discovered_devices: @@ -202,7 +202,7 @@ 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? + self.removeManualDeviceSignal.emit(self.getPluginId(), key, address) def addManualDevice(self, address): if address not in self._manual_instances: @@ -226,8 +226,6 @@ 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. discovered_device = self._discovered_devices.get(key) if discovered_device is None: Logger.log("e", "Could not find discovered device with key [%s]", key) diff --git a/resources/qml/WelcomePages/AddPrinterByIpContent.qml b/resources/qml/WelcomePages/AddPrinterByIpContent.qml index 47e45cda8a..3aa3e8dc2b 100644 --- a/resources/qml/WelcomePages/AddPrinterByIpContent.qml +++ b/resources/qml/WelcomePages/AddPrinterByIpContent.qml @@ -55,7 +55,6 @@ Item width: parent.width anchors.top: parent.top anchors.margins: 20 - //anchors.bottomMargin: 20 font: UM.Theme.getFont("default") text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.") @@ -111,7 +110,12 @@ Item BusyIndicator { anchors.fill: parent - running: { ! parent.enabled && ! addPrinterByIpScreen.hasSentRequest } + running: + { + ! parent.enabled && + ! addPrinterByIpScreen.hasSentRequest && + ! addPrinterByIpScreen.haveConnection + } } } } @@ -154,6 +158,7 @@ Item { id: printerInfoGrid anchors.top: printerNameLabel.bottom + anchors.margins: 20 columns: 2 columnSpacing: 20 @@ -217,10 +222,8 @@ Item fixedWidthMode: true onClicked: { - Cura.MachineManager.addMachine( - UM.OutputDeviceManager.manualDeviceProperty("printer_type"), - UM.OutputDeviceManager.manualDeviceProperty("name") - ) + CuraApplication.getDiscoveredPrintersModel().createMachineFromDiscoveredPrinterAddress( + UM.OutputDeviceManager.manualDeviceProperty("address")) UM.OutputDeviceManager.setActiveDevice(UM.OutputDeviceManager.manualDeviceProperty("device_id")) base.showNextPage() }