on 4a3183d help sign in
unity8/Panel/IndicatorRow.qml
91 lines 3.0 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
19import "../Components"
21Item {
22 id: indicatorRow
24 property QtObject currentItem : null
25 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
26 property alias row: row
27 property QtObject indicatorsModel: null
29 width: units.gu(40)
30 height: units.gu(3)
32 function setDefaultItem() {
33 // The leftmost indicator
34 setCurrentItem(0);
35 }
37 function setCurrentItem(index) {
38 if (currentItemIndex !== index) {
39 currentItem = rowRepeater.itemAt(index);
40 }
41 }
43 Row {
44 id: row
46 width: children.width
47 height: parent.height
48 anchors.right: parent.right
50 Repeater {
51 id: rowRepeater
52 objectName: "rowRepeater"
53 model: indicatorsModel ? indicatorsModel : undefined
55 Item {
56 id: itemWrapper
57 height: indicatorRow.height
58 width: childrenRect.width
60 property int ownIndex: index
61 property alias highlighted: indicatorItem.highlighted
62 property alias dimmed: indicatorItem.dimmed
64 IndicatorItem {
65 id: indicatorItem
66 height: parent.height
68 highlighted: indicatorRow.state != "initial" ? itemWrapper.ownIndex == indicatorRow.currentItemIndex : false
69 dimmed: indicatorRow.state != "initial" ? itemWrapper.ownIndex != indicatorRow.currentItemIndex : false
71 widgetSource: model.widgetSource
72 indicatorProperties : model.indicatorProperties
73 }
75 opacity: {
76 if (!indicatorItem.highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")) {
77 return 0.0;
78 } else {
79 return 1.0;
80 }
81 }
82 Behavior on opacity {
83 StandardAnimation {
84 // flow away from current index
85 duration: (rowRepeater.count - Math.abs(indicatorRow.currentItemIndex - index)) * (500/rowRepeater.count)
86 }
87 }
88 }
89 }
90 }