on b66fdc2 help sign in
unity8/Panel/Indicators/DefaultIndicatorWidget.qml
103 lines 3.1 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
20import QtQuick 2.0
21import Ubuntu.Components 0.1
22import Unity.Indicators 0.1 as Indicators
24Indicators.IndicatorWidget {
25 id: indicatorWidget
27 width: itemRow.width + units.gu(0.5)
29 property alias leftLabel: itemLeftLabel.text
30 property alias rightLabel: itemRightLabel.text
31 property var icons: undefined
33 Row {
34 id: itemRow
35 objectName: "itemRow"
36 anchors {
37 top: parent.top
38 bottom: parent.bottom
39 horizontalCenter: parent.horizontalCenter
40 }
41 spacing: units.gu(0.5)
43 Label {
44 id: itemLeftLabel
45 objectName: "leftLabel"
46 color: Theme.palette.selected.backgroundText
47 opacity: 0.8
48 font.family: "Ubuntu"
49 fontSize: "medium"
50 anchors.verticalCenter: parent.verticalCenter
51 visible: text != ""
52 }
54 Row {
55 width: childrenRect.width
56 anchors {
57 top: parent.top
58 bottom: parent.bottom
59 }
60 spacing: units.gu(0.5)
62 Repeater {
63 model: indicatorWidget.icons
65 Image {
66 id: itemImage
67 objectName: "itemImage"
68 visible: source != ""
69 source: modelData
70 height: indicatorWidget.iconSize
71 width: indicatorWidget.iconSize
72 anchors.verticalCenter: parent.verticalCenter
73 }
74 }
75 }
77 Label {
78 id: itemRightLabel
79 objectName: "rightLabel"
80 color: Theme.palette.selected.backgroundText
81 opacity: 0.8
82 font.family: "Ubuntu"
83 fontSize: "medium"
84 anchors.verticalCenter: parent.verticalCenter
85 visible: text != ""
86 }
87 }
89 onRootActionStateChanged: {
90 if (rootActionState == undefined) {
91 leftLabel = "";
92 rightLabel = "";
93 icons = undefined;
94 enabled = false;
95 return;
96 }
98 leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
99 rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
100 icons = rootActionState.icons;
101 enabled = rootActionState.visible;
102 }