From e551898e0475d74899dee1d785934e645cbe3bdc Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 9 Aug 2016 18:43:09 +0200 Subject: [PATCH] Add a connection string to the printmonitor CURA-2091 --- cura/PrinterOutputDevice.py | 13 ++++++++++++ plugins/USBPrinting/USBPrinterOutputDevice.py | 1 + resources/qml/PrintMonitor.qml | 20 ++++++++++++++----- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cura/PrinterOutputDevice.py b/cura/PrinterOutputDevice.py index 153e5f7c42..b24fe11f18 100644 --- a/cura/PrinterOutputDevice.py +++ b/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() diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 2868e85bcb..b49e2acfe1 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/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 diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 434cb50b3a..6460634d8d 100644 --- a/resources/qml/PrintMonitor.qml +++ b/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