Browse Source

Add a connection string to the printmonitor

CURA-2091
fieldOfView 8 years ago
parent
commit
e551898e04

+ 13 - 0
cura/PrinterOutputDevice.py

@@ -31,6 +31,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
         self._head_y = 0
         self._head_z = 0
         self._connection_state = ConnectionState.closed
+        self._connection_text = ""
         self._time_elapsed = 0
         self._time_total = 0
         self._job_state = ""
@@ -71,6 +72,8 @@ class PrinterOutputDevice(QObject, OutputDevice):
     # it also sends it's own device_id (for convenience sake)
     connectionStateChanged = pyqtSignal(str)
 
+    connectionTextChanged = pyqtSignal()
+
     timeElapsedChanged = pyqtSignal()
 
     timeTotalChanged = pyqtSignal()
@@ -292,6 +295,16 @@ class PrinterOutputDevice(QObject, OutputDevice):
         self._connection_state = connection_state
         self.connectionStateChanged.emit(self._id)
 
+    @pyqtProperty(str, notify = connectionTextChanged)
+    def connectionText(self):
+        return self._connection_text
+
+    ##  Set a text that is shown on top of the print monitor tab
+    def setConnectionText(self, connection_text):
+        if self._connection_text != connection_text:
+            self._connection_text = connection_text
+            self.connectionTextChanged.emit()
+
     ##  Ensure that close gets called when object is destroyed
     def __del__(self):
         self.close()

+ 1 - 0
plugins/USBPrinting/USBPrinterOutputDevice.py

@@ -27,6 +27,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
         self.setShortDescription(catalog.i18nc("@action:button", "Print via USB"))
         self.setDescription(catalog.i18nc("@info:tooltip", "Print via USB"))
         self.setIconName("print")
+        self.setConnectionText(i18n_catalog.i18nc("@info:status", "Connected via USB"))
 
         self._serial = None
         self._serial_port = serial_port

+ 15 - 5
resources/qml/PrintMonitor.qml

@@ -12,6 +12,16 @@ import Cura 1.0 as Cura
 Column
 {
     id: printMonitor
+    property var connectedPrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0] : null
+
+    Label
+    {
+        text: printerConnected ? connectedPrinter.connectionText : catalog.i18nc("@label", "The printer is not connected.")
+        color: printerConnected && printerAcceptsCommands ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
+        font: UM.Theme.getFont("default")
+        wrapMode: Text.WordWrap
+        width: base.width
+    }
 
     Loader
     {
@@ -25,7 +35,7 @@ Column
         {
             sourceComponent: monitorItem
             property string label: machineExtruderCount.properties.value > 1 ? catalog.i18nc("@label", "Hotend Temperature %1").arg(index + 1) : catalog.i18nc("@label", "Hotend Temperature")
-            property string value: printerConnected ? Math.round(Cura.MachineManager.printerOutputDevices[0].hotendTemperatures[index]) + "°C" : ""
+            property string value: printerConnected ? Math.round(connectedPrinter.hotendTemperatures[index]) + "°C" : ""
         }
     }
     Repeater
@@ -35,7 +45,7 @@ Column
         {
             sourceComponent: monitorItem
             property string label: catalog.i18nc("@label", "Bed Temperature")
-            property string value: printerConnected ? Math.round(Cura.MachineManager.printerOutputDevices[0].bedTemperature) + "°C" : ""
+            property string value: printerConnected ? Math.round(connectedPrinter.bedTemperature) + "°C" : ""
         }
     }
 
@@ -48,19 +58,19 @@ Column
     {
         sourceComponent: monitorItem
         property string label: catalog.i18nc("@label", "Job Name")
-        property string value: printerConnected ? Cura.MachineManager.printerOutputDevices[0].jobName : ""
+        property string value: printerConnected ? connectedPrinter.jobName : ""
     }
     Loader
     {
         sourceComponent: monitorItem
         property string label: catalog.i18nc("@label", "Printing Time")
-        property string value: printerConnected ? getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal) : ""
+        property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal) : ""
     }
     Loader
     {
         sourceComponent: monitorItem
         property string label: catalog.i18nc("@label", "Estimated time left")
-        property string value: printerConnected ? getPrettyTime(Cura.MachineManager.printerOutputDevices[0].timeTotal - Cura.MachineManager.printerOutputDevices[0].timeElapsed) : ""
+        property string value: printerConnected ? getPrettyTime(connectedPrinter.timeTotal - connectedPrinter.timeElapsed) : ""
     }
 
     Component