on xenial help sign in
Fixed panel navigation bugs
73a7678Nick Dedekind
qml/Panel/IndicatorItem.qml+1−1
@@ -28,7 +28,7 @@ Item {
28 property bool indicatorVisible: loader.item ? loader.item.enabled : false
28 property bool indicatorVisible: loader.item ? loader.item.enabled : false
29
29
30 opacity: dimmed ? 0.4 : 1
30 opacity: dimmed ? 0.4 : 1
31− Behavior on opacity { StandardAnimation {} }
31+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
32
32
33 width: loader.item ? loader.item.width : 0
33 width: loader.item ? loader.item.width : 0
34
34
qml/Panel/IndicatorRow.qml+92−89
@@ -22,11 +22,11 @@ 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: defined
29+ property var visibleIndicators: undefined
30 property int overFlowWidth: width
30 property int overFlowWidth: width
31 property bool showAll: false
31 property bool showAll: false
32 property real currentItemOffset: 0.0
32 property real currentItemOffset: 0.0
@@ -40,9 +40,15 @@ Item {
40 setCurrentItem(0);
40 setCurrentItem(0);
41 }
41 }
42
42
43+ function setCurrentItemIndex(index) {
44+ itemView.currentIndex = index;
45+ }
46+
43− function setCurrentItem(index) {
47+ function setCurrentItem(item) {
44− if (currentItemIndex !== index) {
48+ if (item && item.hasOwnProperty("ownIndex")) {
45− currentItem = rowRepeater.itemAt(index);
49+ itemView.currentIndex = item.ownIndex;
50+ } else {
51+ itemView.currentIndex = -1;
46 }
52 }
47 }
53 }
48
54
@@ -55,96 +61,91 @@ Item {
55 }
61 }
56 }
62 }
57
63
58− Row {
64+ ListView {
59− id: row
65+ id: itemView
66+ objectName: "indicatorRowItems"
67+ interactive: false
68+ model: indicatorsModel ? indicatorsModel : null
60
69
61− width: children.width
70+ width: childrenRect.width
62− height: parent.height
71+ height: indicatorRow.height
63 anchors.right: parent.right
72 anchors.right: parent.right
73+ orientation: ListView.Horizontal
64
74
65− Repeater {
66− id: rowRepeater
67− objectName: "rowRepeater"
68− model: indicatorsModel ? indicatorsModel : undefined
69−
70− property int lastCount: 0
75+ property int lastCount: 0
71− onCountChanged: {
76+ onCountChanged: {
72− if (lastCount < count) {
77+ if (lastCount < count) {
73− showAll = true;
78+ showAll = true;
74− allVisible.start();
79+ allVisible.start();
75− }
76− lastCount = count;
77 }
80 }
81+ lastCount = count;
82+ }
83+
84+ delegate: Item {
85+ id: itemWrapper
86+ objectName: "item" + index
87+ height: indicatorRow.height
88+ width: visible ? indicatorItem.width : 0
89+ visible: indicatorItem.indicatorVisible
90+ opacity: 1 - indicatorRow.unitProgress
91+ y: 0
92+ state: "standard"
93+
94+ property int ownIndex: index
95+ property bool highlighted: indicatorRow.unitProgress > 0 ? ListView.isCurrentItem : false
96+ property bool dimmed: indicatorRow.unitProgress > 0 ? !ListView.isCurrentItem : false
97+
98+ property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
99+ property bool overflow: row.width - itemWrapper.x > overFlowWidth
100+
101+ IndicatorItem {
102+ id: indicatorItem
103+ height: parent.height
78
104
79− Item {
80− id: itemWrapper
81− height: indicatorRow.height
82− width: indicatorItem.width
83− visible: indicatorItem.indicatorVisible
84− opacity: 1.0 * opacityMultiplier
85− y: 0
86− state: "standard"
87−
88− property int ownIndex: index
89− property bool highlighted: indicatorRow.state != "initial" ? ownIndex == indicatorRow.currentItemIndex : false
90− property bool dimmed: indicatorRow.state != "initial" ? ownIndex != indicatorRow.currentItemIndex : false
91−
92− property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
93− property bool overflow: row.width - itemWrapper.x > overFlowWidth
94− property real opacityMultiplier: highlighted ? 1 : (1 - indicatorRow.unitProgress)
95−
96− IndicatorItem {
97− id: indicatorItem
98− height: parent.height
99−
100− dimmed: itemWrapper.dimmed
105+ dimmed: itemWrapper.dimmed
101−
106+
102− widgetSource: model.widgetSource
107+ widgetSource: model.widgetSource
103− indicatorProperties : model.indicatorProperties
108+ indicatorProperties : model.indicatorProperties
104−
109+
105− Component.onCompleted: {
110+ Component.onCompleted: {
106− if (visibleIndicators == undefined) {
111+ if (visibleIndicators == undefined) {
107− visibleIndicators = {}
112+ visibleIndicators = {}
108− }
109− indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
110− indicatorRow.visibleIndicatorsChanged();
111 }
113 }
112− onIndicatorVisibleChanged: {
113− if (visibleIndicators == undefined) {
114− visibleIndicators = {}
115− }
116− indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
114+ indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
117− indicatorRow.visibleIndicatorsChanged();
115+ indicatorRow.visibleIndicatorsChanged();
118−
116+ }
119− if (indicatorVisible) {
117+ onIndicatorVisibleChanged: {
120− showAll = true;
118+ if (visibleIndicators == undefined) {
121− allVisible.start();
119+ visibleIndicators = {}
122− }
123 }
120 }
124− }
121+ indicatorRow.visibleIndicators[model.identifier] = indicatorVisible;
122+ indicatorRow.visibleIndicatorsChanged();
125
123
126− states: [
124+ if (indicatorVisible) {
127− State {
125+ showAll = true;
128− name: "standard"
126+ allVisible.start();
129− when: !hidden && !overflow
130− },
131− State {
132− name: "overflow"
133− when: hidden || overflow
134− PropertyChanges { target: itemWrapper; opacity: 0.0 }
135− }
136− ]
137−
138− transitions: [
139− Transition {
140− UbuntuNumberAnimation {
141− target: itemWrapper
142− property: "opacity"
143− duration: UbuntuAnimation.BriskDuration
144− }
127+ }
145− }
128+ }
146− ]
147 }
129 }
130+
131+ states: [
132+ State {
133+ name: "standard"
134+ when: !hidden && !overflow && !highlighted
135+ },
136+ State {
137+ name: "highlighted"
138+ when: highlighted
139+ PropertyChanges { target: itemWrapper; opacity: 1.0 }
140+ },
141+ State {
142+ name: "hidden"
143+ when: hidden || overflow
144+ PropertyChanges { target: itemWrapper; opacity: 0.0 }
145+ }
146+ ]
147+
148+ Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
148 }
149 }
149 }
150 }
150
151
@@ -155,7 +156,9 @@ Item {
155 height: units.dp(2)
156 height: units.dp(2)
156 anchors.top: row.bottom
157 anchors.top: row.bottom
157 visible: indicatorRow.currentItem != null
158 visible: indicatorRow.currentItem != null
159+
158− x: row.x + (indicatorRow.currentItem != null ? indicatorRow.currentItem.x + centerOffset : 0)
160+ property real intendedX: row.x + (indicatorRow.currentItem != null ? indicatorRow.currentItem.x + centerOffset : 0)
161+ x: intendedX >= row.x ? (intendedX + width <= row.x + row.width ? intendedX : row.x + row.width - width) : row.x // listview boundaries
159 width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
162 width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
160
163
161 property real centerOffset: {
164 property real centerOffset: {
qml/Panel/Indicators.qml+7−5
@@ -31,7 +31,7 @@ Showable {
31 property alias overFlowWidth: indicatorRow.overFlowWidth
31 property alias overFlowWidth: indicatorRow.overFlowWidth
32 property alias showAll: indicatorRow.showAll
32 property alias showAll: indicatorRow.showAll
33
33
34− property int hintValue
34+ readonly property real hintValue: panelHeight + menuContent.headerHeight
35 readonly property int lockThreshold: openedHeight / 2
35 readonly property int lockThreshold: openedHeight / 2
36 property bool fullyOpened: height == openedHeight
36 property bool fullyOpened: height == openedHeight
37 property bool partiallyOpened: height > panelHeight && !fullyOpened
37 property bool partiallyOpened: height > panelHeight && !fullyOpened
@@ -128,7 +128,7 @@ Showable {
128
128
129 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
129 rowCoordinates = indicatorRow.mapToItem(indicatorRow.row, xValue, 0);
130 // get the current delegate
130 // get the current delegate
131− currentItem = indicatorRow.row.childAt(rowCoordinates.x, 0);
131+ currentItem = indicatorRow.row.itemAt(rowCoordinates.x, 0);
132 if (currentItem) {
132 if (currentItem) {
133 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
133 itemCoordinates = indicatorRow.row.mapToItem(currentItem, rowCoordinates.x, 0);
134 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
134 distanceFromRightEdge = (currentItem.width - itemCoordinates.x) / (currentItem.width);
@@ -143,7 +143,7 @@ Showable {
143 }
143 }
144 }
144 }
145 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
145 if ((!useBuffer || (useBuffer && bufferExceeded)) || indicatorRow.currentItemIndex < 0 || indicatorRow.currentItem == null) {
146− indicatorRow.currentItem = currentItem;
146+ indicatorRow.setCurrentItem(currentItem);
147 }
147 }
148
148
149 // need to re-init the distanceFromRightEdge for offset calculation
149 // need to re-init the distanceFromRightEdge for offset calculation
@@ -151,7 +151,7 @@ Showable {
151 distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
151 distanceFromRightEdge = (indicatorRow.currentItem.width - itemCoordinates.x) / (indicatorRow.currentItem.width);
152 }
152 }
153 indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
153 indicatorRow.currentItemOffset = 1 - (distanceFromRightEdge * 2);
154− } else {
154+ } else if (initalizeItem) {
155 indicatorRow.setDefaultItem();
155 indicatorRow.setDefaultItem();
156 indicatorRow.currentItemOffset = 0;
156 indicatorRow.currentItemOffset = 0;
157 }
157 }
@@ -298,6 +298,7 @@ Showable {
298 onRunningChanged: {
298 onRunningChanged: {
299 if (showAnimation.running) {
299 if (showAnimation.running) {
300 indicators.state = "commit";
300 indicators.state = "commit";
301+ indicatorRow.currentItemOffset = 0;
301 }
302 }
302 }
303 }
303 }
304 }
@@ -308,6 +309,7 @@ Showable {
308 if (hideAnimation.running) {
309 if (hideAnimation.running) {
309 indicators.state = "initial";
310 indicators.state = "initial";
310 initalizeItem = true;
311 initalizeItem = true;
312+ indicatorRow.currentItemOffset = 0;
311 menuContent.animateNextMenuChange = false;
313 menuContent.animateNextMenuChange = false;
312 }
314 }
313 }
315 }
@@ -326,7 +328,7 @@ Showable {
326 if (!oldActive) return;
328 if (!oldActive) return;
327 d.enableIndexChangeSignal = false;
329 d.enableIndexChangeSignal = false;
328
330
329− indicatorRow.setCurrentItem(menuContent.currentMenuIndex);
331+ indicatorRow.setCurrentItemIndex(menuContent.currentMenuIndex);
330
332
331 d.enableIndexChangeSignal = oldActive;
333 d.enableIndexChangeSignal = oldActive;
332 }
334 }
qml/Panel/MenuContent.qml+1
@@ -34,6 +34,7 @@ MainView {
34 property bool activeHeader: false
34 property bool activeHeader: false
35 property alias visibleIndicators: visibleIndicatorsModel.visible
35 property alias visibleIndicators: visibleIndicatorsModel.visible
36 property bool animateNextMenuChange: false
36 property bool animateNextMenuChange: false
37+ property real headerHeight: tabs.tabBar.height
37
38
38 width: units.gu(40)
39 width: units.gu(40)
39 height: units.gu(42)
40 height: units.gu(42)
qml/Panel/Panel.qml−1
@@ -101,7 +101,6 @@ 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
tests/qmltests/Panel/tst_IndicatorRow.qml+62−163
@@ -33,7 +33,7 @@ Item {
33 function init_test()
33 function init_test()
34 {
34 {
35 indicatorRow.state = "initial";
35 indicatorRow.state = "initial";
36− indicatorRow.currentItem = null;
36+ indicatorRow.setCurrentItemIndex(-1);
37 indicatorRow.unitProgress = 0.0;
37 indicatorRow.unitProgress = 0.0;
38 }
38 }
39
39
@@ -60,199 +60,98 @@ Item {
60 name: "IndicatorRow"
60 name: "IndicatorRow"
61 when: windowShown
61 when: windowShown
62
62
63+ function get_indicator_item_at(index) {
64+ return findChild(indicatorRow.row, "item" + index);
65+ }
66+
63 function test_set_current_item() {
67 function test_set_current_item() {
64 init_test();
68 init_test();
65− indicatorRow.setCurrentItem(0);
69+ indicatorRow.setCurrentItemIndex(0);
66 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
70 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
67
71
68− indicatorRow.setCurrentItem(1);
72+ indicatorRow.setCurrentItemIndex(1);
69 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
73 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
70
74
71− indicatorRow.setCurrentItem(2);
75+ indicatorRow.setCurrentItemIndex(2);
72 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
76 compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
73 }
77 }
74− }
75
78
76− UT.UnityTestCase {
79+ function test_highlight_data() {
77− name: "IndicatorRow_IconPosition"
80+ return [
78− when: windowShown
81+ { index: 0, progress: 0.0, current: false, other: false },
79−
82+ { index: 0, progress: 0.1, current: true, other: false },
80− function get_indicator_item_at(index) {
83+ { index: 0, progress: 0.5, current: true, other: false },
81− return findChild(indicatorRow, "rowRepeater").itemAt(index);
84+ { index: 0, progress: 1.0, current: true, other: false },
85+ { index: 2, progress: 0.0, current: false, other: false },
86+ { index: 2, progress: 0.1, current: true, other: false },
87+ { index: 2, progress: 0.5, current: true, other: false },
88+ { index: 2, progress: 1.0, current: true, other: false }
89+ ];
82 }
90 }
83
91
84− function test_current_item_commit() {
92+ function test_highlight(data) {
85 init_test();
93 init_test();
86
94
87− indicatorRow.setCurrentItem(2);
95+ indicatorRow.unitProgress = data.progress;
88− indicatorRow.state = "commit";
96+ indicatorRow.setCurrentItemIndex(data.index);
89− tryCompare(get_indicator_item_at(0), "opacity", 0.0);
90− tryCompare(get_indicator_item_at(1), "opacity", 0.0);
91− tryCompare(get_indicator_item_at(2), "opacity", 1.0);
92− tryCompare(get_indicator_item_at(3), "opacity", 0.0);
93− tryCompare(get_indicator_item_at(4), "opacity", 0.0);
94− }
95− }
96−
97− UT.UnityTestCase {
98− name: "IndicatorRow_Highlight"
99− when: windowShown
100−
101− function get_indicator_item_at(index) {
102− return findChild(indicatorRow, "rowRepeater").itemAt(index);
103− }
104−
105− function test_intial_state() {
106− init_test();
107
97
108− indicatorRow.state = "initial";
98+ compare(indicatorRow.currentItem.highlighted, data.current, "Indicator hightlight did not match for current item");
109− indicatorRow.setCurrentItem(0);
110
99
111− compare(indicatorRow.currentItem.highlighted, false, "Indicator should not highlight when in initial state");
100+ for (var i = 0; i < indicatorRow.row.count; i++) {
112− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in initial state");
101+ compare(get_indicator_item_at(i).highlighted, i === data.index ? data.current: data.other, "Indicator hightlight did not match for item iter");
113− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in initial state");
102+ }
114− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in initial state");
115− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in initial state");
116 }
103 }
117
104
118− function test_hint_state() {
105+ function test_opacity_data() {
119− init_test();
106+ return [
120−
107+ { index: 0, progress: 0.0, current: 1.0, other: 1.0 },
121− indicatorRow.state = "hint";
108+ { index: 0, progress: 0.1, current: 1.0, other: 0.9 },
122− indicatorRow.setCurrentItem(0);
109+ { index: 0, progress: 0.5, current: 1.0, other: 0.5 },
123−
110+ { index: 0, progress: 1.0, current: 1.0, other: 0.0 },
124− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in hint state");
111+ { index: 2, progress: 0.0, current: 1.0, other: 1.0 },
125− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in hint state");
112+ { index: 2, progress: 0.1, current: 1.0, other: 0.9 },
126− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in hint state");
113+ { index: 2, progress: 0.5, current: 1.0, other: 0.5 },
127− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in hint state");
114+ { index: 2, progress: 1.0, current: 1.0, other: 0.0 }
128− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in hint state");
115+ ];
129 }
116 }
130
117
131− function test_revealed_state() {
118+ function test_opacity(data) {
132 init_test();
119 init_test();
133
120
134− indicatorRow.state = "reveal";
121+ indicatorRow.unitProgress = data.progress;
135− indicatorRow.setCurrentItem(0);
122+ indicatorRow.setCurrentItemIndex(data.index);
136
123
137− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in reveal state");
124+ compare(indicatorRow.currentItem.opacity, data.current, "Indicator opacity did not match for current item");
138− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
139− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
140− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
141− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
142− }
143
125
144− function test_commit_state() {
126+ for (var i = 0; i < indicatorRow.row.count; i++) {
145− init_test();
127+ tryCompare(get_indicator_item_at(i), "opacity", i === data.index ? data.current: data.other);
146−
128+ }
147− indicatorRow.state = "commit";
148− indicatorRow.setCurrentItem(0);
149−
150− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in commit state");
151− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in commit state");
152− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in commit state");
153− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in commit state");
154− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in commit state");
155 }
129 }
156
130
157− function test_locked_state() {
131+ function test_dimmed_data() {
158− init_test();
132+ return [
159−
133+ { index: 0, progress: 0.0, current: false, other: false },
160− indicatorRow.state = "locked";
134+ { index: 0, progress: 0.1, current: false, other: true },
161− indicatorRow.setCurrentItem(0);
135+ { index: 0, progress: 0.5, current: false, other: true },
162−
136+ { index: 0, progress: 1.0, current: false, other: true },
163− compare(indicatorRow.currentItem.highlighted, true, "Indicator should highlight when in locked state");
137+ { index: 2, progress: 0.0, current: false, other: false },
164− compare(get_indicator_item_at(1).highlighted, false, "Other indicators should not highlight when in locked state");
138+ { index: 2, progress: 0.1, current: false, other: true },
165− compare(get_indicator_item_at(2).highlighted, false, "Other indicators should not highlight when in locked state");
139+ { index: 2, progress: 0.5, current: false, other: true },
166− compare(get_indicator_item_at(3).highlighted, false, "Other indicators should not highlight when in locked state");
140+ { index: 2, progress: 1.0, current: false, other: true }
167− compare(get_indicator_item_at(4).highlighted, false, "Other indicators should not highlight when in locked state");
141+ ];
168 }
142 }
169
143
170− function test_opacity() {
144+ function test_dimmed(data) {
171 init_test();
145 init_test();
172
146
173− indicatorRow.state = "reveal";
147+ indicatorRow.unitProgress = data.progress;
174− indicatorRow.unitProgress = 0.5;
148+ indicatorRow.setCurrentItemIndex(data.index);
175− indicatorRow.setCurrentItem(2);
176−
177− compare(get_indicator_item_at(0).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
178− compare(get_indicator_item_at(1).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
179− compare(get_indicator_item_at(2).opacity, 1.0, "Current indicator should not change in response to panel progress");
180− compare(get_indicator_item_at(3).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
181− compare(get_indicator_item_at(4).opacity, 0.5, "Other indicator opacity should change in response to panel progress");
182− }
183− }
184−
185− UT.UnityTestCase {
186− name: "IndicatorRow_Dimmed"
187− when: windowShown
188−
189− function get_indicator_item_at(index) {
190− return findChild(indicatorRow, "rowRepeater").itemAt(index);
191− }
192−
193− function test_intial_state() {
194− init_test();
195−
196− indicatorRow.state = "initial";
197− indicatorRow.setCurrentItem(0);
198−
199− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in intiial state");
200− compare(get_indicator_item_at(1).dimmed, false, "Other indicators should not dim when in initial state");
201− compare(get_indicator_item_at(2).dimmed, false, "Other indicators should not dim when in initial state");
202− compare(get_indicator_item_at(3).dimmed, false, "Other indicators should not dim when in initial state");
203− compare(get_indicator_item_at(4).dimmed, false, "Other indicators should not dim when in initial state");
204− }
205−
206− function test_hint_state() {
207− init_test();
208−
209− indicatorRow.state = "hint";
210− indicatorRow.setCurrentItem(0);
211−
212− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in hint state");
213− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in hint state");
214− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in hint state");
215− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in hint state");
216− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in hint state");
217− }
218−
219− function test_revealed_state() {
220− init_test();
221−
222− indicatorRow.state = "reveal";
223− indicatorRow.setCurrentItem(0);
224−
225− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in reveal state");
226− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in reveal state");
227− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in reveal state");
228− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in reveal state");
229− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in reveal state");
230− }
231−
232− function test_commit_state() {
233− init_test();
234−
235− indicatorRow.state = "commit";
236− indicatorRow.setCurrentItem(0);
237−
238− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in commit state");
239− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in commit state");
240− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in commit state");
241− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in commit state");
242− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in commit state");
243− }
244−
245− function test_locked_state() {
246− init_test();
247
149
248− indicatorRow.state = "locked";
150+ compare(indicatorRow.currentItem.dimmed, data.current, "Indicator dim did not match for current item");
249− indicatorRow.setCurrentItem(0);
250
151
251− compare(get_indicator_item_at(0).dimmed, false, "Current indicator should not dim when in locked state");
152+ for (var i = 0; i < indicatorRow.row.count; i++) {
252− compare(get_indicator_item_at(1).dimmed, true, "Other indicators should dim when in locked state");
153+ compare(get_indicator_item_at(i).dimmed, i === data.index ? data.current: data.other, "Indicator dim did not match for item iter");
253− compare(get_indicator_item_at(2).dimmed, true, "Other indicators should dim when in locked state");
154+ }
254− compare(get_indicator_item_at(3).dimmed, true, "Other indicators should dim when in locked state");
255− compare(get_indicator_item_at(4).dimmed, true, "Other indicators should dim when in locked state");
256 }
155 }
257 }
156 }
258}
157}
tests/qmltests/Panel/tst_Indicators.qml+10−6
@@ -101,10 +101,10 @@ Item {
101 // tests changing the lateral position of the revealer activates the correct indicator items.
101 // tests changing the lateral position of the revealer activates the correct indicator items.
102
102
103 var indicatorRow = findChild(indicators, "indicatorRow")
103 var indicatorRow = findChild(indicators, "indicatorRow")
104− var rowRepeater = findChild(indicators, "rowRepeater")
104+ verify(indicatorRow !== undefined)
105
105
106− for (var i = 0; i < rowRepeater.count; i++) {
106+ for (var i = 0; i < indicatorRow.row.count; i++) {
107− var indicatorItem = rowRepeater.itemAt(i);
107+ var indicatorItem = findChild(indicatorRow.row, "item" + i);
108
108
109 if (!indicatorItem.visible)
109 if (!indicatorItem.visible)
110 continue;
110 continue;
@@ -168,10 +168,14 @@ Item {
168
168
169 function test_row_visible_menuContent_visible(data) {
169 function test_row_visible_menuContent_visible(data) {
170 var indicatorTabs = findChild(indicators, "tabs");
170 var indicatorTabs = findChild(indicators, "tabs");
171− var rowRepeater = findChild(indicators, "rowRepeater");
171+ verify(indicatorTabs !== undefined)
172
172
173+ var indicatorRow = findChild(indicators, "indicatorRow");
174+ verify(indicatorRow !== undefined);
173− var indicatorItem = rowRepeater.itemAt(data.index);
175+ var indicatorItem = findChild(indicatorRow.row, "item" + data.index);
176+ verify(indicatorItem !== undefined);
177+
174− tryCompareFunction(function() { return indicatorItem.width > 0}, true);
178+ tryCompareFunction(function() { return indicatorItem.width > 0}, data.visible);
175 tryCompare(indicatorItem, "visible", data.visible);
179 tryCompare(indicatorItem, "visible", data.visible);
176
180
177 var indicatorTab = findChild(indicatorTabs, data.name)
181 var indicatorTab = findChild(indicatorTabs, data.name)
tests/qmltests/Panel/tst_Panel.qml+9−11
@@ -62,10 +62,14 @@ Item {
62 tryCompare(panel.indicators, "state", "initial");
62 tryCompare(panel.indicators, "state", "initial");
63 }
63 }
64
64
65+ function get_indicator_item_at(index) {
66+ }
67+
65 function get_indicator_item(index) {
68 function get_indicator_item(index) {
66− var rowRepeater = findChild(panel.indicators, "rowRepeater");
69+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
67− verify(rowRepeater != undefined);
70+ verify(indicatorRow != undefined);
68− return rowRepeater.itemAt(index);
71+
72+ return findChild(indicatorRow.row, "item" + index);
69 }
73 }
70
74
71 function get_indicator_item_position(index) {
75 function get_indicator_item_position(index) {
@@ -145,9 +149,6 @@ Item {
145 var indicatorRow = findChild(panel.indicators, "indicatorRow");
149 var indicatorRow = findChild(panel.indicators, "indicatorRow");
146 verify(indicatorRow != undefined);
150 verify(indicatorRow != undefined);
147
151
148− var rowRepeater = findChild(panel.indicators, "rowRepeater");
149− verify(indicatorRow != undefined);
150−
151 var menuContent = findChild(panel.indicators, "menuContent");
152 var menuContent = findChild(panel.indicators, "menuContent");
152 verify(indicatorRow != undefined);
153 verify(indicatorRow != undefined);
153
154
@@ -160,7 +161,7 @@ Item {
160 }
161 }
161
162
162 // do this for each indicator item
163 // do this for each indicator item
163− for (var i = 0; i < rowRepeater.count; i++) {
164+ for (var i = 0; i < indicatorRow.row.count; i++) {
164
165
165 var indicatorItem = get_indicator_item(i);
166 var indicatorItem = get_indicator_item(i);
166 verify(indicatorItem != undefined);
167 verify(indicatorItem != undefined);
@@ -234,15 +235,12 @@ Item {
234 var indicatorRow = findChild(panel.indicators, "indicatorRow");
235 var indicatorRow = findChild(panel.indicators, "indicatorRow");
235 verify(indicatorRow != undefined);
236 verify(indicatorRow != undefined);
236
237
237− var rowRepeater = findChild(panel.indicators, "rowRepeater");
238− verify(indicatorRow != undefined);
239−
240 // Get the first indicator
238 // Get the first indicator
241 var indicatorItemFirst = get_indicator_item(0);
239 var indicatorItemFirst = get_indicator_item(0);
242 verify(indicatorItemFirst != undefined);
240 verify(indicatorItemFirst != undefined);
243
241
244 var indicatorItemCoordFirst = get_indicator_item_position(0);
242 var indicatorItemCoordFirst = get_indicator_item_position(0);
245− var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.count - 1);
243+ var indicatorItemCoordNext = get_indicator_item_position(indicatorRow.row.count - 1);
246
244
247 touchPress(panel,
245 touchPress(panel,
248 indicatorItemCoordFirst.x, panel.panelHeight / 2);
246 indicatorItemCoordFirst.x, panel.panelHeight / 2);