on 4e77f91 help sign in
unity8/qml/Panel/Indicators/DefaultIndicatorWidget.qml
118 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 anchors {
67 top: parent.top
68 bottom: parent.bottom
69 }
71 Repeater {
72 model: indicatorWidget.icons
74 Item {
75 width: itemImage.width + units.gu(1)
76 anchors { top: parent.top; bottom: parent.bottom }
78 StatusIcon {
79 id: itemImage
80 height: indicatorWidget.iconSize
81 anchors.centerIn: parent
82 source: modelData
83 sets: ["status", "actions"]
84 color: "#CCCCCC"
85 }
86 }
87 }
88 }
90 Label {
91 id: itemRightLabel
92 width: contentWidth + units.gu(1)
93 objectName: "rightLabel"
94 color: Theme.palette.selected.backgroundText
95 opacity: 0.8
96 font.family: "Ubuntu"
97 fontSize: "medium"
98 anchors.verticalCenter: parent.verticalCenter
99 visible: text != ""
100 horizontalAlignment: Text.AlignHCenter
101 }
102 }
104 onRootActionStateChanged: {
105 if (rootActionState == undefined) {
106 leftLabel = "";
107 rightLabel = "";
108 icons = undefined;
109 enabled = false;
110 return;
111 }
113 leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
114 rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
115 icons = rootActionState.icons;
116 enabled = rootActionState.visible;
117 }