mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 23:17:32 -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.
|
||||
self.addPrinterSignal.connect(self.addPrinter)
|
||||
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineInstanceChanged)
|
||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
|
||||
|
||||
addPrinterSignal = Signal()
|
||||
|
||||
|
@ -30,12 +30,13 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
|||
def stop(self):
|
||||
self._zero_conf.close()
|
||||
|
||||
def _onActiveMachineInstanceChanged(self):
|
||||
def _onGlobalContainerStackChanged(self):
|
||||
try:
|
||||
active_machine_key = Application.getInstance().getMachineManager().getActiveMachineInstance().getKey()
|
||||
active_machine_key = Application.getInstance().getGlobalContainerStack().getId()
|
||||
except AttributeError:
|
||||
## Active machine instance changed to None. This can happen upon clean start. Simply ignore.
|
||||
return
|
||||
|
||||
for key in self._printers:
|
||||
if key == active_machine_key:
|
||||
self._printers[key].connect()
|
||||
|
@ -47,8 +48,8 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
|||
def addPrinter(self, name, address, properties):
|
||||
printer = NetworkPrinterOutputDevice.NetworkPrinterOutputDevice(name, address, properties)
|
||||
self._printers[printer.getKey()] = printer
|
||||
active_machine_instance = Application.getInstance().getMachineManager().getActiveMachineInstance()
|
||||
if active_machine_instance and printer.getKey() == active_machine_instance.getKey():
|
||||
stack = Application.getInstance().getGlobalContainerStack()
|
||||
if stack and printer.getKey() == stack.getKey():
|
||||
self._printers[printer.getKey()].connect()
|
||||
printer.connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
|
||||
|
||||
|
@ -71,4 +72,4 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin, SignalEmitter):
|
|||
elif state_change == ServiceStateChange.Removed:
|
||||
pass
|
||||
# TODO; This isn't testable right now. We need to also decide how to handle
|
||||
#
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue