From 67dc415b58eec45b497b3cd29eedee538514ec0a Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 23 Nov 2018 10:46:55 +0100 Subject: [PATCH] Add the connected icon to the printer selector that shows a blue icon when the printer is connected. If not connected then there is no icon. Contributes to CURA-5942. --- .../qml/PrinterSelector/MachineSelector.qml | 36 +++++++++++++++++-- .../themes/cura-light/icons/connected.svg | 5 --- .../themes/cura-light/icons/disconnected.svg | 6 ---- resources/themes/cura-light/theme.json | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) delete mode 100644 resources/themes/cura-light/icons/connected.svg delete mode 100644 resources/themes/cura-light/icons/disconnected.svg diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index d10478227a..a33c54ed88 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -14,6 +14,7 @@ Cura.ExpandableComponent id: machineSelector property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != "" + property bool isPrinterConnected: Cura.MachineManager.printerConnected property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null popupPadding: 0 @@ -31,9 +32,9 @@ Cura.ExpandableComponent text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName source: { - if (isNetworkPrinter && machineSelector.outputDevice != null) + if (isNetworkPrinter) { - if (machineSelector.outputDevice.clusterSize > 1) + if (machineSelector.outputDevice != null && machineSelector.outputDevice.clusterSize > 1) { return UM.Theme.getIcon("printer_group") } @@ -44,6 +45,37 @@ Cura.ExpandableComponent font: UM.Theme.getFont("medium") color: UM.Theme.getColor("text") iconSize: UM.Theme.getSize("machine_selector_icon").width + + UM.RecolorImage + { + id: icon + + anchors.bottom: parent.bottom + x: UM.Theme.getSize("thick_margin").width + + source: UM.Theme.getIcon("printer_connected") + width: UM.Theme.getSize("printer_status_icon").width + height: UM.Theme.getSize("printer_status_icon").height + + sourceSize.width: width + sourceSize.height: height + + color: UM.Theme.getColor("primary") + visible: isNetworkPrinter && isPrinterConnected + + // Make a themable circle in the background so we can change it in other themes + Rectangle + { + id: iconBackground + anchors.centerIn: parent + // Make it a bit bigger so there is an outline + width: parent.width + 2 + height: parent.height + 2 + radius: Math.round(width / 2) + color: UM.Theme.getColor("main_background") + z: parent.z - 1 + } + } } popupItem: Item diff --git a/resources/themes/cura-light/icons/connected.svg b/resources/themes/cura-light/icons/connected.svg deleted file mode 100644 index 18423bb6c4..0000000000 --- a/resources/themes/cura-light/icons/connected.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/resources/themes/cura-light/icons/disconnected.svg b/resources/themes/cura-light/icons/disconnected.svg deleted file mode 100644 index 019dff117e..0000000000 --- a/resources/themes/cura-light/icons/disconnected.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 8f110db65d..23b1ffcada 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -449,7 +449,7 @@ "favorites_button": [2, 2], "favorites_button_icon": [1.2, 1.2], - "printer_status_icon": [1.8, 1.8], + "printer_status_icon": [1.0, 1.0], "printer_sync_icon": [1.2, 1.2], "button_tooltip": [1.0, 1.3],