From ffccdd99c03d74f060a49a608009f7e706876fa8 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 8 Mar 2018 10:55:29 +0100 Subject: [PATCH] Added status icon --- cura/Settings/MachineManager.py | 6 ++++++ resources/qml/MachineSelection.qml | 8 +++++--- resources/qml/Menus/PrinterStatusIcon.qml | 11 ++++++----- resources/themes/cura-light/theme.json | 11 +++++++++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index be30c83dda..7b9a4191ed 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -469,6 +469,12 @@ class MachineManager(QObject): return self._global_container_stack.getId() return "" + @pyqtProperty(str, notify = globalContainerChanged) + def activeMachineNetworkKey(self) -> str: + if self._global_container_stack: + return self._global_container_stack.getMetaDataEntry("um_network_key") + return "" + @pyqtProperty(QObject, notify = globalContainerChanged) def activeMachine(self) -> Optional["GlobalStack"]: return self._global_container_stack diff --git a/resources/qml/MachineSelection.qml b/resources/qml/MachineSelection.qml index b9d8840f2f..5ca6cda406 100644 --- a/resources/qml/MachineSelection.qml +++ b/resources/qml/MachineSelection.qml @@ -11,7 +11,8 @@ import Cura 1.0 as Cura import "Menus" ToolButton { - property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + property var isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey ? true : false + property var printerStatus: Cura.MachineManager.printerOutputDevices.length != 0 ? "connected" : "unknown" text: Cura.MachineManager.activeMachineName tooltip: Cura.MachineManager.activeMachineName @@ -45,7 +46,8 @@ ToolButton { } PrinterStatusIcon { - visible: printerConnected + visible: isNetworkPrinter + status: printerStatus anchors { verticalCenter: parent.verticalCenter left: parent.left @@ -59,7 +61,7 @@ ToolButton { text: control.text; elide: Text.ElideRight; anchors.left: parent.left; - anchors.leftMargin: printerConnected ? UM.Theme.getSize("default_margin").width * 3 : UM.Theme.getSize("default_margin").width * 2 + anchors.leftMargin: isNetworkPrinter ? UM.Theme.getSize("default_margin").width * 3 : UM.Theme.getSize("default_margin").width * 2 anchors.right: downArrow.left; anchors.rightMargin: control.rightMargin; anchors.verticalCenter: parent.verticalCenter; diff --git a/resources/qml/Menus/PrinterStatusIcon.qml b/resources/qml/Menus/PrinterStatusIcon.qml index a8c465dba8..d7106bf33d 100644 --- a/resources/qml/Menus/PrinterStatusIcon.qml +++ b/resources/qml/Menus/PrinterStatusIcon.qml @@ -10,16 +10,17 @@ import UM 1.2 as UM import Cura 1.0 as Cura Item { - property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + property var status: "unknown" width: childrenRect.width height: childrenRect.height - Image { + UM.RecolorImage { id: statusIcon - width: UM.Theme.getSize("status_icon").width - height: UM.Theme.getSize("status_icon").height + width: UM.Theme.getSize("printer_status_icon").width + height: UM.Theme.getSize("printer_status_icon").height sourceSize.width: width sourceSize.height: width - source: printerConnected ? UM.Theme.getIcon("tab_status_connected") : UM.Theme.getIcon("tab_status_busy") + color: UM.Theme.getColor("tab_status_" + parent.status ) + source: UM.Theme.getIcon("tab_status_" + parent.status ) } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 7c5d7bddec..1e3f9ce79a 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -307,7 +307,14 @@ "configuration_item_text_active": [0, 0, 0, 255], "configuration_item_border": [127, 127, 127, 255], "configuration_item_border_active": [12, 169, 227, 32], - "configuration_item_border_hover": [12, 169, 227, 255] + "configuration_item_border_hover": [12, 169, 227, 255], + + "tab_status_busy": [255, 255, 255, 255], + "tab_status_connected": [12, 169, 227, 255], + "tab_status_finished": [255, 255, 255, 255], + "tab_status_paused": [255, 255, 255, 255], + "tab_status_stopped": [255, 255, 255, 255], + "tab_status_unknown": [200, 200, 200, 255] }, "sizes": { @@ -360,7 +367,7 @@ "small_button": [2, 2], "small_button_icon": [1.5, 1.5], - "status_icon": [1.0, 1.0], + "printer_status_icon": [1.0, 1.0], "topbar_logo_right_margin": [3, 0], "topbar_button": [8, 4],