From a02486e85a71a4aa04cc4820dc649d62fef5041c Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 7 Mar 2018 17:15:56 +0100 Subject: [PATCH] Added status icon --- resources/qml/MachineSelection.qml | 40 ++++++++++++----------- resources/qml/Menus/PrinterStatusIcon.qml | 27 +++++++++++++++ resources/themes/cura-light/theme.json | 2 ++ 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 resources/qml/Menus/PrinterStatusIcon.qml diff --git a/resources/qml/MachineSelection.qml b/resources/qml/MachineSelection.qml index e40731f3ca..b266b0c839 100644 --- a/resources/qml/MachineSelection.qml +++ b/resources/qml/MachineSelection.qml @@ -10,35 +10,28 @@ import UM 1.2 as UM import Cura 1.0 as Cura import "Menus" -ToolButton -{ +ToolButton { + property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 text: Cura.MachineManager.activeMachineName tooltip: Cura.MachineManager.activeMachineName - style: ButtonStyle - { - background: Rectangle - { - color: - { - if(control.pressed) - { + style: ButtonStyle { + background: Rectangle { + color: { + if (control.pressed) { return UM.Theme.getColor("sidebar_header_active"); } - else if(control.hovered) - { + else if (control.hovered) { return UM.Theme.getColor("sidebar_header_hover"); } - else - { + else { return UM.Theme.getColor("sidebar_header_bar"); } } Behavior on color { ColorAnimation { duration: 50; } } - UM.RecolorImage - { + UM.RecolorImage { id: downArrow anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right @@ -50,14 +43,23 @@ ToolButton color: UM.Theme.getColor("text_emphasis") source: UM.Theme.getIcon("arrow_bottom") } - Label - { + + PrinterStatusIcon { + visible: printerConnected + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + } + } + + Label { id: sidebarComboBoxLabel color: UM.Theme.getColor("sidebar_header_text_active") text: control.text; elide: Text.ElideRight; anchors.left: parent.left; - anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2 + anchors.leftMargin: printerConnected ? 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 new file mode 100644 index 0000000000..a8c465dba8 --- /dev/null +++ b/resources/qml/Menus/PrinterStatusIcon.qml @@ -0,0 +1,27 @@ +// Copyright (c) 2017 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Layouts 1.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +Item { + property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 + width: childrenRect.width + height: childrenRect.height + Image { + id: statusIcon + width: UM.Theme.getSize("status_icon").width + height: UM.Theme.getSize("status_icon").height + sourceSize.width: width + sourceSize.height: width + source: printerConnected ? UM.Theme.getIcon("tab_status_connected") : UM.Theme.getIcon("tab_status_busy") + } +} + + + diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index d97970e566..7c5d7bddec 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -360,6 +360,8 @@ "small_button": [2, 2], "small_button_icon": [1.5, 1.5], + "status_icon": [1.0, 1.0], + "topbar_logo_right_margin": [3, 0], "topbar_button": [8, 4], "topbar_button_icon": [1.2, 1.2],