on xenial help sign in
self review fixes
cfc6b8cNick Dedekind
qml/Components/ScrollCalculator.qml+16−14
@@ -29,9 +29,9 @@ Item {
29 readonly property bool areaActive: lateralPosition >= 0
29 readonly property bool areaActive: lateralPosition >= 0
30 onAreaActiveChanged: {
30 onAreaActiveChanged: {
31 if (areaActive) {
31 if (areaActive) {
32− handleEnter()
32+ handleEnter();
33 } else {
33 } else {
34− handleExit()
34+ handleExit();
35 }
35 }
36 }
36 }
37
37
@@ -44,37 +44,39 @@ Item {
44 rotation: direction == Qt.LeftToRight ? 0 : 180
44 rotation: direction == Qt.LeftToRight ? 0 : 180
45
45
46 function handleEnter() {
46 function handleEnter() {
47− d.threasholdAreaX = -scrollArea.thresholdAreaWidth
47+ d.threasholdAreaX = -scrollArea.thresholdAreaWidth;
48− scrollTimer.restart()
48+ scrollTimer.restart();
49 }
49 }
50 onLateralPositionChanged: {
50 onLateralPositionChanged: {
51 if (scrollArea.areaActive) {
51 if (scrollArea.areaActive) {
52
52
53 if (lateralPosition > width * (1 - forceScrollingPercentage)) {
53 if (lateralPosition > width * (1 - forceScrollingPercentage)) {
54− d.threasholdAreaX = width * (1 - forceScrollingPercentage)
54+ d.threasholdAreaX = width * (1 - forceScrollingPercentage);
55− if (!scrollTimer.running) scrollTimer.restart()
55+ if (!scrollTimer.running) scrollTimer.restart();
56 } else if (lateralPosition > d.threasholdAreaX + scrollArea.thresholdAreaWidth) {
56 } else if (lateralPosition > d.threasholdAreaX + scrollArea.thresholdAreaWidth) {
57− d.threasholdAreaX = lateralPosition - scrollArea.thresholdAreaWidth
57+ d.threasholdAreaX = lateralPosition - scrollArea.thresholdAreaWidth;
58− if (!scrollTimer.running) scrollTimer.restart()
58+ if (!scrollTimer.running) scrollTimer.restart();
59 } else if (lateralPosition < d.threasholdAreaX) {
59 } else if (lateralPosition < d.threasholdAreaX) {
60− d.threasholdAreaX = lateralPosition
60+ d.threasholdAreaX = lateralPosition;
61− scrollTimer.stop()
61+ scrollTimer.stop();
62 }
62 }
63
63
64− d.progression = lateralPosition / width
64+ d.progression = lateralPosition / width;
65 }
65 }
66 }
66 }
67
67
68 function handleExit() {
68 function handleExit() {
69− d.threasholdAreaX = -scrollArea.thresholdAreaWidth
69+ d.threasholdAreaX = -scrollArea.thresholdAreaWidth;
70− scrollTimer.stop()
70+ scrollTimer.stop();
71 }
71 }
72
72
73 Timer {
73 Timer {
74 id: scrollTimer
74 id: scrollTimer
75 interval: 5
75 interval: 5
76 repeat: true
76 repeat: true
77+ onTriggered: {
77− onTriggered: scrollArea.scroll(scrollArea.baseScrollAmount + scrollArea.maximumScrollAmount * d.progression)
78+ scrollArea.scroll(scrollArea.baseScrollAmount + scrollArea.maximumScrollAmount * d.progression);
79+ }
78 }
80 }
79
81
80 QtObject {
82 QtObject {
qml/Panel/IndicatorItem.qml+1−4
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -12,9 +12,6 @@
12 *
12 *
13 * You should have received a copy of the GNU Lesser General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Nick Dedekind <nick.dedekind@canonical.com>
18 */
15 */
19
16
20import QtQuick 2.1
17import QtQuick 2.1
qml/Panel/IndicatorItemRow.qml+15−25
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -19,10 +19,11 @@ import Ubuntu.Components 0.1
19
19
20Item {
20Item {
21 id: root
21 id: root
22+ width: row.width
23+ height: units.gu(3)
22
24
23 property QtObject indicatorsModel: null
25 property QtObject indicatorsModel: null
24 property real overFlowWidth: width
26 property real overFlowWidth: width
25− property bool showAll: false
26 property bool expanded: false
27 property bool expanded: false
27 property var currentItem: null
28 property var currentItem: null
28 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
29 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
@@ -30,6 +31,7 @@ Item {
30 property real unitProgress: 0.0
31 property real unitProgress: 0.0
31 property real selectionChangeBuffer: units.gu(2)
32 property real selectionChangeBuffer: units.gu(2)
32 property bool enableLateralChanges: false
33 property bool enableLateralChanges: false
34+ property color hightlightColor: "#ededed"
33
35
34 property real lateralPosition: -1
36 property real lateralPosition: -1
35 onLateralPositionChanged: {
37 onLateralPositionChanged: {
@@ -53,11 +55,11 @@ Item {
53 } else {
55 } else {
54 var currentItemLateralPosition = root.mapToItem(proposedItem, lateralPosition, 0).x;
56 var currentItemLateralPosition = root.mapToItem(proposedItem, lateralPosition, 0).x;
55
57
56− // is the distance into proposed item greater than max buffer?
58+ // Is the distance into proposed item greater than max buffer?
57− // proposed item is before current item
59+ // Poposed item is before current item
58 if (proposedItem.x < currentItem.x) {
60 if (proposedItem.x < currentItem.x) {
59 bufferExceeded = (proposedItem.width - currentItemLateralPosition) > maximumBufferOffset;
61 bufferExceeded = (proposedItem.width - currentItemLateralPosition) > maximumBufferOffset;
60− } else { // after
62+ } else { // After
61 bufferExceeded = currentItemLateralPosition > maximumBufferOffset;
63 bufferExceeded = currentItemLateralPosition > maximumBufferOffset;
62 }
64 }
63 }
65 }
@@ -70,12 +72,9 @@ Item {
70 }
72 }
71 }
73 }
72
74
73− width: row.width
74− height: units.gu(3)
75−
76 function indicatorAt(x, y) {
75 function indicatorAt(x, y) {
77 var item = row.childAt(x, y);
76 var item = row.childAt(x, y);
78− return item && item.hasOwnProperty("ownIndex") ? item : null
77+ return item && item.hasOwnProperty("ownIndex") ? item : null;
79 }
78 }
80
79
81 function resetCurrentItem() {
80 function resetCurrentItem() {
@@ -99,11 +98,11 @@ Item {
99 if (item && item.opacity > 0) {
98 if (item && item.opacity > 0) {
100 currentItem = item;
99 currentItem = item;
101 } else {
100 } else {
101+ // Select default item.
102 var searchIndex = lateralPosition > width ? repeater.count-1 : 0;
102 var searchIndex = lateralPosition > width ? repeater.count-1 : 0;
103
103
104 for (var i = 0; i < row.children.length; i++) {
104 for (var i = 0; i < row.children.length; i++) {
105− if (row.children[i].hasOwnProperty("ownIndex") &&
105+ if (row.children[i].hasOwnProperty("ownIndex") && row.children[i].ownIndex === searchIndex) {
106− row.children[i].ownIndex === searchIndex) {
107 item = row.children[i];
106 item = row.children[i];
108 break;
107 break;
109 }
108 }
@@ -125,15 +124,6 @@ Item {
125 d.previousItem = currentItem;
124 d.previousItem = currentItem;
126 }
125 }
127
126
128− Timer {
129− id: allVisible
130− interval: 1000
131−
132− onTriggered: {
133− showAll = false;
134− }
135− }
136−
137 Row {
127 Row {
138 id: row
128 id: row
139 anchors {
129 anchors {
@@ -175,7 +165,7 @@ Item {
175
165
176 anchors.bottom: row.bottom
166 anchors.bottom: row.bottom
177 height: units.dp(2)
167 height: units.dp(2)
178− color: "#ededed"
168+ color: root.hightlightColor
179 visible: root.currentItem !== null
169 visible: root.currentItem !== null
180 opacity: 0.0
170 opacity: 0.0
181
171
@@ -193,11 +183,11 @@ Item {
193
183
194 var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
184 var itemMapped = root.mapToItem(currentItem, lateralPosition, 0);
195
185
196− var distanceFromCenter = itemMapped.x - currentItem.width/2;
186+ var distanceFromCenter = itemMapped.x - currentItem.width / 2;
197 if (distanceFromCenter > 0) {
187 if (distanceFromCenter > 0) {
198− distanceFromCenter = Math.max(0, distanceFromCenter-currentItem.width/8);
188+ distanceFromCenter = Math.max(0, distanceFromCenter-currentItem.width / 8);
199 } else {
189 } else {
200− distanceFromCenter = Math.min(0, distanceFromCenter+currentItem.width/8);
190+ distanceFromCenter = Math.min(0, distanceFromCenter+currentItem.width / 8);
201 }
191 }
202
192
203 if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
193 if (currentItem && currentItem.ownIndex === 0 && distanceFromCenter < 0) {
@@ -206,7 +196,7 @@ Item {
206 return 0;
196 return 0;
207 }
197 }
208
198
209− var shiftPercentageOffset = (distanceFromCenter / (currentItem.width/4));
199+ var shiftPercentageOffset = (distanceFromCenter / (currentItem.width / 4));
210 return shiftPercentageOffset * units.gu(1);
200 return shiftPercentageOffset * units.gu(1);
211 }
201 }
212 Behavior on highlightCenterOffset {
202 Behavior on highlightCenterOffset {
qml/Panel/IndicatorPage.qml+1−5
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU Lesser General Public License as published by
@@ -12,10 +12,6 @@
12 *
12 *
13 * You should have received a copy of the GNU Lesser General Public License
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/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Renato Araujo Oliveira Filho <renato@canonical.com>
18− * Nick Dedekind <nick.dedekind@canonical.com>
19 */
15 */
20
16
21import QtQuick 2.0
17import QtQuick 2.0
qml/Panel/Indicators/VisibleIndicators.qml+1−3
@@ -24,9 +24,8 @@ import Utils 0.1
24Item {
24Item {
25 id: root
25 id: root
26 property SortFilterProxyModel model: filterModel
26 property SortFilterProxyModel model: filterModel
27− property string profile: indicatorProfile
28
27
29− function initialise() {
28+ function initialise(profile) {
30 indicatorsModel.load(profile);
29 indicatorsModel.load(profile);
31 }
30 }
32
31
@@ -44,7 +43,6 @@ Item {
44
43
45 Indicators.IndicatorsModel {
44 Indicators.IndicatorsModel {
46 id: indicatorsModel
45 id: indicatorsModel
47− Component.onCompleted: root.initialise();
48 }
46 }
49
47
50 Repeater {
48 Repeater {
qml/Panel/IndicatorsBar.qml+13−13
@@ -45,13 +45,13 @@ Item {
45
45
46 function addScrollOffset(scrollAmmout) {
46 function addScrollOffset(scrollAmmout) {
47 var proposedScrollOffset = d.scrollOffset + scrollAmmout;
47 var proposedScrollOffset = d.scrollOffset + scrollAmmout;
48− var proposedCombinedOffset = d.combinedOffset - scrollAmmout
48+ var proposedCombinedOffset = d.combinedOffset - scrollAmmout;
49
49
50 if (scrollAmmout < 0 && d.combinedOffset > (row.width - rowContainer.width)) return;
50 if (scrollAmmout < 0 && d.combinedOffset > (row.width - rowContainer.width)) return;
51
51
52 if (scrollAmmout > 0 && proposedCombinedOffset < 0) {
52 if (scrollAmmout > 0 && proposedCombinedOffset < 0) {
53 // get the combined offset back to 0
53 // get the combined offset back to 0
54− proposedScrollOffset = proposedScrollOffset + proposedCombinedOffset
54+ proposedScrollOffset = proposedScrollOffset + proposedCombinedOffset;
55 } else if (scrollAmmout < 0 && proposedCombinedOffset > row.width - rowContainer.width) {
55 } else if (scrollAmmout < 0 && proposedCombinedOffset > row.width - rowContainer.width) {
56 // get the combined offset back to max
56 // get the combined offset back to max
57 proposedScrollOffset = proposedScrollOffset + (proposedCombinedOffset - (row.width - rowContainer.width));
57 proposedScrollOffset = proposedScrollOffset + (proposedCombinedOffset - (row.width - rowContainer.width));
@@ -148,7 +148,9 @@ Item {
148 interactive: root.expanded
148 interactive: root.expanded
149
149
150 property bool moved: false
150 property bool moved: false
151− onMovingChanged: { moved = true }
151+ onMovingChanged: {
152+ moved = true;
153+ }
152
154
153 rebound: Transition {
155 rebound: Transition {
154 NumberAnimation {
156 NumberAnimation {
@@ -201,7 +203,7 @@ Item {
201 // keep flickable inline with row
203 // keep flickable inline with row
202 PropertyChanges {
204 PropertyChanges {
203 target: flickable
205 target: flickable
204− contentX: (flickable.contentWidth - flickable.width) - d.combinedOffset;
206+ contentX: (flickable.contentWidth - flickable.width) - d.combinedOffset
205 restoreEntryValues: false
207 restoreEntryValues: false
206 }
208 }
207 },
209 },
@@ -227,13 +229,11 @@ Item {
227 Transition {
229 Transition {
228 from: "expanded"
230 from: "expanded"
229 to: "minimized"
231 to: "minimized"
230− SequentialAnimation {
231− PropertyAnimation {
232+ PropertyAnimation {
232− target: d;
233+ target: d;
233− properties: "rowOffset, scrollOffset";
234+ properties: "rowOffset, scrollOffset"
234− duration: UbuntuAnimation.SnapDuration;
235+ duration: UbuntuAnimation.SnapDuration
235− easing: UbuntuAnimation.StandardEasing
236+ easing: UbuntuAnimation.StandardEasing
236− }
237 }
237 }
238 },
238 },
239 Transition {
239 Transition {
@@ -243,8 +243,8 @@ Item {
243 PropertyAction { target: d; properties: "rowOffset, rowOffsetAdjustment, scrollOffset" }
243 PropertyAction { target: d; properties: "rowOffset, rowOffsetAdjustment, scrollOffset" }
244 PropertyAnimation {
244 PropertyAnimation {
245 target: row;
245 target: row;
246− properties: "anchors.rightMargin";
246+ properties: "anchors.rightMargin"
247− duration: UbuntuAnimation.SnapDuration;
247+ duration: UbuntuAnimation.SnapDuration
248 easing: UbuntuAnimation.StandardEasing
248 easing: UbuntuAnimation.StandardEasing
249 }
249 }
250 }
250 }
qml/Panel/IndicatorsMenu.qml+17−20
@@ -33,10 +33,8 @@ Showable {
33 readonly property bool fullyOpened: unitProgress >= 1
33 readonly property bool fullyOpened: unitProgress >= 1
34 readonly property bool partiallyOpened: unitProgress > 0 && unitProgress < 1.0
34 readonly property bool partiallyOpened: unitProgress > 0 && unitProgress < 1.0
35 readonly property bool fullyClosed: unitProgress == 0
35 readonly property bool fullyClosed: unitProgress == 0
36− readonly property real unitProgress: Math.max(0, (height - minimizedPanelHeight) /
36+ readonly property real unitProgress: Math.max(0, (height - minimizedPanelHeight) / (openedHeight - minimizedPanelHeight))
37− (openedHeight - minimizedPanelHeight))
38 property color panelColor: "black"
37 property color panelColor: "black"
39− // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
40
38
41 signal showTapped(point position)
39 signal showTapped(point position)
42
40
@@ -88,34 +86,34 @@ Showable {
88 indicatorsModel: root.indicatorsModel
86 indicatorsModel: root.indicatorsModel
89 visible: root.unitProgress > 0
87 visible: root.unitProgress > 0
90 enabled: contentEnabled
88 enabled: contentEnabled
89+ }
90+
91+ Handle {
92+ id: handle
93+ anchors {
94+ left: parent.left
95+ right: parent.right
96+ bottom: parent.bottom
97+ }
98+ height: units.gu(2)
99+ active: d.activeDragHandle ? true : false
91
100
92 //small shadow gradient at bottom of menu
101 //small shadow gradient at bottom of menu
93 Rectangle {
102 Rectangle {
94 anchors {
103 anchors {
95 left: parent.left
104 left: parent.left
96 right: parent.right
105 right: parent.right
97− bottom: parent.bottom
106+ bottom: parent.top
98 }
107 }
99 height: units.gu(0.5)
108 height: units.gu(0.5)
100 gradient: Gradient {
109 gradient: Gradient {
101 GradientStop { position: 0.0; color: "transparent" }
110 GradientStop { position: 0.0; color: "transparent" }
102 GradientStop { position: 1.0; color: "black" }
111 GradientStop { position: 1.0; color: "black" }
103 }
112 }
104− opacity: 0.4
113+ opacity: 0.3
105 }
114 }
106 }
115 }
107
116
108− Handle {
109− id: handle
110− anchors {
111− left: parent.left
112− right: parent.right
113− bottom: parent.bottom
114− }
115− height: units.gu(2)
116− active: d.activeDragHandle ? true : false
117− }
118−
119 Rectangle {
117 Rectangle {
120 anchors.fill: bar
118 anchors.fill: bar
121 color: panelColor
119 color: panelColor
@@ -176,12 +174,12 @@ Showable {
176 autoCompleteDragThreshold: maxTotalDragDistance / 2
174 autoCompleteDragThreshold: maxTotalDragDistance / 2
177 stretch: true
175 stretch: true
178 distanceThreshold: minimizedPanelHeight
176 distanceThreshold: minimizedPanelHeight
177+ onTapped: showTapped(Qt.point(touchSceneX, touchSceneY));
179
178
180 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
179 // using hint regulates minimum to hint displacement, but in fullscreen mode, we need to do it manually.
181 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
180 overrideStartValue: enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height
182 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
181 maxTotalDragDistance: openedHeight - (enableHint ? minimizedPanelHeight : expandedPanelHeight + handle.height)
183 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
182 hintDisplacement: enableHint ? expandedPanelHeight - minimizedPanelHeight + handle.height : 0
184− onTapped: showTapped(Qt.point(touchSceneX, touchSceneY));
185 }
183 }
186
184
187 DragHandle {
185 DragHandle {
@@ -238,7 +236,7 @@ Showable {
238 if (!oldActive) return;
236 if (!oldActive) return;
239 d.enableIndexChangeSignal = false;
237 d.enableIndexChangeSignal = false;
240
238
241− content.setCurrentMenuIndex(bar.currentItemIndex, fullyOpened || partiallyOpened);
239+ content.setCurrentMenuIndex(bar.currentItemIndex);
242
240
243 d.enableIndexChangeSignal = oldActive;
241 d.enableIndexChangeSignal = oldActive;
244 }
242 }
@@ -265,7 +263,6 @@ Showable {
265 StateChangeScript {
263 StateChangeScript {
266 script: {
264 script: {
267 yVelocityCalculator.reset();
265 yVelocityCalculator.reset();
268−
269 // initial item selection
266 // initial item selection
270 bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
267 bar.selectItemAt(d.activeDragHandle ? d.activeDragHandle.touchX : -1);
271 }
268 }
@@ -280,7 +277,7 @@ Showable {
280 if (!d.activeDragHandle) return false;
277 if (!d.activeDragHandle) return false;
281 if (!d.activeDragHandle.dragging) return false;
278 if (!d.activeDragHandle.dragging) return false;
282
279
283− yVelocityCalculator.trackedPosition = d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0
280+ yVelocityCalculator.trackedPosition = d.activeDragHandle ? d.activeDragHandle.touchSceneY : 0;
284 return Math.abs(yVelocityCalculator.calculate()) < 0.2;
281 return Math.abs(yVelocityCalculator.calculate()) < 0.2;
285 }
282 }
286 }
283 }
qml/Panel/MenuContent.qml+2−2
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -31,7 +31,7 @@ Rectangle {
31 width: units.gu(40)
31 width: units.gu(40)
32 height: units.gu(42)
32 height: units.gu(42)
33
33
34− function setCurrentMenuIndex(index, animate) {
34+ function setCurrentMenuIndex(index) {
35 // FIXME - https://bugreports.qt-project.org/browse/QTBUG-41229
35 // FIXME - https://bugreports.qt-project.org/browse/QTBUG-41229
36 listViewContent.currentIndex = -1;
36 listViewContent.currentIndex = -1;
37 listViewContent.currentIndex = index;
37 listViewContent.currentIndex = index;
qml/Panel/Panel.qml+1−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013-2014 Canonical, Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
qml/Shell.qml+2
@@ -583,6 +583,8 @@ Item {
583
583
584 VisibleIndicators {
584 VisibleIndicators {
585 id: visibleIndicators
585 id: visibleIndicators
586+ // TODO: This should be sourced by device type (eg "desktop", "tablet", "phone"...)
587+ Component.onCompleted: initialise(indicatorProfile)
586 }
588 }
587
589
588 property bool topmostApplicationIsFullscreen:
590 property bool topmostApplicationIsFullscreen:
tests/mocks/Unity/Indicators/FakeMenuPage.qmldeleted−58
@@ -1,58 +0,0 @@
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 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− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 1.1
19−
20−Flickable {
21− id: root
22− objectName: "fakeMenuPlugin"
23−
24− property string identifier
25− property color color: "transparent"
26−
27− Label {
28− text: identifier
29− anchors {
30− horizontalCenter: parent.horizontalCenter
31− bottom: contents.top
32− bottomMargin: units.gu(3)
33− }
34− color: Theme.palette.normal.foregroundText
35− fontSize: "x-large"
36−
37− }
38−
39− Rectangle {
40− id: contents
41− color: root.color
42−
43− height: 150
44− width: 150
45−
46− anchors {
47− horizontalCenter: parent.horizontalCenter
48− verticalCenter: parent.verticalCenter
49− }
50− }
51−
52− // Make it compatible with the PluginItem interface
53− function reset() {
54− if (shell != undefined && shell.indicator_status != undefined) {
55− shell.indicator_status[objectName].reset++;
56− }
57− }
58−}
tests/mocks/Unity/Indicators/qmldir−1
@@ -3,5 +3,4 @@ plugin IndicatorsFakeQml
3typeinfo Indicators.qmltypes
3typeinfo Indicators.qmltypes
4
4
5IndicatorsModel 0.1 IndicatorsModel.qml
5IndicatorsModel 0.1 IndicatorsModel.qml
6−FakeMenuPage 0.1 FakeMenuPage.qml
7RootActionState 0.1 RootActionState.qml
6RootActionState 0.1 RootActionState.qml
tests/qmltests/Panel/IndicatorTest.qml+1−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
tests/qmltests/Panel/tst_IndicatorItem.qml+1−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
tests/qmltests/Panel/tst_IndicatorItemRow.qml+15−13
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -61,7 +61,9 @@ IndicatorTest {
61 MouseArea {
61 MouseArea {
62 id: ma
62 id: ma
63 anchors.fill: parent
63 anchors.fill: parent
64+ onPositionChanged: {
64− onPositionChanged: { indicatorsRow.lateralPosition = mouse.x }
65+ indicatorsRow.lateralPosition = mouse.x;
66+ }
65 onPressed: {
67 onPressed: {
66 if (pressed) {
68 if (pressed) {
67 indicatorsRow.selectItemAt(mouse.x);
69 indicatorsRow.selectItemAt(mouse.x);
@@ -137,7 +139,7 @@ IndicatorTest {
137
139
138 verify(indicatorsModel.originalModelData.length > 0);
140 verify(indicatorsModel.originalModelData.length > 0);
139 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
141 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
140− item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"]+"-panelItem");
142+ item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"] + "-panelItem");
141 verify(item);
143 verify(item);
142
144
143 compare(item.ownIndex, i, "Item at incorrect index");
145 compare(item.ownIndex, i, "Item at incorrect index");
@@ -149,7 +151,7 @@ IndicatorTest {
149
151
150 // test removals
152 // test removals
151 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
153 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
152− item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"]+"-panelItem");
154+ item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"] + "-panelItem");
153
155
154 verify(data.remove.indexOf(i) !== -1 ? (item === null) : (item !== null));
156 verify(data.remove.indexOf(i) !== -1 ? (item === null) : (item !== null));
155 }
157 }
@@ -160,7 +162,7 @@ IndicatorTest {
160 }
162 }
161
163
162 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
164 for (i = 0; i < indicatorsModel.originalModelData.length; i++) {
163− item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"]+"-panelItem");
165+ item = findChild(indicatorsRow, indicatorsModel.originalModelData[i]["identifier"] + "-panelItem");
164 verify(item);
166 verify(item);
165
167
166 compare(item.ownIndex, i, "Item at incorrect index");
168 compare(item.ownIndex, i, "Item at incorrect index");
@@ -177,7 +179,7 @@ IndicatorTest {
177
179
178 // test selecting the item at it's position sets the current item of the row.
180 // test selecting the item at it's position sets the current item of the row.
179 function test_validCurrentItem(data) {
181 function test_validCurrentItem(data) {
180− var dataItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.index]["identifier"]+"-panelItem");
182+ var dataItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.index]["identifier"] + "-panelItem");
181 verify(dataItem !== null);
183 verify(dataItem !== null);
182
184
183 indicatorsRow.selectItemAt(dataItem.x + dataItem.width/2);
185 indicatorsRow.selectItemAt(dataItem.x + dataItem.width/2);
@@ -187,7 +189,7 @@ IndicatorTest {
187 // tests item default selection (no item at position X)
189 // tests item default selection (no item at position X)
188 function test_invalidCurrentItem() {
190 function test_invalidCurrentItem() {
189 indicatorsRow.selectItemAt(-100);
191 indicatorsRow.selectItemAt(-100);
190− var item = findChild(indicatorsRow, indicatorsModel.originalModelData[0]["identifier"]+"-panelItem");
192+ var item = findChild(indicatorsRow, indicatorsModel.originalModelData[0]["identifier"] + "-panelItem");
191 compare(indicatorsRow.currentItem, item);
193 compare(indicatorsRow.currentItem, item);
192 }
194 }
193
195
@@ -203,10 +205,10 @@ IndicatorTest {
203 indicatorsRow.expanded = true;
205 indicatorsRow.expanded = true;
204 wait_for_expansion_to_settle();
206 wait_for_expansion_to_settle();
205
207
206− var fromItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.from]["identifier"]+"-panelItem");
208+ var fromItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.from]["identifier"] + "-panelItem");
207 verify(fromItem !== null);
209 verify(fromItem !== null);
208
210
209− var toItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.to]["identifier"]+"-panelItem");
211+ var toItem = findChild(indicatorsRow, indicatorsModel.originalModelData[data.to]["identifier"] + "-panelItem");
210 verify(toItem !== null);
212 verify(toItem !== null);
211
213
212 var fromPosition = indicatorsRow.mapFromItem(fromItem, fromItem.width/2, fromItem.height/2);
214 var fromPosition = indicatorsRow.mapFromItem(fromItem, fromItem.width/2, fromItem.height/2);
@@ -228,12 +230,12 @@ IndicatorTest {
228 wait_for_expansion_to_settle();
230 wait_for_expansion_to_settle();
229
231
230 var highlight = findChild(indicatorsRow, "highlight");
232 var highlight = findChild(indicatorsRow, "highlight");
231− var item = findChild(indicatorsRow, indicatorsModel.originalModelData[2]["identifier"]+"-panelItem");
233+ var item = findChild(indicatorsRow, indicatorsModel.originalModelData[2]["identifier"] + "-panelItem");
232 verify(item !== null);
234 verify(item !== null);
233 var mappedPosition = indicatorsRow.mapFromItem(item, item.width/2, item.height/2);
235 var mappedPosition = indicatorsRow.mapFromItem(item, item.width/2, item.height/2);
234
236
235 mousePress(indicatorsRow, mappedPosition.x, mappedPosition.y);
237 mousePress(indicatorsRow, mappedPosition.x, mappedPosition.y);
236− var originalHightlightX = highlight.x
238+ var originalHightlightX = highlight.x;
237 var offset = 1;
239 var offset = 1;
238 while((highlight.x - originalHightlightX) <= units.gu(0.5) && offset < units.gu(10)) {
240 while((highlight.x - originalHightlightX) <= units.gu(0.5) && offset < units.gu(10)) {
239 mouseMove(indicatorsRow, mappedPosition.x + offset, mappedPosition.y, 10);
241 mouseMove(indicatorsRow, mappedPosition.x + offset, mappedPosition.y, 10);
@@ -253,12 +255,12 @@ IndicatorTest {
253 wait_for_expansion_to_settle();
255 wait_for_expansion_to_settle();
254
256
255 var highlight = findChild(indicatorsRow, "highlight");
257 var highlight = findChild(indicatorsRow, "highlight");
256− var item = findChild(indicatorsRow, indicatorsModel.originalModelData[2]["identifier"]+"-panelItem");
258+ var item = findChild(indicatorsRow, indicatorsModel.originalModelData[2]["identifier"] + "-panelItem");
257 verify(item !== null);
259 verify(item !== null);
258 var mappedPosition = indicatorsRow.mapFromItem(item, item.width/2, item.height/2);
260 var mappedPosition = indicatorsRow.mapFromItem(item, item.width/2, item.height/2);
259
261
260 mousePress(indicatorsRow, mappedPosition.x, mappedPosition.y);
262 mousePress(indicatorsRow, mappedPosition.x, mappedPosition.y);
261− var originalHightlightX = highlight.x
263+ var originalHightlightX = highlight.x;
262 var offset = 1;
264 var offset = 1;
263 while((highlight.x - originalHightlightX) >= -units.gu(0.5) && offset < units.gu(10)) {
265 while((highlight.x - originalHightlightX) >= -units.gu(0.5) && offset < units.gu(10)) {
264 mouseMove(indicatorsRow, mappedPosition.x - offset, mappedPosition.y, 10);
266 mouseMove(indicatorsRow, mappedPosition.x - offset, mappedPosition.y, 10);
tests/qmltests/Panel/tst_IndicatorPage.qml+6−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -109,7 +109,7 @@ Item {
109 "submenu": []
109 "submenu": []
110 }]; // end row 1
110 }]; // end row 1
111
111
112− function initMenuData(data) {
112+ function initializeMenuData(data) {
113 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.test",
113 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.test",
114 "/com/canonical/indicator/test",
114 "/com/canonical/indicator/test",
115 "/com/canonical/indicator/test",
115 "/com/canonical/indicator/test",
@@ -120,7 +120,7 @@ Item {
120 name: "IndicatorPage"
120 name: "IndicatorPage"
121
121
122 function init() {
122 function init() {
123− initMenuData([]);
123+ initializeMenuData([]);
124 }
124 }
125
125
126 function test_reloadData() {
126 function test_reloadData() {
@@ -128,10 +128,10 @@ Item {
128
128
129 tryCompare(mainMenu, "count", 0);
129 tryCompare(mainMenu, "count", 0);
130
130
131− initMenuData(fullMenuData);
131+ initializeMenuData(fullMenuData);
132 tryCompare(mainMenu, "count", 3);
132 tryCompare(mainMenu, "count", 3);
133
133
134− initMenuData([]);
134+ initializeMenuData([]);
135 tryCompare(mainMenu, "count", 0);
135 tryCompare(mainMenu, "count", 0);
136 }
136 }
137
137
@@ -144,7 +144,7 @@ Item {
144
144
145 function test_traverse_rootMenuType(data) {
145 function test_traverse_rootMenuType(data) {
146 page.rootMenuType = data.rootMenuType;
146 page.rootMenuType = data.rootMenuType;
147− initMenuData(fullMenuData);
147+ initializeMenuData(fullMenuData);
148
148
149 var mainMenu = findChild(page, "mainMenu");
149 var mainMenu = findChild(page, "mainMenu");
150 tryCompare(mainMenu, "count", data.expectedCount);
150 tryCompare(mainMenu, "count", data.expectedCount);
tests/qmltests/Panel/tst_IndicatorsBar.qml+7−6
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -121,7 +121,7 @@ IndicatorTest {
121
121
122 // Rough check that expanding a selected item keeps it within the area of the original item.
122 // Rough check that expanding a selected item keeps it within the area of the original item.
123 function test_expandSelectedItem(data) {
123 function test_expandSelectedItem(data) {
124− var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[data.index]["identifier"]+"-panelItem");
124+ var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[data.index]["identifier"] + "-panelItem");
125 verify(dataItem !== null);
125 verify(dataItem !== null);
126
126
127 var mappedPosition = indicatorsBar.mapFromItem(dataItem, dataItem.width/2, dataItem.height/2);
127 var mappedPosition = indicatorsBar.mapFromItem(dataItem, dataItem.width/2, dataItem.height/2);
@@ -133,15 +133,16 @@ IndicatorTest {
133 var mappedRect = indicatorsBar.mapFromItem(dataItem, 0, 0, dataItem.width, dataItem.height);
133 var mappedRect = indicatorsBar.mapFromItem(dataItem, 0, 0, dataItem.width, dataItem.height);
134
134
135 // mappedPosition contained within mappedRect
135 // mappedPosition contained within mappedRect
136− verify(mappedRect.x <= mappedPosition.x)
136+ verify(mappedRect.x <= mappedPosition.x);
137− verify(mappedRect.x + mappedRect.width >= mappedPosition.x)
137+ verify(mappedRect.x + mappedRect.width >= mappedPosition.x);
138 }
138 }
139
139
140 function test_scrollOffset() {
140 function test_scrollOffset() {
141 indicatorsBar.expanded = true;
141 indicatorsBar.expanded = true;
142 wait_for_expansion_to_settle();
142 wait_for_expansion_to_settle();
143
143
144+ var lastItemIndex = indicatorsModel.originalModelData.length-1;
144− var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[indicatorsModel.originalModelData.length-1]["identifier"]+"-panelItem");
145+ var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[lastItemIndex]["identifier"] + "-panelItem");
145 verify(dataItem !== null);
146 verify(dataItem !== null);
146
147
147 var row = findChild(indicatorsBar, "indicatorItemRow");
148 var row = findChild(indicatorsBar, "indicatorItemRow");
@@ -166,7 +167,7 @@ IndicatorTest {
166 indicatorsBar.expanded = true;
167 indicatorsBar.expanded = true;
167 wait_for_expansion_to_settle();
168 wait_for_expansion_to_settle();
168
169
169− var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[data.index]["identifier"]+"-panelItem");
170+ var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[data.index]["identifier"] + "-panelItem");
170 if (indicatorsBar.mapFromItem(dataItem, dataItem.width/2, dataItem.height/2).x < 0) {
171 if (indicatorsBar.mapFromItem(dataItem, dataItem.width/2, dataItem.height/2).x < 0) {
171 skip("Out of bounds");
172 skip("Out of bounds");
172 }
173 }
tests/qmltests/Panel/tst_IndicatorsMenu.qml+4−5
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -103,7 +103,7 @@ IndicatorTest {
103 }
103 }
104
104
105 function get_indicator_item(index) {
105 function get_indicator_item(index) {
106− var indicatorItem = findChild(indicatorsMenu, indicatorsModel.originalModelData[index]["identifier"]+"-panelItem");
106+ var indicatorItem = findChild(indicatorsMenu, indicatorsModel.originalModelData[index]["identifier"] + "-panelItem");
107 verify(indicatorItem !== null);
107 verify(indicatorItem !== null);
108
108
109 return indicatorItem;
109 return indicatorItem;
@@ -163,14 +163,13 @@ IndicatorTest {
163 // tests swiping on an indicator item activates the correct item.
163 // tests swiping on an indicator item activates the correct item.
164 function test_swipeForCurrentItem()
164 function test_swipeForCurrentItem()
165 {
165 {
166− var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow")
166+ var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow");
167 verify(indicatorItemRow !== null);
167 verify(indicatorItemRow !== null);
168
168
169 for (var i = 0; i < indicatorsModel.originalModelData.length; i++) {
169 for (var i = 0; i < indicatorsModel.originalModelData.length; i++) {
170 var indicatorItem = get_indicator_item(i);
170 var indicatorItem = get_indicator_item(i);
171
171
172− var mappedPosition = root.mapFromItem(indicatorItem,
172+ var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width/2, indicatorItem.height/2);
173− indicatorItem.width/2, indicatorItem.height/2);
174
173
175 touchFlick(indicatorsMenu,
174 touchFlick(indicatorsMenu,
176 mappedPosition.x, mappedPosition.y,
175 mappedPosition.x, mappedPosition.y,
tests/qmltests/Panel/tst_MenuContent.qml+1−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
tests/qmltests/Panel/tst_Panel.qml+1−1
@@ -1,5 +1,5 @@
1/*
1/*
2− * Copyright 2013 Canonical Ltd.
2+ * Copyright 2013-2014 Canonical Ltd.
3 *
3 *
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by