on xenial help sign in
Added Panel/VisibleIndicatorsModel for use with both indicator row & menuContent.
9dcab01Nick Dedekind
qml/Panel/IndicatorItem.qml+1−1
@@ -29,7 +29,7 @@ Item {
29 property string identifier
29 property string identifier
30
30
31 opacity: dimmed ? 0.4 : 1
31 opacity: dimmed ? 0.4 : 1
32− Behavior on opacity { StandardAnimation {} }
32+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
33
33
34 width: loader.item ? loader.item.width : 0
34 width: loader.item ? loader.item.width : 0
35
35
qml/Panel/IndicatorRow.qml+73−113
@@ -22,11 +22,10 @@ import "../Components"
22Item {
22Item {
23 id: indicatorRow
23 id: indicatorRow
24
24
25− property QtObject currentItem : null
25+ readonly property alias currentItem : itemView.currentItem
26− readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
26+ readonly property alias currentItemIndex: itemView.currentIndex
27− property alias row: row
27+ readonly property alias row: itemView
28 property QtObject indicatorsModel: null
28 property QtObject indicatorsModel: null
29− property var visibleIndicators: undefined
30 property int overFlowWidth: width
29 property int overFlowWidth: width
31 property bool showAll: false
30 property bool showAll: false
32 property real currentItemOffset: 0.0
31 property real currentItemOffset: 0.0
@@ -40,9 +39,15 @@ Item {
40 setCurrentItem(0);
39 setCurrentItem(0);
41 }
40 }
42
41
42+ function setCurrentItemIndex(index) {
43+ itemView.currentIndex = index;
44+ }
45+
43− function setCurrentItem(index) {
46+ function setCurrentItem(item) {
44− if (currentItemIndex !== index) {
47+ if (item && item.hasOwnProperty("ownIndex")) {
45− currentItem = rowRepeater.itemAt(index);
48+ itemView.currentIndex = item.ownIndex;
49+ } else {
50+ itemView.currentIndex = -1;
46 }
51 }
47 }
52 }
48
53
@@ -55,122 +60,75 @@ Item {
55 }
60 }
56 }
61 }
57
62
58− Row {
63+ ListView {
59− id: row
64+ id: itemView
65+ objectName: "indicatorRowItems"
66+ interactive: false
67+ model: indicatorsModel ? indicatorsModel : null
60
68
61− width: children.width
69+ width: childrenRect.width
62− height: parent.height
70+ height: indicatorRow.height
63 anchors.right: parent.right
71 anchors.right: parent.right
72+ orientation: ListView.Horizontal
64
73
65− Repeater {
74+ property int lastCount: 0
66− id: rowRepeater
75+ onCountChanged: {
67− objectName: "rowRepeater"
76+ if (lastCount < count) {
68− model: indicatorsModel ? indicatorsModel : undefined
77+ showAll = true;
78+ allVisible.start();
79+ }
80+ lastCount = count;
81+ }
69
82
83+ delegate: Item {
84+ id: itemWrapper
85+ objectName: "item" + index
86+ height: indicatorRow.height
87+ width: indicatorItem.width
88+ opacity: 1 - indicatorRow.unitProgress
89+ y: 0
90+ state: "standard"
91+
70− property int lastCount: 0
92+ property int ownIndex: index
71− onCountChanged: {
93+ property bool highlighted: indicatorRow.unitProgress > 0 ? ListView.isCurrentItem : false
72− if (lastCount < count) {
94+ property bool dimmed: indicatorRow.unitProgress > 0 ? !ListView.isCurrentItem : false
73− showAll = true;
95+
74− allVisible.start();
96+ property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
75− }
97+ property bool overflow: row.width - itemWrapper.x > overFlowWidth
76− lastCount = count;
98+
99+ IndicatorItem {
100+ id: indicatorItem
101+ identifier: model.identifier
102+ height: parent.height
103+
104+ dimmed: itemWrapper.dimmed
105+
106+ widgetSource: model.widgetSource
107+ indicatorProperties : model.indicatorProperties
77 }
108 }
78
109
79− Item {
110+ states: [
80− id: itemWrapper
111+ State {
81− height: indicatorRow.height
82− width: indicatorItem.width
83− visible: indicatorItem.indicatorVisible
84− opacity: 1.0 * opacityMultiplier
85− y: 0
86− state: "standard"
112+ name: "standard"
87−
113+ when: !hidden && !overflow && !highlighted
88− property int ownIndex: index
114+ },
89− property bool highlighted: indicatorRow.state != "initial" ? ownIndex == indicatorRow.currentItemIndex : false
115+ State {
90− property bool dimmed: indicatorRow.state != "initial" ? ownIndex != indicatorRow.currentItemIndex : false
116+ name: "highlighted"
91−
117+ when: highlighted
92− property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
118+ PropertyChanges { target: itemWrapper; opacity: 1.0 }
93− property bool overflow: row.width - itemWrapper.x > overFlowWidth
119+ },
94− property real opacityMultiplier: highlighted ? 1 : (1 - indicatorRow.unitProgress)
120+ State {
95−
121+ name: "hidden"
96− IndicatorItem {
122+ when: hidden || overflow
97− id: indicatorItem
123+ PropertyChanges { target: itemWrapper; opacity: 0.0 }
98− identifier: model.identifier
99− height: parent.height
100−
101− dimmed: itemWrapper.dimmed
102−
103− widgetSource: model.widgetSource
104− indicatorProperties : model.indicatorProperties
105−
106− Component.onCompleted: {
107− updateVisiblility();
108− }
109− onIndicatorVisibleChanged: {
110− updateVisiblility();
111−
112− if (indicatorVisible) {
113− showAll = true;
114− allVisible.start();
115− }
116− }
117−
118− function updateVisiblility() {
119− if (visibleIndicators == undefined) {
120− visibleIndicators = {}
121− }
122− indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
123−
124− // removed current index?
125− if (indicatorRow.currentItemIndex === index && !indicatorVisible) {
126− // find the next closest visible indicator (after current, else before)
127− var newIndex = -1;
128− for (var i = index+1; i < rowRepeater.count; i++) {
129− if (indicatorRow.visibleIndicators[i] === undefined || indicatorRow.visibleIndicators[model.identifier]) {
130− newIndex = i;
131− break;
132− }
133− }
134− if (newIndex === -1) {
135− for (i = index - 1; i >= 0; i--) {
136− if (indicatorRow.visibleIndicators[i] === undefined || indicatorRow.visibleIndicators[model.identifier]) {
137− newIndex = i;
138− break;
139− }
140− }
141− }
142− indicatorRow.setCurrentItem(newIndex);
143− }
144−
145− indicatorRow.visibleIndicatorsChanged();
146− }
147 }
124 }
125+ ]
148
126
149− states: [
150− State {
151− name: "standard"
152− when: !hidden && !overflow
153− },
154− State {
155− name: "overflow"
156− when: hidden || overflow
157− PropertyChanges { target: itemWrapper; opacity: 0.0 }
158− }
159− ]
160−
161− transitions: [
162− Transition {
163− UbuntuNumberAnimation {
164− target: itemWrapper
165− property: "opacity"
166− duration: UbuntuAnimation.BriskDuration
127+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
167− }
168− }
169− ]
170− }
171 }
128 }
172 }
129 }
173
130
131+
174 Rectangle {
132 Rectangle {
175 id: highlight
133 id: highlight
176 color: Theme.palette.selected.foreground
134 color: Theme.palette.selected.foreground
@@ -178,7 +136,9 @@ Item {
178 height: units.dp(2)
136 height: units.dp(2)
179 anchors.top: row.bottom
137 anchors.top: row.bottom
180 visible: indicatorRow.currentItem != null
138 visible: indicatorRow.currentItem != null
139+
181− x: row.x + (indicatorRow.currentItem != null ? indicatorRow.currentItem.x + centerOffset : 0)
140+ property real intendedX: row.x + (indicatorRow.currentItem != null ? indicatorRow.currentItem.x + centerOffset : 0)
141+ x: intendedX >= row.x ? (intendedX + width <= row.x + row.width ? intendedX : row.x + row.width - width) : row.x // listview boundaries
182 width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
142 width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
183
143
184 property real centerOffset: {
144 property real centerOffset: {
qml/Panel/Indicators.qml+18−28
@@ -21,6 +21,7 @@ import Unity.Indicators 0.1 as Indicators
21
21
22import "../Components"
22import "../Components"
23import "../Components/ListItems"
23import "../Components/ListItems"
24+import "Indicators"
24
25
25Showable {
26Showable {
26 id: indicators
27 id: indicators
@@ -31,7 +32,7 @@ Showable {
31 property alias overFlowWidth: indicatorRow.overFlowWidth
32 property alias overFlowWidth: indicatorRow.overFlowWidth
32 property alias showAll: indicatorRow.showAll
33 property alias showAll: indicatorRow.showAll
33
34
34− property int hintValue
35+ readonly property real hintValue: panelHeight + menuContent.headerHeight
35 readonly property int lockThreshold: openedHeight / 2
36 readonly property int lockThreshold: openedHeight / 2
36 property bool fullyOpened: height == openedHeight
37 property bool fullyOpened: height == openedHeight
37 property bool partiallyOpened: height > panelHeight && !fullyOpened
38 property bool partiallyOpened: height > panelHeight && !fullyOpened
@@ -39,7 +40,7 @@ Showable {
39 property bool contentEnabled: true
40 property bool contentEnabled: true
40 property bool initalizeItem: true
41 property bool initalizeItem: true
41 readonly property alias content: menuContent
42 readonly property alias content: menuContent
42− property real unitProgress: 0.0
43+ property real unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
43
44
44 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
45 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
45 // use its own values. Need to ask design about this.
46 // use its own values. Need to ask design about this.
@@ -128,7 +129,7 @@ Showable {
128
129
129 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
130 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
130 // get the current delegate
131 // get the current delegate
131− currentItem = indicatorRow.row.childAt(rowCoordinates.x, 0);
132+ currentItem = indicatorRow.row.itemAt(rowCoordinates.x, 0);
132 if (currentItem) {
133 if (currentItem) {
133 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
134 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
134 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
135 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
@@ -143,7 +144,7 @@ Showable {
143 }
144 }
144 }
145 }
145 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
146 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
146− indicatorRow.currentItem = currentItem;
147+ indicatorRow.setCurrentItem(currentItem);
147 }
148 }
148
149
149 // need to re-init the distanceFromRightEdge for offset calculation
150 // need to re-init the distanceFromRightEdge for offset calculation
@@ -151,7 +152,7 @@ Showable {
151 distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
152 distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
152 }
153 }
153 indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
154 indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
154− } else {
155+ } else if (initalizeItem) {
155 indicatorRow.setDefaultItem();
156 indicatorRow.setDefaultItem();
156 indicatorRow.currentItemOffset = 0;
157 indicatorRow.currentItemOffset = 0;
157 }
158 }
@@ -179,6 +180,10 @@ Showable {
179 source: "graphics/VerticalDivider.png"
180 source: "graphics/VerticalDivider.png"
180 }
181 }
181
182
183+ VisibleIndicators {
184+ id: visibleIndicators
185+ }
186+
182 MenuContent {
187 MenuContent {
183 id: menuContent
188 id: menuContent
184 objectName: "menuContent"
189 objectName: "menuContent"
@@ -189,7 +194,7 @@ Showable {
189 top: indicatorRow.bottom
194 top: indicatorRow.bottom
190 bottom: handle.top
195 bottom: handle.top
191 }
196 }
192− indicatorsModel: indicatorsModel
197+ indicatorsModel: visibleIndicators.model
193 clip: !indicators.fullyOpened
198 clip: !indicators.fullyOpened
194 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
199 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
195 enabled: contentEnabled
200 enabled: contentEnabled
@@ -220,13 +225,9 @@ Showable {
220 right: parent.right
225 right: parent.right
221 bottom: parent.bottom
226 bottom: parent.bottom
222 }
227 }
223− height: get_height()
228+ height: Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0)
224 clip: height < handleImage.height
229 clip: height < handleImage.height
225
230
226− function get_height() {
227− return Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0);
228− }
229−
230 BorderImage {
231 BorderImage {
231 id: handleImage
232 id: handleImage
232 source: "graphics/handle.sci"
233 source: "graphics/handle.sci"
@@ -246,10 +247,6 @@ Showable {
246 anchors.fill: indicatorRow
247 anchors.fill: indicatorRow
247 }
248 }
248
249
249− Indicators.IndicatorsModel {
250− id: indicatorsModel
251− }
252−
253 IndicatorRow {
250 IndicatorRow {
254 id: indicatorRow
251 id: indicatorRow
255 objectName: "indicatorRow"
252 objectName: "indicatorRow"
@@ -258,18 +255,10 @@ Showable {
258 right: parent.right
255 right: parent.right
259 }
256 }
260 height: indicators.panelHeight
257 height: indicators.panelHeight
261− indicatorsModel: indicatorsModel
258+ indicatorsModel: visibleIndicators.model
262 state: indicators.state
259 state: indicators.state
263 unitProgress: indicators.unitProgress
260 unitProgress: indicators.unitProgress
264
261
265− onVisibleIndicatorsChanged: {
266− // need to do it here so we can control sequence
267− if (visibleIndicators !== undefined) {
268− menuContent.visibleIndicators = visibleIndicators;
269− menuContent.setCurrentMenuIndex(currentItemIndex);
270− }
271− }
272−
273 EdgeDragArea {
262 EdgeDragArea {
274 id: rowDragArea
263 id: rowDragArea
275 anchors.fill: indicatorRow
264 anchors.fill: indicatorRow
@@ -303,6 +292,7 @@ Showable {
303 onRunningChanged: {
292 onRunningChanged: {
304 if (showAnimation.running) {
293 if (showAnimation.running) {
305 indicators.state = "commit";
294 indicators.state = "commit";
295+ indicatorRow.currentItemOffset = 0;
306 }
296 }
307 }
297 }
308 }
298 }
@@ -313,7 +303,7 @@ Showable {
313 if (hideAnimation.running) {
303 if (hideAnimation.running) {
314 indicators.state = "initial";
304 indicators.state = "initial";
315 initalizeItem = true;
305 initalizeItem = true;
316− menuContent.animateNextMenuChange = false;
306+ indicatorRow.currentItemOffset = 0;
317 }
307 }
318 }
308 }
319 }
309 }
@@ -331,7 +321,7 @@ Showable {
331 if (!oldActive) return;
321 if (!oldActive) return;
332 d.enableIndexChangeSignal = false;
322 d.enableIndexChangeSignal = false;
333
323
334− indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
324+ indicatorRow.setCurrentItemIndex(menuContent.currentMenuIndex);
335
325
336 d.enableIndexChangeSignal = oldActive;
326 d.enableIndexChangeSignal = oldActive;
337 }
327 }
@@ -344,7 +334,7 @@ Showable {
344 if (!oldActive) return;
334 if (!oldActive) return;
345 d.enableIndexChangeSignal = false;
335 d.enableIndexChangeSignal = false;
346
336
347− menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex);
337+ menuContent.setCurrentMenuIndex(indicatorRow.currentItemIndex, fullyOpened || partiallyOpened);
348
338
349 d.enableIndexChangeSignal = oldActive;
339 d.enableIndexChangeSignal = oldActive;
350 }
340 }
@@ -439,6 +429,6 @@ Showable {
439
429
440 Component.onCompleted: initialise();
430 Component.onCompleted: initialise();
441 function initialise() {
431 function initialise() {
442− indicatorsModel.load();
432+ visibleIndicators.load();
443 }
433 }
444}
434}
qml/Panel/Indicators/IndicatorDelegate.qmlnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
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/>.
15+ *
16+ * Authors:
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Unity.Indicators 0.1 as Indicators
22+
23+Indicators.IndicatorBase {
24+ enabled: false
25+
26+ onRootActionStateChanged: {
27+ if (rootActionState == undefined) {
28+ enabled = false;
29+ return;
30+ }
31+
32+ enabled = rootActionState.visible;
33+ }
34+}
qml/Panel/Indicators/VisibleIndicators.qmlnew file+84
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
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/>.
15+ *
16+ * Authors:
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18+ */
19+
20+import QtQuick 2.0
21+import Unity.Indicators 0.1 as Indicators
22+import Utils 0.1
23+
24+Item {
25+ property SortFilterProxyModel model: filterModel
26+
27+ SortFilterProxyModel {
28+ id: filterModel
29+ filterRole: Indicators.IndicatorsModelRole.IsVisible
30+ filterRegExp: RegExp("^true$")
31+ dynamicSortFilter: true
32+
33+ model: Indicators.VisibleIndicatorsModel {
34+ id: visibleIndicatorsModel
35+ model: indicatorsModel
36+ }
37+ }
38+
39+
40+ Indicators.IndicatorsModel {
41+ id: indicatorsModel
42+ }
43+
44+ Repeater {
45+ id: repeater
46+ model: indicatorsModel
47+
48+ property var visibleIndicators: undefined
49+ onVisibleIndicatorsChanged: {
50+ if (visibleIndicators !== undefined) {
51+ visibleIndicatorsModel.visible = visibleIndicators;
52+ }
53+ }
54+
55+ delegate: IndicatorDelegate {
56+ id: item
57+ objectName: model.identifier + "-delegate"
58+ Component.onCompleted: {
59+ for(var pName in indicatorProperties) {
60+ if (item.hasOwnProperty(pName)) {
61+ item[pName] = indicatorProperties[pName];
62+ }
63+ }
64+ updateVisibility();
65+ }
66+
67+ onEnabledChanged: {
68+ updateVisibility()
69+ }
70+
71+ function updateVisibility() {
72+ if (repeater.visibleIndicators === undefined) {
73+ repeater.visibleIndicators = {}
74+ }
75+ repeater.visibleIndicators[model.identifier] = enabled;
76+ repeater.visibleIndicatorsChanged();
77+ }
78+ }
79+ }
80+
81+ function load() {
82+ indicatorsModel.load();
83+ }
84+}
qml/Panel/MenuContent.qml+13−26
@@ -28,26 +28,22 @@ MainView {
28
28
29 property QtObject indicatorsModel: null
29 property QtObject indicatorsModel: null
30 property bool __contentActive: false
30 property bool __contentActive: false
31− readonly property int currentMenuIndex : filteredIndicators.mapToSource(tabs.selectedTabIndex)
31+ readonly property int currentMenuIndex: tabs.selectedTabIndex
32 backgroundColor: "#221e1c" // FIXME not in palette yet
32 backgroundColor: "#221e1c" // FIXME not in palette yet
33 property int contentReleaseInterval: 20000
33 property int contentReleaseInterval: 20000
34 property bool activeHeader: false
34 property bool activeHeader: false
35− property alias visibleIndicators: visibleIndicatorsModel.visible
35+ property real headerHeight: tabs.tabBar.height
36− property bool animateNextMenuChange: false
37
36
38 width: units.gu(40)
37 width: units.gu(40)
39 height: units.gu(42)
38 height: units.gu(42)
40
39
41− function setCurrentMenuIndex(index) {
40+ function setCurrentMenuIndex(index, animate) {
42− var filteredIndex = filteredIndicators.mapFromSource(index);
43−
44− if (tabs.selectedTabIndex !== filteredIndex) {
41+ if (tabs.selectedTabIndex !== index) {
45− if (tabs.selectedTabIndex === -1 || !animateNextMenuChange) {
42+ if (tabs.selectedTabIndex === -1 || !animate) {
46 tabs.tabBar.animate = false;
43 tabs.tabBar.animate = false;
47 }
44 }
48− tabs.selectedTabIndex = filteredIndex;
45+ tabs.selectedTabIndex = index;
49 tabs.tabBar.animate = true;
46 tabs.tabBar.animate = true;
50− animateNextMenuChange = true;
51 }
47 }
52 }
48 }
53
49
@@ -67,29 +63,14 @@ MainView {
67 tabs.tabBar.alwaysSelectionMode = activeHeader;
63 tabs.tabBar.alwaysSelectionMode = activeHeader;
68 }
64 }
69
65
70− SortFilterProxyModel {
71− id: filteredIndicators
72− model: visibleIndicatorsModel
73− dynamicSortFilter: true
74−
75− filterRole: Indicators.IndicatorsModelRole.IsVisible
76− filterRegExp: RegExp("^true$")
77− }
78−
79− Indicators.VisibleIndicatorsModel {
80− id: visibleIndicatorsModel
81− model: indicatorsModel
82− }
83−
84 Tabs {
66 Tabs {
85 id: tabs
67 id: tabs
86 objectName: "tabs"
68 objectName: "tabs"
87 anchors.fill: parent
69 anchors.fill: parent
88− selectedTabIndex: -1
89
70
90 Repeater {
71 Repeater {
91 id: repeater
72 id: repeater
92− model: filteredIndicators
73+ model: content.indicatorsModel ? content.indicatorsModel : null
93 objectName: "tabsRepeater"
74 objectName: "tabsRepeater"
94
75
95 // FIXME: This is needed because tabs dont handle repeaters well.
76 // FIXME: This is needed because tabs dont handle repeaters well.
@@ -145,6 +126,12 @@ MainView {
145 property: "title"
126 property: "title"
146 value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
127 value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
147 }
128 }
129+
130+ Binding {
131+ target: loader.item
132+ property: "objectName"
133+ value: identifier + "-page"
134+ }
148 }
135 }
149 }
136 }
150 }
137 }
qml/Panel/Panel.qml+1−4
@@ -50,7 +50,7 @@ Item {
50
50
51 Connections {
51 Connections {
52 target: indicatorsMenu
52 target: indicatorsMenu
53− onShown: hideTimer.stop()
53+ onShownChanged: hideTimer.stop()
54 }
54 }
55
55
56 PanelBackground {
56 PanelBackground {
@@ -101,13 +101,10 @@ Item {
101 y: panelBackground.y
101 y: panelBackground.y
102 width: root.indicatorsMenuWidth
102 width: root.indicatorsMenuWidth
103 shown: false
103 shown: false
104− hintValue: __panelMinusSeparatorLineHeight * 3
105 panelHeight: __panelMinusSeparatorLineHeight
104 panelHeight: __panelMinusSeparatorLineHeight
106 openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
105 openedHeight: parent.height + (pinnedMode ? 0 : root.panelHeight)
107 pinnedMode: !fullscreenMode
106 pinnedMode: !fullscreenMode
108 overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
107 overFlowWidth: search.state=="hidden" ? parent.width : parent.width - search.width
109−
110− unitProgress: (height - panelHeight) / (openedHeight - panelHeight)
111 }
108 }
112
109
113 PanelSeparatorLine {
110 PanelSeparatorLine {
tests/mocks/Unity/Indicators/IndicatorsModel.qml+5−5
@@ -28,35 +28,35 @@ ListModel {
28 "position": 0,
28 "position": 0,
29 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
29 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
30 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
30 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
31− "indicatorProperties": ""
31+ "indicatorProperties": { enabled: true }
32 });
32 });
33
33
34 append({ "identifier": "indicator-fake2",
34 append({ "identifier": "indicator-fake2",
35 "position": 1,
35 "position": 1,
36 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
36 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
37 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
37 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
38− "indicatorProperties": ""
38+ "indicatorProperties": { enabled: true }
39 });
39 });
40
40
41 append({ "identifier": "indicator-fake3",
41 append({ "identifier": "indicator-fake3",
42 "position": 2,
42 "position": 2,
43 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
43 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
44 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
44 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
45− "indicatorProperties": ""
45+ "indicatorProperties": { enabled: true }
46 });
46 });
47
47
48 append({ "identifier": "indicator-fake4",
48 append({ "identifier": "indicator-fake4",
49 "position": 3,
49 "position": 3,
50 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
50 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
51 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
51 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
52− "indicatorProperties": ""
52+ "indicatorProperties": { enabled: true }
53 });
53 });
54
54
55 append({ "identifier": "indicator-fake5",
55 append({ "identifier": "indicator-fake5",
56 "position": 4,
56 "position": 4,
57 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
57 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
58 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
58 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
59− "indicatorProperties": ""
59+ "indicatorProperties": { enabled: true }
60 });
60 });
61 }
61 }
62}
62}
tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin1
21 id: menu_plugin1
22− objectName: "menu_page1"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin2
21 id: menu_plugin2
22− objectName: "menu_page2"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin3
21 id: menu_plugin3
22− objectName: "menu_page3"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin4
21 id: menu_plugin4
22− objectName: "menu_page4"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin5
21 id: menu_plugin5
22− objectName: "menu_page5"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/qmltests/Panel/tst_IndicatorRow.qml+64−163
@@ -35,7 +35,7 @@ Item {
35 indicatorModel.load();
35 indicatorModel.load();
36
36
37 indicatorRow.state = "initial";
37 indicatorRow.state = "initial";
38− indicatorRow.currentItem = null;
38+ indicatorRow.setCurrentItemIndex(-1);
39 indicatorRow.unitProgress = 0.0;
39 indicatorRow.unitProgress = 0.0;
40 }
40 }
41
41
@@ -51,6 +51,8 @@ Item {
51 }
51 }
52
52
53 indicatorsModel: indicatorModel
53 indicatorsModel: indicatorModel
54+
55+ Component.onCompleted: indicatorModel.load()
54 }
56 }
55
57
56 Indicators.IndicatorsModel {
58 Indicators.IndicatorsModel {
@@ -61,199 +63,98 @@ Item {
61 name: "IndicatorRow"
63 name: "IndicatorRow"
62 when: windowShown
64 when: windowShown
63
65
66+ function get_indicator_item(index) {
67+ return findChild(indicatorRow.row, "item" + index);
68+ }
69+
64 function test_set_current_item() {
70 function test_set_current_item() {
65 init_test();
71 init_test();
66− indicatorRow.setCurrentItem(0);
72+ indicatorRow.setCurrentItemIndex(0);
67 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
68
74
69− indicatorRow.setCurrentItem(1);
75+ indicatorRow.setCurrentItemIndex(1);
70 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
76 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
71
77
72− indicatorRow.setCurrentItem(2);
78+ indicatorRow.setCurrentItemIndex(2);
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
79 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
74 }
80 }
75− }
76−
77− UT.UnityTestCase {
78− name: "IndicatorRow_IconPosition"
79− when: windowShown
80−
81− function get_indicator_item_at(index) {
82− return findChild(indicatorRow, "rowRepeater").itemAt(index);
83− }
84−
85− function test_current_item_commit() {
86− init_test();
87−
88− indicatorRow.setCurrentItem(2);
89− indicatorRow.state = "commit";
90− tryCompare(get_indicator_item_at(0), "opacity", 0.0);
91− tryCompare(get_indicator_item_at(1), "opacity", 0.0);
92− tryCompare(get_indicator_item_at(2), "opacity", 1.0);
93− tryCompare(get_indicator_item_at(3), "opacity", 0.0);
94− tryCompare(get_indicator_item_at(4), "opacity", 0.0);
95− }
96− }
97−
98− UT.UnityTestCase {
99− name: "IndicatorRow_Highlight"
100− when: windowShown
101−
102− function get_indicator_item_at(index) {
103− return findChild(indicatorRow, "rowRepeater").itemAt(index);
104− }
105−
106− function test_intial_state() {
107− init_test();
108−
109− indicatorRow.state = "initial";
110− indicatorRow.setCurrentItem(0);
111−
112− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
113− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
114− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in initial state");
115− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in initial state");
116− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in initial state");
117− }
118−
119− function test_hint_state() {
120− init_test();
121−
122− indicatorRow.state = "hint";
123− indicatorRow.setCurrentItem(0);
124−
125− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
126− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
127− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
128− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
129− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in hint state");
130− }
131−
132− function test_revealed_state() {
133− init_test();
134−
135− indicatorRow.state = "reveal";
136− indicatorRow.setCurrentItem(0);
137−
138− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
139− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
140− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
141− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
142− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
143− }
144−
145− function test_commit_state() {
146− init_test();
147−
148− indicatorRow.state = "commit";
149− indicatorRow.setCurrentItem(0);
150
81
151− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
82+ function test_highlight_data() {
152− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
83+ return [
153− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
84+ { index: 0, progress: 0.0, current: false, other: false },
154− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
85+ { index: 0, progress: 0.1, current: true, other: false },
155− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
86+ { index: 0, progress: 0.5, current: true, other: false },
87+ { index: 0, progress: 1.0, current: true, other: false },
88+ { index: 2, progress: 0.0, current: false, other: false },
89+ { index: 2, progress: 0.1, current: true, other: false },
90+ { index: 2, progress: 0.5, current: true, other: false },
91+ { index: 2, progress: 1.0, current: true, other: false }
92+ ];
156 }
93 }
157
94
158− function test_locked_state() {
95+ function test_highlight(data) {
159 init_test();
96 init_test();
160
97
161− indicatorRow.state = "locked";
98+ indicatorRow.unitProgress = data.progress;
162− indicatorRow.setCurrentItem(0);
99+ indicatorRow.setCurrentItemIndex(data.index);
163
100
164− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
101+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
165− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
166− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in locked state");
167− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
168− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
169− }
170
102
171− function test_opacity() {
103+ for (var i = 0; i < indicatorRow.row.count; i++) {
172− init_test();
104+ compare(get_indicator_item(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
173−
105+ }
174− indicatorRow.state = "reveal";
175− indicatorRow.unitProgress = 0.5;
176− indicatorRow.setCurrentItem(2);
177−
178− compare(get_indicator_item_at(0).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
179− compare(get_indicator_item_at(1).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
180− compare(get_indicator_item_at(2).opacity, 1.0, "Current indicator should not change in response to panel progress");
181− compare(get_indicator_item_at(3).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
182− compare(get_indicator_item_at(4).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
183 }
106 }
184− }
185
107
186− UT.UnityTestCase {
108+ function test_opacity_data() {
187− name: "IndicatorRow_Dimmed"
109+ return [
188− when: windowShown
110+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
189−
111+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
190− function get_indicator_item_at(index) {
112+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
191− return findChild(indicatorRow, "rowRepeater").itemAt(index);
113+ { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
114+ { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
115+ { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
116+ { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
117+ { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
118+ ];
192 }
119 }
193
120
194− function test_intial_state() {
121+ function test_opacity(data) {
195 init_test();
122 init_test();
196
123
197− indicatorRow.state = "initial";
124+ indicatorRow.unitProgress = data.progress;
198− indicatorRow.setCurrentItem(0);
125+ indicatorRow.setCurrentItemIndex(data.index);
199−
200− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
201− compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
202− compare(get_indicator_item_at(2).dimmed, false, "Other indicators should not dim when in initial state");
203− compare(get_indicator_item_at(3).dimmed, false, "Other indicators should not dim when in initial state");
204− compare(get_indicator_item_at(4).dimmed, false, "Other indicators should not dim when in initial state");
205− }
206−
207− function test_hint_state() {
208− init_test();
209
126
210− indicatorRow.state = "hint";
127+ tryCompare(indicatorRow.currentItem, "opacity", data.current);
211− indicatorRow.setCurrentItem(0);
212
128
213− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
129+ for (var i = 0; i < indicatorRow.row.count; i++) {
214− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
130+ tryCompare(get_indicator_item(i), "opacity", i === data.index ? data.current: data.other);
215− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
131+ }
216− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");
217− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in hint state");
218 }
132 }
219
133
220− function test_revealed_state() {
134+ function test_dimmed_data() {
221− init_test();
135+ return [
222−
136+ { index: 0, progress: 0.0, current: false, other: false },
223− indicatorRow.state = "reveal";
137+ { index: 0, progress: 0.1, current: false, other: true },
224− indicatorRow.setCurrentItem(0);
138+ { index: 0, progress: 0.5, current: false, other: true },
225−
139+ { index: 0, progress: 1.0, current: false, other: true },
226− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
140+ { index: 2, progress: 0.0, current: false, other: false },
227− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
141+ { index: 2, progress: 0.1, current: false, other: true },
228− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
142+ { index: 2, progress: 0.5, current: false, other: true },
229− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
143+ { index: 2, progress: 1.0, current: false, other: true }
230− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
144+ ];
231 }
145 }
232
146
233− function test_commit_state() {
147+ function test_dimmed(data) {
234 init_test();
148 init_test();
235
149
236− indicatorRow.state = "commit";
150+ indicatorRow.unitProgress = data.progress;
237− indicatorRow.setCurrentItem(0);
151+ indicatorRow.setCurrentItemIndex(data.index);
238−
239− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
240− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
241− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in commit state");
242− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in commit state");
243− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in commit state");
244− }
245−
246− function test_locked_state() {
247− init_test();
248
152
249− indicatorRow.state = "locked";
153+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
250− indicatorRow.setCurrentItem(0);
251
154
252− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
155+ for (var i = 0; i < indicatorRow.row.count; i++) {
253− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
156+ compare(get_indicator_item(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
254− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
157+ }
255− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in locked state");
256− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
257 }
158 }
258 }
159 }
259}
160}
tests/qmltests/Panel/tst_Indicators.qml+40−32
@@ -103,21 +103,23 @@ Item {
103 // tests changing the lateral position of the revealer activates the correct indicator items.
103 // tests changing the lateral position of the revealer activates the correct indicator items.
104
104
105 var indicatorRow = findChild(indicators, "indicatorRow")
105 var indicatorRow = findChild(indicators, "indicatorRow")
106− var rowRepeater = findChild(indicators, "rowRepeater")
106+ verify(indicatorRow !== null);
107+ var indicatorRowItems = findChild(indicatorRow, "indicatorRowItems");
108+ verify(indicatorRowItems !== null);
107
109
108− for (var i = 0; i < rowRepeater.count; i++) {
110+ for (var i = 0; i < indicatorRowItems.count; i++) {
109− var indicatorItem = rowRepeater.itemAt(i);
111+ var indicatorItem = findChild(indicatorRowItems, "item" + i);
110
112
111 if (!indicatorItem.visible)
113 if (!indicatorItem.visible)
112 continue;
114 continue;
113
115
114 var indicatorPosition = indicators.mapFromItem(indicatorItem,
116 var indicatorPosition = indicators.mapFromItem(indicatorItem,
115− indicatorItem.width/2, indicatorItem.height/2)
117+ indicatorItem.width/2, indicatorItem.height/2);
116
118
117 touchFlick(indicators,
119 touchFlick(indicators,
118 indicatorPosition.x, indicatorPosition.y,
120 indicatorPosition.x, indicatorPosition.y,
119 indicatorPosition.x, indicators.openedHeight * 0.4,
121 indicatorPosition.x, indicators.openedHeight * 0.4,
120− true /* beginTouch */, false /* endTouch */)
122+ true /* beginTouch */, false /* endTouch */);
121
123
122 compare(indicatorRow.currentItem, indicatorItem,
124 compare(indicatorRow.currentItem, indicatorItem,
123 "Incorrect item activated at position " + i);
125 "Incorrect item activated at position " + i);
@@ -125,10 +127,10 @@ Item {
125 touchFlick(indicators,
127 touchFlick(indicators,
126 indicatorPosition.x, indicators.openedHeight * 0.4,
128 indicatorPosition.x, indicators.openedHeight * 0.4,
127 indicatorPosition.x, indicatorPosition.y,
129 indicatorPosition.x, indicatorPosition.y,
128− false /* beginTouch */, true /* endTouch */)
130+ false /* beginTouch */, true /* endTouch */);
129
131
130 // wait until fully closed
132 // wait until fully closed
131− tryCompare(indicators, "height", indicators.panelHeight)
133+ tryCompare(indicators, "height", indicators.panelHeight);
132 }
134 }
133 }
135 }
134
136
@@ -141,20 +143,20 @@ Item {
141 function test_progress_changes_state_to_not_initial() {
143 function test_progress_changes_state_to_not_initial() {
142 indicators.height = indicators.openedHeight / 2
144 indicators.height = indicators.openedHeight / 2
143 compare(indicators.state!="initial", true,
145 compare(indicators.state!="initial", true,
144− "Indicators should not be in initial state when partially opened.")
146+ "Indicators should not be in initial state when partially opened.");
145 }
147 }
146
148
147 function test_progress_changes_state_to_locked() {
149 function test_progress_changes_state_to_locked() {
148 indicators.height = indicators.openedHeight - indicators.panelHeight
150 indicators.height = indicators.openedHeight - indicators.panelHeight
149− compare(indicators.state, "locked", "Indicators should be locked when fully opened.")
151+ compare(indicators.state, "locked", "Indicators should be locked when fully opened.");
150 }
152 }
151
153
152 function test_partially_open() {
154 function test_partially_open() {
153 indicators.height = indicators.openedHeight / 2
155 indicators.height = indicators.openedHeight / 2
154 compare(indicators.partiallyOpened, true,
156 compare(indicators.partiallyOpened, true,
155− "Indicator should show as partially opened when height is half of openedHeight")
157+ "Indicator should show as partially opened when height is half of openedHeight");
156 compare(indicators.fullyOpened, false,
158 compare(indicators.fullyOpened, false,
157− "Indicator should not show as fully opened when height is half of openedHeight")
159+ "Indicator should not show as fully opened when height is half of openedHeight");
158 }
160 }
159
161
160 function test_fully_open() {
162 function test_fully_open() {
@@ -164,8 +166,8 @@ Item {
164 }
166 }
165
167
166 function init_invisible_indicator(identifier) {
168 function init_invisible_indicator(identifier) {
167− tryCompareFunction(function() { return findChild(indicators, identifier+"-widget") !== null }, true);
169+ tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
168− var item = findChild(indicators, identifier+"-widget");
170+ var item = findChild(indicators, identifier+"-delegate");
169
171
170 item.enabled = false;
172 item.enabled = false;
171 }
173 }
@@ -179,54 +181,60 @@ Item {
179 }
181 }
180
182
181 function test_row_visible_menuContent_visible(data) {
183 function test_row_visible_menuContent_visible(data) {
182−
183 indicators.show();
184 indicators.show();
184
185
185 var indicatorTabs = findChild(indicators, "tabs");
186 var indicatorTabs = findChild(indicators, "tabs");
186− var rowRepeater = findChild(indicators, "rowRepeater")
187+ var indicatorRowItems = findChild(indicators, "indicatorRowItems");
187−
188
188
189+ var count = data.visible.length
189 for (var i = 0; i< data.visible.length; i++) {
190 for (var i = 0; i< data.visible.length; i++) {
190− if (data.visible[i] === false)
191+ if (data.visible[i] === false) {
191 init_invisible_indicator("indicator-fake" + (i + 1));
192 init_invisible_indicator("indicator-fake" + (i + 1));
193+ count--;
194+ }
192 }
195 }
193
196
197+ tryCompare(indicatorRowItems, "count", count);
198+
194 for (i = 0; i < data.visible.length; i++) {
199 for (i = 0; i < data.visible.length; i++) {
195− var shouldBeVisible = data.visible[i];
200+ var widgetName = "indicator-fake" + (i + 1 + "-widget");
201+ var pageName = "indicator-fake" + (i + 1 + "-page");
202+
203+ // check for item
204+ tryCompareFunction(function() { return findChild(indicatorRowItems, widgetName) !== null }, data.visible[i]);
196
205
197− // check item visibility
206+ // check for tab
198− var indicatorItem = rowRepeater.itemAt(i);
199− tryCompare(indicatorItem, "visible", shouldBeVisible);
200− // check tab visibility
201− tryCompareFunction(function() { return findChild(indicatorTabs, "indicator-fake" + (i + 1)) !== null }, shouldBeVisible);
207+ tryCompareFunction(function() { return findChild(indicatorTabs, pageName) !== null }, data.visible[i]);
202 }
208 }
203 }
209 }
204
210
205 function test_indicator_visible_correct_tabs_data() { return [
211 function test_indicator_visible_correct_tabs_data() { return [
206− {tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expected: 1 },
212+ {tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake2" },
207− {tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expected: 3 },
213+ {tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expectedIndex: 3, expectedTab: "indicator-fake4" },
208− {tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expected: 0 },
214+ {tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake1" },
209− {tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expected: 1 }];
215+ {tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expectedIndex: 1, expectedTab: "indicator-fake2" }];
210 }
216 }
211
217
212 function test_indicator_visible_correct_tabs(data) {
218 function test_indicator_visible_correct_tabs(data) {
213−
214 var indicatorTabs = findChild(indicators, "tabs");
219 var indicatorTabs = findChild(indicators, "tabs");
215 var indicatorRow = findChild(indicators, "indicatorRow");
220 var indicatorRow = findChild(indicators, "indicatorRow");
216
221
217 indicators.show();
222 indicators.show();
218− indicatorRow.setCurrentItem(data.currentIndex);
223+ indicatorRow.setCurrentItemIndex(data.currentIndex);
219 tryCompare(indicators, "fullyOpened", true);
224 tryCompare(indicators, "fullyOpened", true);
220
225
221 for (var i = 0; i< data.visible.length; i++) {
226 for (var i = 0; i< data.visible.length; i++) {
222− if (data.visible[i] === false)
227+ if (data.visible[i] === false) {
223 init_invisible_indicator("indicator-fake" + (i + 1));
228 init_invisible_indicator("indicator-fake" + (i + 1));
229+ }
224 }
230 }
225
231
226 // check for current selected item
232 // check for current selected item
227− tryCompare(indicatorRow, "currentItemIndex", data.expected);
233+ tryCompare(indicatorRow, "currentItemIndex", data.expectedIndex);
234+
228 // check for current selected tab
235 // check for current selected tab
229− tryCompareFunction(function() { return findChild(indicatorTabs, "indicator-fake" + (data.expected + 1)) === indicatorTabs.selectedTab }, true);
236+ tryCompareFunction(function() { return findChild(indicatorTabs, data.expectedTab) === indicatorTabs.selectedTab }, true);
237+
230 }
238 }
231 }
239 }
232}
240}
tests/qmltests/Panel/tst_MenuContent.qml+6−14
@@ -27,11 +27,11 @@ Item {
27 height: units.gu(70)
27 height: units.gu(70)
28
28
29 property var indicator_status: {
29 property var indicator_status: {
30− 'menu_page1': { 'started': false, 'reset': 0 },
30+ 'indicator-fake1-page': { 'started': false, 'reset': 0 },
31− 'menu_page2': { 'started': false, 'reset': 0 },
31+ 'indicator-fake2-page': { 'started': false, 'reset': 0 },
32− 'menu_page3': { 'started': false, 'reset': 0 },
32+ 'indicator-fake3-page': { 'started': false, 'reset': 0 },
33− 'menu_page4': { 'started': false, 'reset': 0 },
33+ 'indicator-fake4-page': { 'started': false, 'reset': 0 },
34− 'menu_page5': { 'started': false, 'reset': 0 }
34+ 'indicator-fake5-page': { 'started': false, 'reset': 0 }
35 }
35 }
36
36
37 // Dummy objects
37 // Dummy objects
@@ -49,14 +49,6 @@ Item {
49 indicatorsModel: indicatorsModel
49 indicatorsModel: indicatorsModel
50 contentReleaseInterval: 50
50 contentReleaseInterval: 50
51 height: parent.height - 50
51 height: parent.height - 50
52−
53− visibleIndicators: {
54− 'indicator-fake1': true,
55− 'indicator-fake2': true,
56− 'indicator-fake3': true,
57− 'indicator-fake4': true,
58− 'indicator-fake5': true
59− }
60 }
52 }
61
53
62 Rectangle {
54 Rectangle {
@@ -96,7 +88,7 @@ Item {
96 }
88 }
97
89
98 function get_test_menu_objecName(index) {
90 function get_test_menu_objecName(index) {
99− return "menu_page"+(index+1);
91+ return "indicator-fake" + (index + 1) + "-page";
100 }
92 }
101
93
102 property string testTabObjectName : ""
94 property string testTabObjectName : ""
tests/qmltests/Panel/tst_Panel.qml+10−12
@@ -65,9 +65,10 @@ Item {
65 }
65 }
66
66
67 function get_indicator_item(index) {
67 function get_indicator_item(index) {
68− var rowRepeater = findChild(panel.indicators, "rowRepeater");
68+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
69− verify(rowRepeater !== null);
69+ verify(indicatorRow !== null);
70− return rowRepeater.itemAt(index);
70+
71+ return findChild(indicatorRow.row, "item" + index);
71 }
72 }
72
73
73 function get_indicator_item_position(index) {
74 function get_indicator_item_position(index) {
@@ -144,10 +145,10 @@ Item {
144 tryCompare(panel.indicators, "fullyOpened", true);
145 tryCompare(panel.indicators, "fullyOpened", true);
145 }
146 }
146
147
147− var indicatorRow = findChild(panel.indicators, "indicatorRow");
148+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
148 verify(indicatorRow !== null);
149 verify(indicatorRow !== null);
149
150
150− var rowRepeater = findChild(panel.indicators, "rowRepeater");
151+ var menuContent = findChild(panel.indicators, "menuContent");
151 verify(indicatorRow !== null);
152 verify(indicatorRow !== null);
152
153
153 var menuContent = findChild(panel.indicators, "menuContent");
154 var menuContent = findChild(panel.indicators, "menuContent");
@@ -162,10 +163,10 @@ Item {
162 }
163 }
163
164
164 // do this for each indicator item
165 // do this for each indicator item
165− for (var i = 0; i < rowRepeater.count; i++) {
166+ for (var i = 0; i < indicatorRow.row.count; i++) {
166
167
167 var indicatorItem = get_indicator_item(i);
168 var indicatorItem = get_indicator_item(i);
168− verify(indicatorItem != undefined);
169+ verify(indicatorItem !== null);
169
170
170 if (!indicatorItem.visible)
171 if (!indicatorItem.visible)
171 continue;
172 continue;
@@ -236,15 +237,12 @@ Item {
236 var indicatorRow = findChild(panel.indicators, "indicatorRow");
237 var indicatorRow = findChild(panel.indicators, "indicatorRow");
237 verify(indicatorRow !== null);
238 verify(indicatorRow !== null);
238
239
239− var rowRepeater = findChild(panel.indicators, "rowRepeater");
240− verify(indicatorRow !== null);
241−
242 // Get the first indicator
240 // Get the first indicator
243 var indicatorItemFirst = get_indicator_item(0);
241 var indicatorItemFirst = get_indicator_item(0);
244− verify(indicatorItemFirst !== undefined);
242+ verify(indicatorItemFirst !== null);
245
243
246 var indicatorItemCoordFirst = get_indicator_item_position(0);
244 var indicatorItemCoordFirst = get_indicator_item_position(0);
247− var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.count - 1);
245+ var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
248
246
249 touchPress(panel,
247 touchPress(panel,
250 indicatorItemCoordFirst.x, panel.panelHeight / 2);
248 indicatorItemCoordFirst.x, panel.panelHeight / 2);