mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Update plugin to API version 3
Contributes to CURA-49
This commit is contained in:
parent
3f4e740c0d
commit
65f329623f
2 changed files with 8 additions and 7 deletions
|
@ -18,7 +18,7 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
||||||
|
|
||||||
# Because the model needs to be created in the same thread as the QMLEngine, we use a signal.
|
# Because the model needs to be created in the same thread as the QMLEngine, we use a signal.
|
||||||
self.addPrinterSignal.connect(self.addPrinter)
|
self.addPrinterSignal.connect(self.addPrinter)
|
||||||
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineInstanceChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
|
||||||
|
|
||||||
addPrinterSignal = Signal()
|
addPrinterSignal = Signal()
|
||||||
|
|
||||||
|
@ -30,12 +30,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self._zero_conf.close()
|
self._zero_conf.close()
|
||||||
|
|
||||||
def _onActiveMachineInstanceChanged(self):
|
def _onGlobalContainerStackChanged(self):
|
||||||
try:
|
try:
|
||||||
active_machine_key = Application.getInstance().getMachineManager().getActiveMachineInstance().getKey()
|
active_machine_key = Application.getInstance().getGlobalContainerStack().getId()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
## Active machine instance changed to None. This can happen upon clean start. Simply ignore.
|
## Active machine instance changed to None. This can happen upon clean start. Simply ignore.
|
||||||
return
|
return
|
||||||
|
|
||||||
for key in self._printers:
|
for key in self._printers:
|
||||||
if key == active_machine_key:
|
if key == active_machine_key:
|
||||||
self._printers[key].connect()
|
self._printers[key].connect()
|
||||||
|
@ -47,8 +48,8 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
||||||
def addPrinter(self, name, address, properties):
|
def addPrinter(self, name, address, properties):
|
||||||
printer = NetworkPrinterOutputDevice.NetworkPrinterOutputDevice(name, address, properties)
|
printer = NetworkPrinterOutputDevice.NetworkPrinterOutputDevice(name, address, properties)
|
||||||
self._printers[printer.getKey()] = printer
|
self._printers[printer.getKey()] = printer
|
||||||
active_machine_instance = Application.getInstance().getMachineManager().getActiveMachineInstance()
|
stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if active_machine_instance and printer.getKey() == active_machine_instance.getKey():
|
if stack and printer.getKey() == stack.getKey():
|
||||||
self._printers[printer.getKey()].connect()
|
self._printers[printer.getKey()].connect()
|
||||||
printer.connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
|
printer.connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
|
||||||
|
|
||||||
|
@ -71,4 +72,4 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
||||||
elif state_change == ServiceStateChange.Removed:
|
elif state_change == ServiceStateChange.Removed:
|
||||||
pass
|
pass
|
||||||
# TODO; This isn't testable right now. We need to also decide how to handle
|
# TODO; This isn't testable right now. We need to also decide how to handle
|
||||||
#
|
#
|
||||||
|
|
|
@ -11,7 +11,7 @@ def getMetaData():
|
||||||
"name": "Wifi connection",
|
"name": "Wifi connection",
|
||||||
"author": "Ultimaker",
|
"author": "Ultimaker",
|
||||||
"description": catalog.i18nc("Wifi connection", "Wifi connection"),
|
"description": catalog.i18nc("Wifi connection", "Wifi connection"),
|
||||||
"api": 2
|
"api": 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue