diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index dcd6b5ca70..f8d2ec66e2 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -1,3 +1,6 @@ +# Copyright (c) 2017 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + from UM.Application import Application from UM.Logger import Logger diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 9744f352fd..5b747d19bf 100644 --- a/cura/PrinterOutputDevice.py +++ b/cura/PrinterOutputDevice.py @@ -34,6 +34,7 @@ i18n_catalog = i18nCatalog("cura") class PrinterOutputDevice(QObject, OutputDevice): printersChanged = pyqtSignal() connectionStateChanged = pyqtSignal(str) + acceptsCommandsChanged = pyqtSignal() def __init__(self, device_id, parent = None): super().__init__(device_id = device_id, parent = parent) @@ -49,6 +50,7 @@ class PrinterOutputDevice(QObject, OutputDevice): self._control_item = None self._qml_context = None + self._accepts_commands = False self._update_timer = QTimer() self._update_timer.setInterval(2000) # TODO; Add preference for update interval @@ -152,6 +154,17 @@ class PrinterOutputDevice(QObject, OutputDevice): def __del__(self): self.close() + @pyqtProperty(bool, notify=acceptsCommandsChanged) + def acceptsCommands(self): + return self._accepts_commands + + ## Set a flag to signal the UI that the printer is not (yet) ready to receive commands + def setAcceptsCommands(self, accepts_commands): + if self._accepts_commands != accepts_commands: + self._accepts_commands = accepts_commands + + self.acceptsCommandsChanged.emit() + ## The current processing state of the backend. class ConnectionState(IntEnum): diff --git a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py index 7c76811fd2..67db519c9e 100644 --- a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py @@ -65,6 +65,15 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): self._compressing_gcode = False self._gcode = [] + self.authenticationStateChanged.connect(self._onAuthenticationStateChanged) + + def _onAuthenticationStateChanged(self): + # We only accept commands if we are authenticated. + if self._authentication_state == AuthState.Authenticated: + self.setAcceptsCommands(True) + else: + self.setAcceptsCommands(False) + def _setupMessages(self): self._authentication_requested_message = Message(i18n_catalog.i18nc("@info:status", "Access to the printer requested. Please approve the request on the printer"),