on b60e2fc help sign in
unity8/qml/Panel/Indicators/DefaultIndicatorWidget.qml
119 lines 3.8 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 Ubuntu.Settings.Components 0.1
24IndicatorBase {
25 id: indicatorWidget
27 property int iconSize: units.gu(2)
28 property alias leftLabel: itemLeftLabel.text
29 property alias rightLabel: itemRightLabel.text
30 property var icons: undefined
32 width: itemRow.width
33 enabled: false
35 // FIXME: For now we will enable led indicator support only for messaging indicator
36 // in the future we should export a led API insted of doing that,
37 Loader {
38 id: indicatorLed
39 // only load source Component if the icons contains the new message icon
40 source: (indicatorWidget.icons && (String(indicatorWidget.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("IndicatorsLight.qml") : ""
41 }
43 Row {
44 id: itemRow
45 objectName: "itemRow"
46 anchors {
47 top: parent.top
48 bottom: parent.bottom
49 horizontalCenter: parent.horizontalCenter
50 }
52 Label {
53 id: itemLeftLabel
54 width: contentWidth + units.gu(1)
55 objectName: "leftLabel"
56 color: Theme.palette.selected.backgroundText
57 opacity: 0.8
58 font.family: "Ubuntu"
59 fontSize: "medium"
60 anchors.verticalCenter: parent.verticalCenter
61 visible: text != ""
62 horizontalAlignment: Text.AlignHCenter
63 }
65 Row {
66 id: iconRow
67 anchors {
68 top: parent.top
69 bottom: parent.bottom
70 }
72 Repeater {
73 model: indicatorWidget.icons
75 Item {
76 width: itemImage.width + units.gu(1)
77 height: iconRow.height
79 StatusIcon {
80 id: itemImage
81 height: indicatorWidget.iconSize
82 anchors.centerIn: parent
83 source: modelData
84 sets: ["status", "actions"]
85 color: "#CCCCCC"
86 }
87 }
88 }
89 }
91 Label {
92 id: itemRightLabel
93 width: contentWidth + units.gu(1)
94 objectName: "rightLabel"
95 color: Theme.palette.selected.backgroundText
96 opacity: 0.8
97 font.family: "Ubuntu"
98 fontSize: "medium"
99 anchors.verticalCenter: parent.verticalCenter
100 visible: text != ""
101 horizontalAlignment: Text.AlignHCenter
102 }
103 }
105 onRootActionStateChanged: {
106 if (rootActionState == undefined) {
107 leftLabel = "";
108 rightLabel = "";
109 icons = undefined;
110 enabled = false;
111 return;
112 }
114 leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
115 rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
116 icons = rootActionState.icons;
117 enabled = rootActionState.visible;
118 }