mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46: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")
|
@pyqtSlot("QVariant")
|
||||||
def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None:
|
def createMachineFromDiscoveredPrinter(self, discovered_printer: "DiscoveredPrinter") -> None:
|
||||||
discovered_printer.create_callback(discovered_printer.getKey())
|
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:
|
else:
|
||||||
self.getOutputDeviceManager().removeOutputDevice(key)
|
self.getOutputDeviceManager().removeOutputDevice(key)
|
||||||
if key.startswith("manual:"):
|
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):
|
def stop(self):
|
||||||
if self._zero_conf is not None:
|
if self._zero_conf is not None:
|
||||||
|
@ -188,8 +188,8 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
self._cloud_output_device_manager.stop()
|
self._cloud_output_device_manager.stop()
|
||||||
|
|
||||||
def canAddManualDevice(self, address: str) -> ManualDeviceAdditionAttempt:
|
def canAddManualDevice(self, address: str) -> ManualDeviceAdditionAttempt:
|
||||||
|
# This plugin should always be the fallback option (at least try it):
|
||||||
return ManualDeviceAdditionAttempt.POSSIBLE
|
return ManualDeviceAdditionAttempt.POSSIBLE
|
||||||
# TODO?: Check if address is a valid IP (by regexp?).
|
|
||||||
|
|
||||||
def removeManualDevice(self, key, address = None):
|
def removeManualDevice(self, key, address = None):
|
||||||
if key in self._discovered_devices:
|
if key in self._discovered_devices:
|
||||||
|
@ -202,7 +202,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
self._manual_instances.remove(address)
|
self._manual_instances.remove(address)
|
||||||
self._preferences.setValue("um3networkprinting/manual_instances", ",".join(self._manual_instances))
|
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):
|
def addManualDevice(self, address):
|
||||||
if address not in self._manual_instances:
|
if address not in self._manual_instances:
|
||||||
|
@ -226,8 +226,6 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
|
||||||
self._checkManualDevice(address)
|
self._checkManualDevice(address)
|
||||||
|
|
||||||
def _createMachineFromDiscoveredPrinter(self, key: str) -> None:
|
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)
|
discovered_device = self._discovered_devices.get(key)
|
||||||
if discovered_device is None:
|
if discovered_device is None:
|
||||||
Logger.log("e", "Could not find discovered device with key [%s]", key)
|
Logger.log("e", "Could not find discovered device with key [%s]", key)
|
||||||
|
|
|
@ -55,7 +55,6 @@ Item
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.margins: 20
|
anchors.margins: 20
|
||||||
//anchors.bottomMargin: 20
|
|
||||||
font: UM.Theme.getFont("default")
|
font: UM.Theme.getFont("default")
|
||||||
|
|
||||||
text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.")
|
text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.")
|
||||||
|
@ -111,7 +110,12 @@ Item
|
||||||
BusyIndicator
|
BusyIndicator
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
running: { ! parent.enabled && ! addPrinterByIpScreen.hasSentRequest }
|
running:
|
||||||
|
{
|
||||||
|
! parent.enabled &&
|
||||||
|
! addPrinterByIpScreen.hasSentRequest &&
|
||||||
|
! addPrinterByIpScreen.haveConnection
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,6 +158,7 @@ Item
|
||||||
{
|
{
|
||||||
id: printerInfoGrid
|
id: printerInfoGrid
|
||||||
anchors.top: printerNameLabel.bottom
|
anchors.top: printerNameLabel.bottom
|
||||||
|
anchors.margins: 20
|
||||||
columns: 2
|
columns: 2
|
||||||
columnSpacing: 20
|
columnSpacing: 20
|
||||||
|
|
||||||
|
@ -217,10 +222,8 @@ Item
|
||||||
fixedWidthMode: true
|
fixedWidthMode: true
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
Cura.MachineManager.addMachine(
|
CuraApplication.getDiscoveredPrintersModel().createMachineFromDiscoveredPrinterAddress(
|
||||||
UM.OutputDeviceManager.manualDeviceProperty("printer_type"),
|
UM.OutputDeviceManager.manualDeviceProperty("address"))
|
||||||
UM.OutputDeviceManager.manualDeviceProperty("name")
|
|
||||||
)
|
|
||||||
UM.OutputDeviceManager.setActiveDevice(UM.OutputDeviceManager.manualDeviceProperty("device_id"))
|
UM.OutputDeviceManager.setActiveDevice(UM.OutputDeviceManager.manualDeviceProperty("device_id"))
|
||||||
base.showNextPage()
|
base.showNextPage()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue