Browse Source

Disable print monitor if the printer is not (yet) ready to receive commands

CURA-1851
fieldOfView 8 years ago
parent
commit
ed669925ad

+ 13 - 0
cura/PrinterOutputDevice.py

@@ -36,6 +36,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
         self._job_state = ""
         self._job_name = ""
         self._error_text = ""
+        self._accepts_commands = True
 
     def requestWrite(self, node, file_name = None, filter_by_machine = False):
         raise NotImplementedError("requestWrite needs to be implemented")
@@ -80,6 +81,8 @@ class PrinterOutputDevice(QObject, OutputDevice):
 
     errorTextChanged = pyqtSignal()
 
+    acceptsCommandsChanged = pyqtSignal()
+
     @pyqtProperty(str, notify = jobStateChanged)
     def jobState(self):
         return self._job_state
@@ -115,6 +118,16 @@ class PrinterOutputDevice(QObject, OutputDevice):
             self._error_text = error_text
             self.errorTextChanged.emit()
 
+    @pyqtProperty(str, 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()
+
     ##  Get the bed temperature of the bed (if any)
     #   This function is "final" (do not re-implement)
     #   /sa _getBedTemperature implementation function

+ 4 - 2
resources/qml/MonitorButton.qml

@@ -126,7 +126,8 @@ Rectangle
         id: abortButton
 
         visible: printerConnected
-        enabled: printerConnected && (Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing")
+        enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
+                 (Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing")
 
         height: UM.Theme.getSize("save_button_save_to_button").height
         anchors.top: progressBar.bottom
@@ -173,7 +174,8 @@ Rectangle
         id: pauseButton
 
         visible: printerConnected
-        enabled: printerConnected && (Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing")
+        enabled: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands &&
+                 (Cura.MachineManager.printerOutputDevices[0].jobState == "paused" || Cura.MachineManager.printerOutputDevices[0].jobState == "printing")
 
         height: UM.Theme.getSize("save_button_save_to_button").height
         anchors.top: progressBar.bottom

+ 2 - 2
resources/qml/PrintMonitor.qml

@@ -73,7 +73,7 @@ Column
             Label
             {
                 text: label
-                color: printerConnected ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
+                color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
                 font: UM.Theme.getFont("default")
                 width: base.width * 0.4
                 elide: Text.ElideRight
@@ -82,7 +82,7 @@ Column
             Label
             {
                 text: value
-                color: printerConnected ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
+                color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
                 font: UM.Theme.getFont("default")
                 anchors.verticalCenter: parent.verticalCenter
             }

+ 1 - 0
resources/qml/Sidebar.qml

@@ -28,6 +28,7 @@ Rectangle
 
     // Is there an output device for this printer?
     property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
+    property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
 
     color: UM.Theme.getColor("sidebar");
     UM.I18nCatalog { id: catalog; name:"cura"}