on 212a1db help sign in
unity8/Panel/IndicatorRow.qml
105 lines 3.6 kB history raw
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import Ubuntu.Components 0.1
20Item {
21 id: indicatorRow
23 property QtObject currentItem : null
24 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
25 property alias row: row
26 property QtObject indicatorsModel: null
28 Behavior on y {NumberAnimation {duration: 300; easing.type: Easing.OutCubic} }
30 width: units.gu(40)
31 height: units.gu(3)
33 Component.onCompleted: setDefaultItem()
35 function setDefaultItem() {
36 // The leftmost indicator
37 var defaultItemIndex = 0
38 setItem(defaultItemIndex)
39 }
41 function setItem(index) {
42 currentItem = rowRepeater.itemAt(index)
43 }
45 Row {
46 id: row
48 width: children.width
49 height: parent.height
50 anchors.right: parent.right
52 Repeater {
53 id: rowRepeater
54 objectName: "rowRepeater"
55 model: indicatorsModel ? indicatorsModel : undefined
57 IndicatorItem {
58 id: indicatorItem
60 property int ownIndex: index
62 widgetSource: model.widgetSource
64 indicatorProperties : model.indicatorProperties
65 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
66 dimmed: { //See FIXME in Indicators regarding the "states" change
67 if (indicatorRow.state == "initial" || indicatorRow.state == "") {
68 return false;
69 } else if (indicatorRow.state == "hint") {
70 return true
71 } else {
72 return ownIndex != indicatorRow.currentItemIndex
73 }
74 }
75 height: indicatorRow.height
76 y: {
77 //FIXME: all indicators will be initial for now.
78 if (!highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
79 return -indicatorRow.height
80 } else {
81 return 0
82 }
83 }
84 Behavior on y {
85 NumberAnimation{
86 duration: {
87 if (index == 0) {
88 return 250
89 } else if (index == 1) {
90 return 150
91 } else if (index == 2) {
92 return 550
93 } else if (index == 3) {
94 return 400
95 } else {
96 return 100 + Math.random() * 200
97 }
98 }
99 easing.type: Easing.OutCubic
100 }
101 }
102 }
103 }
104 }