mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
(Add-by-IP/onboard) Cleanup and use discovered-printer instead of machine-manager. [CURA-6294]
This commit is contained in:
parent
61821e6378
commit
2693eecd33
3 changed files with 20 additions and 11 deletions
|
@ -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])
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue