mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Action now has a list of found UM3 keys
CURA-336
This commit is contained in:
parent
d7bb807e2b
commit
f199d490bb
3 changed files with 33 additions and 2 deletions
|
@ -1,9 +1,32 @@
|
||||||
from cura.MachineAction import MachineAction
|
from cura.MachineAction import MachineAction
|
||||||
|
|
||||||
|
from UM.Application import Application
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
|
||||||
|
|
||||||
class DiscoverUM3Action(MachineAction):
|
class DiscoverUM3Action(MachineAction):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__("DiscoverUM3Action", "Discover printers")
|
super().__init__("DiscoverUM3Action", "Discover printers")
|
||||||
self._qml_url = "DiscoverUM3Action.qml"
|
self._qml_url = "DiscoverUM3Action.qml"
|
||||||
|
|
||||||
def _execute(self):
|
self._network_plugin = None
|
||||||
pass
|
|
||||||
|
printerDetected = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def startDiscovery(self):
|
||||||
|
if not self._network_plugin:
|
||||||
|
self._network_plugin = Application.getInstance().getOutputDeviceManager().getOutputDevicePlugin("JediWifiPrintingPlugin")
|
||||||
|
self._network_plugin.addPrinterSignal.connect(self._onPrinterAdded)
|
||||||
|
self.printerDetected.emit()
|
||||||
|
|
||||||
|
def _onPrinterAdded(self, *args):
|
||||||
|
self.printerDetected.emit()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = printerDetected)
|
||||||
|
def foundDevices(self):
|
||||||
|
if self._network_plugin:
|
||||||
|
print(list(self._network_plugin.getPrinters().keys()))
|
||||||
|
return list(self._network_plugin.getPrinters().keys())
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
|
@ -22,5 +22,10 @@ Cura.MachineAction
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
font.pointSize: 18;
|
font.pointSize: 18;
|
||||||
}
|
}
|
||||||
|
Button
|
||||||
|
{
|
||||||
|
text: "Start looking!"
|
||||||
|
onClicked: manager.startDiscovery()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,6 +31,9 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._zero_conf.close()
|
self._zero_conf.close()
|
||||||
|
|
||||||
|
def getPrinters(self):
|
||||||
|
return self._printers
|
||||||
|
|
||||||
def _onGlobalStackChanged(self):
|
def _onGlobalStackChanged(self):
|
||||||
active_machine = Application.getInstance().getGlobalContainerStack()
|
active_machine = Application.getInstance().getGlobalContainerStack()
|
||||||
if not active_machine:
|
if not active_machine:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue