2
* Copyright 2013-2014 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/>.
18
import Ubuntu.Components 1.1
19
import Ubuntu.Settings.Components 0.1
25
property string identifier
26
property string title: indicatorName.text
27
property alias leftLabel: leftLabelItem.text
28
property alias rightLabel: rightLabelItem.text
29
property var icons: undefined
30
property bool expanded: false
31
property bool selected: false
32
property real iconHeight: units.gu(2)
33
readonly property color color: {
34
if (!expanded) return "#ededed";
35
if (!selected) return "#4c4c4c";
41
implicitWidth: mainItems.width
45
onClicked: parent.clicked()
48
// FIXME: For now we will enable led indicator support only for messaging indicator
49
// in the future we should export a led API insted of doing that,
52
// only load source Component if the icons contains the new message icon
53
source: (root.icons && (String(root.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("Indicators/IndicatorsLight.qml") : ""
58
anchors.centerIn: parent
60
width: leftLabelItem.width + iconsItem.width + rightLabelItem.width
61
implicitHeight: units.gu(2)
65
objectName: "leftLabel"
69
verticalCenter: parent.verticalCenter
71
width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
72
horizontalAlignment: Text.AlignHCenter
78
Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
85
width: iconRow.width > 0 ? iconRow.width + units.gu(1) : 0
87
left: leftLabelItem.right
88
verticalCenter: parent.verticalCenter
93
anchors.centerIn: iconsItem
98
objectName: "iconRepeater"
100
model: d.useFallbackIcon ? [ "image://theme/settings" ] : root.icons
104
objectName: "icon"+index
107
sets: ["status", "actions"]
109
Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
112
if (!expanded) return 1.0;
113
if (!selected) return 0.6;
116
Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
124
objectName: "rightLabel"
127
left: iconsItem.right
128
verticalCenter: parent.verticalCenter
130
width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
131
horizontalAlignment: Text.AlignHCenter
134
font.family: "Ubuntu"
137
Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
143
objectName: "indicatorName"
145
anchors.top: mainItems.bottom
146
anchors.topMargin: units.gu(0.5)
147
anchors.horizontalCenter: parent.horizontalCenter
148
width: contentWidth > 0 ? contentWidth + units.gu(1) : 0
150
text: title !== "" ? title : identifier
152
horizontalAlignment: Text.AlignHCenter
155
Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
160
property bool useFallbackIcon: false
165
when: !expanded && ((icons && icons.length > 0) || leftLabel !== "" || rightLabel !== "")
166
PropertyChanges { target: indicatorName; opacity: 0}
170
name: "minimised_fallback"
171
when: !expanded && (!icons || icons.length === 0) && leftLabel == "" && rightLabel == ""
172
PropertyChanges { target: indicatorName; opacity: 0}
173
PropertyChanges { target: d; useFallbackIcon: true }
178
PropertyChanges { target: indicatorName; visible: true; opacity: 1}
179
PropertyChanges { target: mainItems; anchors.verticalCenterOffset: -units.gu(1) }
183
name: "expanded_icon"
185
when: expanded && (icons && icons.length > 0)
186
AnchorChanges { target: iconsItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
187
AnchorChanges { target: leftLabelItem; anchors.left: undefined; anchors.right: iconsItem.left }
188
PropertyChanges { target: leftLabelItem; opacity: 0 }
189
PropertyChanges { target: leftLabelItem; opacity: 0 }
190
PropertyChanges { target: rightLabelItem; opacity: 0 }
191
PropertyChanges { target: root; width: Math.max(units.gu(10), Math.max(iconsItem.width, indicatorName.width)) }
195
name: "expanded_fallback"
197
when: expanded && (!icons || icons.length === 0) && leftLabel == "" && rightLabel == ""
198
PropertyChanges { target: d; useFallbackIcon: true }
199
AnchorChanges { target: iconsItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
200
AnchorChanges { target: leftLabelItem; anchors.left: undefined; anchors.right: iconsItem.left }
201
PropertyChanges { target: leftLabelItem; opacity: 0 }
202
PropertyChanges { target: leftLabelItem; opacity: 0 }
203
PropertyChanges { target: rightLabelItem; opacity: 0 }
204
PropertyChanges { target: root; width: Math.max(units.gu(10), Math.max(iconsItem.width, indicatorName.width)) }
208
name: "expanded_rightLabel"
210
when: expanded && (!icons || icons.length === 0) && rightLabel !== ""
211
AnchorChanges { target: rightLabelItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
212
PropertyChanges { target: iconsItem; opacity: 0 }
213
PropertyChanges { target: leftLabelItem; opacity: 0 }
214
PropertyChanges { target: root; width: Math.max(units.gu(10), Math.max(rightLabelItem.width, indicatorName.width)) }
218
name: "expanded_leftLabel"
220
when: expanded && (!icons || icons.length === 0) && leftLabel !== ""
221
AnchorChanges { target: leftLabelItem; anchors.left: undefined; anchors.horizontalCenter: parent.horizontalCenter }
222
PropertyChanges { target: iconsItem; opacity: 0 }
223
PropertyChanges { target: rightLabelItem; opacity: 0 }
224
PropertyChanges { target: root; width: Math.max(units.gu(10), Math.max(leftLabelItem.width, indicatorName.width)) }
230
PropertyAction { target: d; property: "useFallbackIcon" }
232
targets: [ mainItems, iconsItem, leftLabelItem, rightLabelItem ]
233
duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
236
targets: [ root, mainItems, iconsItem, leftLabelItem, rightLabelItem, indicatorName ]
237
properties: "width, opacity, anchors.verticalCenterOffset";
238
duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
244
onRootActionStateChanged: {
245
if (rootActionState == undefined) {
253
title = rootActionState.title ? rootActionState.title : "";
254
leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
255
rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
256
icons = rootActionState.icons;