mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Added property to indicate if output device accepts commands
Instead of how this was previously done, it's now tied to the auth state. CL-541
This commit is contained in:
parent
0b91112d72
commit
1c2c4d4163
3 changed files with 25 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue