@@ -0,0 +1,252 @@
2+ * Copyright 2013 Canonical Ltd.
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.
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.
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/>.
17+ * Nick Dedekind <nick.dedekind@canonical.com>
21+import Ubuntu.Components 0.1
22+import Ubuntu.Settings.Components 0.1
23+import "../Indicators"
28+ property alias title: indicatorName.text
29+ property alias leftLabel: itemLeftLabel.text
30+ property alias rightLabel: itemRightLabel.text
31+ property var icons: undefined
32+ property bool expanded: false
33+ property bool selected: false
37+ width: mainItems.width
42+ onClicked: parent.clicked()
45+ // FIXME: For now we will enable led indicator support only for messaging indicator
46+ // in the future we should export a led API insted of doing that,
49+ // only load source Component if the icons contains the new message icon
50+ source: (root.icons && (String(root.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("IndicatorsLight.qml") : ""
55+ anchors.centerIn: parent
57+ width: itemLeftLabel.width + iconsItem.width + itemRightLabel.width
58+ implicitHeight: units.gu(2)
64+ verticalCenter: parent.verticalCenter
66+ width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
67+ horizontalAlignment: Text.AlignHCenter
69+ objectName: "leftLabel"
71+ font.family: "Ubuntu"
74+ if (!expanded) return Theme.palette.normal.foregroundText;
75+ if (!selected) return Theme.palette.selected.backgroundText;
76+ return Theme.palette.normal.foregroundText;
78+ Behavior on color { ColorAnimation{ duration: UbuntuAnimation.SnapDuration } }
83+ width: iconRow.width > 0 ? iconRow.width + units.gu(1) : 0
85+ left: itemLeftLabel.right
86+ verticalCenter: parent.verticalCenter
91+ anchors.centerIn: iconsItem
96+ model: d.useFallbackIcon ? [ "image://theme/settings" ] : root.icons
102+ sets: ["status", "actions"]
104+ if (!expanded) return Theme.palette.normal.foregroundText;
105+ if (!selected) return Theme.palette.selected.backgroundText;
106+ return Theme.palette.normal.foregroundText;
108+ Behavior on color { ColorAnimation{ duration: 1 } }
117+ left: iconsItem.right
118+ verticalCenter: parent.verticalCenter
120+ width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
121+ horizontalAlignment: Text.AlignHCenter
123+ objectName: "rightLabel"
125+ font.family: "Ubuntu"
128+ if (!expanded) return Theme.palette.normal.foregroundText;
129+ if (!selected) return Theme.palette.selected.backgroundText;
130+ return Theme.palette.normal.foregroundText;
132+ Behavior on color { ColorAnimation{ duration: UbuntuAnimation.SnapDuration } }
139+ anchors.top: mainItems.bottom
140+ anchors.topMargin: units.gu(0.5)
141+ anchors.horizontalCenter: parent.horizontalCenter
142+ width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
144+ text: rootActionState.title
146+ horizontalAlignment: Text.AlignHCenter
149+ if (!expanded) return Theme.palette.normal.foregroundText;
150+ if (!selected) return Theme.palette.selected.backgroundText;
151+ return Theme.palette.normal.foregroundText;
153+ Behavior on color { ColorAnimation{ duration: UbuntuAnimation.SnapDuration } }
158+ property bool useFallbackIcon: false
164+ when: !expanded && ((icons && icons.length > 0) || leftLabel !== "" || rightLabel !== "")
165+ PropertyChanges { target: indicatorName; opacity: 0}
169+ name: "minimised_fallback"
170+ when: !expanded && (!icons || icons.length === 0) && leftLabel == "" && rightLabel == ""
171+ PropertyChanges { target: indicatorName; opacity: 0}
172+ PropertyChanges { target: d; useFallbackIcon: true }
176+ name: "expanded_icon"
177+ when: expanded && (icons && icons.length > 0)
178+ PropertyChanges { target: indicatorName; visible: true; opacity: 1}
179+ AnchorChanges { target: iconsItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
180+ AnchorChanges { target: itemLeftLabel; anchors.left: undefined; anchors.right: iconsItem.left }
181+ PropertyChanges { target: itemLeftLabel; opacity: 0 }
182+ PropertyChanges { target: mainItems; width: Math.max(iconsItem.width, indicatorName.width); anchors.verticalCenterOffset: -units.gu(1) }
183+ PropertyChanges { target: itemLeftLabel; opacity: 0 }
184+ PropertyChanges { target: itemRightLabel; opacity: 0 }
188+ name: "expanded_fallback"
189+ when: expanded && (!icons || icons.length === 0) && leftLabel == "" && rightLabel == ""
190+ PropertyChanges { target: d; useFallbackIcon: true }
191+ PropertyChanges { target: indicatorName; visible: true; opacity: 1}
192+ AnchorChanges { target: iconsItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
193+ AnchorChanges { target: itemLeftLabel; anchors.left: undefined; anchors.right: iconsItem.left }
194+ PropertyChanges { target: itemLeftLabel; opacity: 0 }
195+ PropertyChanges { target: mainItems; width: Math.max(iconsItem.width, indicatorName.width); anchors.verticalCenterOffset: -units.gu(1) }
196+ PropertyChanges { target: itemLeftLabel; opacity: 0 }
197+ PropertyChanges { target: itemRightLabel; opacity: 0 }
201+ name: "expanded_rightLabel"
202+ when: expanded && (!icons || icons.length === 0) && rightLabel !== ""
203+ PropertyChanges { target: indicatorName; visible: true; opacity: 1}
204+ AnchorChanges { target: itemRightLabel; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
205+ PropertyChanges { target: mainItems; width: Math.max(itemRightLabel.width, indicatorName.width); anchors.verticalCenterOffset: -units.gu(1) }
206+ PropertyChanges { target: iconsItem; opacity: 0 }
207+ PropertyChanges { target: itemLeftLabel; opacity: 0 }
211+ name: "expanded_leftLabel"
212+ when: expanded && (!icons || icons.length === 0) && leftLabel !== ""
213+ PropertyChanges { target: indicatorName; visible: true; opacity: 1}
214+ AnchorChanges { target: itemLeftLabel; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
215+ PropertyChanges { target: mainItems; width: Math.max(itemLeftLabel.width, indicatorName.width); anchors.verticalCenterOffset: -units.gu(1) }
216+ PropertyChanges { target: iconsItem; opacity: 0 }
217+ PropertyChanges { target: itemRightLabel; opacity: 0 }
223+ PropertyAction { target: d; property: "useFallbackIcon"}
225+ targets: [ mainItems, iconsItem, itemLeftLabel, itemRightLabel ]
226+ duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
229+ targets: [ mainItems, iconsItem, itemLeftLabel, itemRightLabel, indicatorName ]
230+ properties: "width, opacity, anchors.verticalCenterOffset";
231+ duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
237+ onRootActionStateChanged: {
238+ if (rootActionState == undefined) {
246+ title = rootActionState.title ? rootActionState.title : "";
247+ leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
248+ rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
249+ icons = rootActionState.icons;
250+ enabled = rootActionState.visible;