on 3f5d08f help sign in
unity8/Panel/IndicatorRow.qml
106 lines 3.7 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
27 property bool overviewActive: false // "state of the menu"
29 Behavior on y {NumberAnimation {duration: 300; easing.type: Easing.OutCubic} }
31 width: units.gu(40)
32 height: units.gu(3)
34 Component.onCompleted: setDefaultItem()
36 function setDefaultItem() {
37 // The leftmost indicator
38 var defaultItemIndex = 0
39 setItem(defaultItemIndex)
40 }
42 function setItem(index) {
43 currentItem = rowRepeater.itemAt(index)
44 }
46 Row {
47 id: row
49 width: children.width
50 height: parent.height
51 anchors.right: parent.right
53 Repeater {
54 id: rowRepeater
55 objectName: "rowRepeater"
56 model: indicatorsModel ? indicatorsModel : undefined
58 IndicatorItem {
59 id: indicatorItem
61 property int ownIndex: index
63 widgetSource: model.widgetSource
65 indicatorProperties : model.indicatorProperties
66 highlighted: indicatorRow.state == "reveal" || indicatorRow.state == "locked" || indicatorRow.state == "commit" ? ownIndex == indicatorRow.currentItemIndex : false
67 dimmed: { //See FIXME in Indicators regarding the "states" change
68 if (indicatorRow.state == "initial" || indicatorRow.state == "") {
69 return false;
70 } else if (indicatorRow.state == "hint") {
71 return true
72 } else {
73 return ownIndex != indicatorRow.currentItemIndex
74 }
75 }
76 height: indicatorRow.height
77 y: {
78 //FIXME: all indicators will be initial for now.
79 if (!highlighted && !overviewActive && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
80 return -indicatorRow.height
81 } else {
82 return 0
83 }
84 }
85 Behavior on y {
86 NumberAnimation{
87 duration: {
88 if (index == 0) {
89 return 250
90 } else if (index == 1) {
91 return 150
92 } else if (index == 2) {
93 return 550
94 } else if (index == 3) {
95 return 400
96 } else {
97 return 100 + Math.random() * 200
98 }
99 }
100 easing.type: Easing.OutCubic
101 }
102 }
103 }
104 }
105 }