on xenial help sign in
Make Panel use DragHandles instead of a Revealer
6793897Daniel d'Andrada
Panel/Indicators.qml+102−26
@@ -16,32 +16,46 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Ubuntu.Gestures 0.1
19import Ubuntu.ChewieUI 0.1 as ChewieUI
20import Ubuntu.ChewieUI 0.1 as ChewieUI
20
21
21import "../Components"
22import "../Components"
23+import "../Components/ListItems"
22import "../Components/Math.js" as MathLocal
24import "../Components/Math.js" as MathLocal
23
25
24Showable {
26Showable {
25 id: indicators
27 id: indicators
26
28
27− property int progress: panelHeight
28 property int openedHeight: units.gu(71)
29 property int openedHeight: units.gu(71)
29 property int panelHeight: units.gu(3)
30 property int panelHeight: units.gu(3)
30 property bool pinnedMode: true //should be set true if indicators menu can cover whole screen
31 property bool pinnedMode: true //should be set true if indicators menu can cover whole screen
31
32
32 property int hintValue
33 property int hintValue
33− readonly property int lockThreshold: shell.height/2
34+ readonly property int lockThreshold: openedHeight / 2
34− property bool fullyOpened: revealer ? progress == revealer.openedValue : false
35+ property bool fullyOpened: pinnedMode ? height == openedHeight - panelHeight
35− property bool partiallyOpened: revealer ? progress > revealer.closedValue && progress < revealer.openedValue : false
36+ : height == openedHeight
37+ property bool partiallyOpened: height > panelHeight && !fullyOpened
38+
39+ showAnimation: StandardAnimation {
40+ property: "height"
41+ duration: 350
42+ to: pinnedMode ? openedHeight - panelHeight : openedHeight
43+ easing.type: Easing.OutCubic
44+ }
36
45
37− property Revealer revealer: null
46+ hideAnimation: StandardAnimation {
47+ property: "height"
48+ duration: 350
49+ to: panelHeight
50+ easing.type: Easing.OutCubic
51+ }
38
52
39− height: menuContent.height + handle.height + menuContent.y
53+ height: panelHeight
40
54
41− onProgressChanged: {
55+ onHeightChanged: {
42− // need to use handle.get_height(). As the handle height depends on progress changes (but this is called first!)
56+ // need to use handle.get_height(). As the handle height depends on indicators.height changes (but this is called first!)
43− var contentProgress = progress - handle.get_height()
57+ var contentProgress = indicators.height - handle.get_height()
44− if (!showAnimation.running && !hideAnimation.running && !revealer.hintingAnimation.running) {
58+ if (!showAnimation.running && !hideAnimation.running /*&& !revealer.hintingAnimation.running*/) {
45 if (contentProgress <= hintValue && indicators.state == "reveal") {
59 if (contentProgress <= hintValue && indicators.state == "reveal") {
46 indicators.state = "hint"
60 indicators.state = "hint"
47 menuContent.hideAll()
61 menuContent.hideAll()
@@ -66,12 +80,6 @@ Showable {
66 }
80 }
67 }
81 }
68
82
69− function handlePress() {
70− menuContent.hideAll()
71− menuContent.activateContent()
72− indicators.state = "hint"
73− }
74−
75 function openOverview() {
83 function openOverview() {
76 indicatorRow.currentItem = null
84 indicatorRow.currentItem = null
77 menuContent.showOverview()
85 menuContent.showOverview()
@@ -91,7 +99,9 @@ Showable {
91 If bar is dragged down a distance greater than or equal to lockThreshold, this is 1.
99 If bar is dragged down a distance greater than or equal to lockThreshold, this is 1.
92 Otherwise it contains the bar's location as a fraction of the distance between hintValue (is 0) and lockThreshold (is 1).
100 Otherwise it contains the bar's location as a fraction of the distance between hintValue (is 0) and lockThreshold (is 1).
93 */
101 */
102+ var verticalProgress =
94− var verticalProgress = MathLocal.clamp((indicators.progress - handle.height - hintValue) / (lockThreshold - hintValue), 0, 1)
103+ MathLocal.clamp((indicators.height - handle.height - hintValue) /
104+ (lockThreshold - hintValue), 0, 1)
95
105
96 /*
106 /*
97 Percentage of an indicator icon's width the user's press can stray horizontally from the
107 Percentage of an indicator icon's width the user's press can stray horizontally from the
@@ -139,6 +149,17 @@ Showable {
139 }
149 }
140 }
150 }
141
151
152+ VerticalThinDivider {
153+ anchors {
154+ top: indicators.top
155+ topMargin: panelHeight
156+ bottom: handle.bottom
157+ right: indicators.left
158+ }
159+ width: units.dp(2)
160+ source: "graphics/VerticalDivider.png"
161+ }
162+
142 MenuContent {
163 MenuContent {
143 id: menuContent
164 id: menuContent
144 objectName: "menuContent"
165 objectName: "menuContent"
@@ -147,8 +168,8 @@ Showable {
147 left: parent.left
168 left: parent.left
148 right: parent.right
169 right: parent.right
149 top: indicatorRow.bottom
170 top: indicatorRow.bottom
171+ bottom: parent.bottom
150 }
172 }
151− height: progress - y
152 indicatorsModel: indicatorsModel
173 indicatorsModel: indicatorsModel
153 animate: false
174 animate: false
154 clip: indicators.partiallyOpened
175 clip: indicators.partiallyOpened
@@ -187,7 +208,7 @@ Showable {
187 clip: height < handleImage.height
208 clip: height < handleImage.height
188
209
189 function get_height() {
210 function get_height() {
190− return Math.max(Math.min(handleImage.height, progress - handleImage.height), 0)
211+ return Math.max(Math.min(handleImage.height, indicators.height - handleImage.height), 0)
191 }
212 }
192
213
193 BorderImage {
214 BorderImage {
@@ -205,6 +226,29 @@ Showable {
205 }
226 }
206 }
227 }
207
228
229+ PanelSeparatorLine {
230+ id: indicatorsSeparatorLine
231+ visible: true
232+ anchors {
233+ top: handle.bottom
234+ left: indicators.left
235+ right: indicators.right
236+ }
237+ }
238+
239+ BorderImage {
240+ id: dropShadow
241+ anchors {
242+ top: indicators.top
243+ bottom: indicatorsSeparatorLine.bottom
244+ left: indicators.left
245+ right: indicators.right
246+ margins: -units.gu(1)
247+ }
248+ visible: indicators.height > panelHeight
249+ source: "graphics/rectangular_dropshadow.sci"
250+ }
251+
208 PanelBackground {
252 PanelBackground {
209 anchors.fill: indicatorRow
253 anchors.fill: indicatorRow
210 }
254 }
@@ -249,7 +293,7 @@ Showable {
249 openOverview()
293 openOverview()
250 }
294 }
251 else {
295 else {
252− indicators.calculateCurrentItem(revealer.lateralPosition, false)
296+ indicators.calculateCurrentItem(dragHandle.touchX, false)
253 menuContent.showMenu()
297 menuContent.showMenu()
254 }
298 }
255 indicators.state = "commit"
299 indicators.state = "commit"
@@ -258,10 +302,10 @@ Showable {
258 }
302 }
259
303
260 Connections {
304 Connections {
261− target: revealer
305+ target: dragHandle
262− onLateralPositionChanged: {
306+ onTouchXChanged: {
263− var buffer = revealer.dragging ? true : false
307+ var buffer = dragHandle.dragging ? true : false
264− indicators.calculateCurrentItem(revealer.lateralPosition, buffer)
308+ indicators.calculateCurrentItem(dragHandle.touchX, buffer)
265 }
309 }
266 }
310 }
267
311
@@ -277,6 +321,38 @@ Showable {
277 state = last_state;
321 state = last_state;
278 }
322 }
279
323
324+ property var dragHandle: showDragHandle.dragging ? showDragHandle : hideDragHandle
325+ DragHandle {
326+ id: showDragHandle
327+ anchors.bottom: parent.bottom
328+ // go beyond parent so that it stays reachable, at the top of the screen.
329+ anchors.bottomMargin: pinnedMode ? 0 : -panelHeight
330+ anchors.left: parent.left
331+ anchors.right: parent.right
332+ height: panelHeight
333+ direction: Direction.Downwards
334+ enabled: !indicators.shown
335+ hintDisplacement: pinnedMode ? indicators.hintValue : 0
336+ autoCompleteDragThreshold: maxTotalDragDistance / 2
337+ stretch: true
338+ maxTotalDragDistance:
339+ pinnedMode ? openedHeight - panelHeight - handle.height
340+ : openedHeight - handle.height
341+ distanceThreshold: pinnedMode ? 0 : units.gu(3)
342+ }
343+ DragHandle {
344+ id: hideDragHandle
345+ anchors.fill: handle
346+ height: panelHeight
347+ direction: Direction.Upwards
348+ enabled: indicators.shown
349+ hintDisplacement: units.gu(2)
350+ autoCompleteDragThreshold: maxTotalDragDistance / 6
351+ stretch: true
352+ maxTotalDragDistance: openedHeight - 2*panelHeight
353+ distanceThreshold: 0
354+ }
355+
280 property list<State> offScreenModeStates: [
356 property list<State> offScreenModeStates: [
281 State {
357 State {
282 name: "initial"
358 name: "initial"
@@ -289,7 +365,7 @@ Showable {
289 name: "reveal"
365 name: "reveal"
290 extend: "hint"
366 extend: "hint"
291 PropertyChanges { target: menuContent; animate: true }
367 PropertyChanges { target: menuContent; animate: true }
292− StateChangeScript { script: calculateCurrentItem(revealer.lateralPosition, false); }
368+ StateChangeScript { script: calculateCurrentItem(dragHandle.touchX, false); }
293 },
369 },
294 State {
370 State {
295 name: "locked"
371 name: "locked"
@@ -311,7 +387,7 @@ Showable {
311 State {
387 State {
312 name: "reveal"
388 name: "reveal"
313 PropertyChanges { target: menuContent; animate: true }
389 PropertyChanges { target: menuContent; animate: true }
314− StateChangeScript { script: calculateCurrentItem(revealer.lateralPosition, false); }
390+ StateChangeScript { script: calculateCurrentItem(dragHandle.touchX, false); }
315 },
391 },
316 State {
392 State {
317 name: "locked"
393 name: "locked"
Panel/MenuContent.qml+1−1
@@ -99,7 +99,7 @@ Rectangle {
99 onVisibleChanged: {
99 onVisibleChanged: {
100 // Reset the indicator states
100 // Reset the indicator states
101 if (!visible && item) {
101 if (!visible && item) {
102− item.reset()
102+ //item.reset()
103 }
103 }
104 }
104 }
105 asynchronous: true
105 asynchronous: true
Panel/Panel.qml+2−73
@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19import "../Components"
19import "../Components"
20−import "../Components/ListItems"
21
20
22Item {
21Item {
23 id: root
22 id: root
@@ -75,29 +74,6 @@ Item {
75 }
74 }
76 }
75 }
77
76
78− BorderImage {
79− id: dropShadow
80− anchors {
81− top: indicatorsMenu.top
82− bottom: indicatorsSeparatorLine.bottom
83− left: indicatorsMenu.left
84− right: indicatorsMenu.right
85− margins: -units.gu(1)
86− }
87− visible: indicatorsMenu.progress != indicatorRevealer.closedValue
88− source: "graphics/rectangular_dropshadow.sci"
89− }
90−
91− VerticalThinDivider {
92− anchors {
93− top: leftSeparatorLine.top
94− bottom: indicatorsSeparatorLine.top
95− right: indicatorsMenu.left
96− }
97− width: units.dp(2)
98− source: "graphics/VerticalDivider.png"
99− }
100−
101 Indicators {
77 Indicators {
102 id: indicatorsMenu
78 id: indicatorsMenu
103
79
@@ -105,58 +81,13 @@ Item {
105 y: 0
81 y: 0
106 width: root.indicatorsMenuWidth
82 width: root.indicatorsMenuWidth
107 shown: false
83 shown: false
108− revealer: indicatorRevealer
84+ hintValue: __panelMinusSeparatorLineHeight * 3
109− hintValue: indicatorRevealer.hintDisplacement
110 panelHeight: __panelMinusSeparatorLineHeight
85 panelHeight: __panelMinusSeparatorLineHeight
111− showAnimation: StandardAnimation { property: "progress"; duration: 350; to: indicatorRevealer.openedValue; easing.type: Easing.OutCubic }
112− hideAnimation: StandardAnimation { property: "progress"; duration: 350; to: indicatorRevealer.closedValue; easing.type: Easing.OutCubic }
113 openedHeight: parent.height
86 openedHeight: parent.height
114
87
115 pinnedMode: !fullscreenMode
88 pinnedMode: !fullscreenMode
116
89
117− property real unitProgress: (indicatorRevealer.closedValue - progress) / (indicatorRevealer.closedValue - indicatorRevealer.openedValue)
90+ property real unitProgress: height / parent.height
118− }
119−
120− PanelSeparatorLine {
121− id: indicatorsSeparatorLine
122− anchors {
123− top: indicatorsMenu.bottom
124− left: indicatorsMenu.left
125− right: parent.right
126− }
127− }
128−
129− Revealer {
130− id: indicatorRevealer
131− objectName: "indicatorRevealer"
132−
133− width: root.indicatorsMenuWidth
134− anchors {
135− top: parent.top
136− bottom: parent.bottom
137− right: parent.right
138− }
139− target: indicatorsMenu
140− handleSize: __panelMinusSeparatorLineHeight
141− closedValue: __panelMinusSeparatorLineHeight
142− dragVelocityThreshold: units.dp(1)
143− boundProperty: "progress"
144− hintDisplacement: __panelMinusSeparatorLineHeight * 3
145− openOnPress: !fullscreenMode
146− orientation: Qt.Vertical
147−
148− onOpenClicked: {
149− indicatorsMenu.openOverview();
150− indicatorsMenu.show();
151− }
152− onCloseClicked: indicatorsMenu.hide();
153−
154− onOpenPressed: indicatorsMenu.handlePress()
155−
156− function dragToValue(dragPosition) {
157− var offset = target.shown ? 0 : -hintDisplacement + handleSize;
158− return dragPosition + offset;
159− }
160 }
91 }
161
92
162 SearchIndicator {
93 SearchIndicator {
@@ -192,13 +123,11 @@ Item {
192 name: "in" //fully opaque and visible at top edge of screen
123 name: "in" //fully opaque and visible at top edge of screen
193 when: !fullscreenMode
124 when: !fullscreenMode
194 PropertyChanges { target: panelBackground; y: 0 }
125 PropertyChanges { target: panelBackground; y: 0 }
195− PropertyChanges { target: indicatorRevealer; openedValue: indicatorsMenu.openedHeight - panelHeight }
196 },
126 },
197 State {
127 State {
198 name: "out" //pushed off screen
128 name: "out" //pushed off screen
199 when: fullscreenMode
129 when: fullscreenMode
200 PropertyChanges { target: panelBackground; y: -panelHeight }
130 PropertyChanges { target: panelBackground; y: -panelHeight }
201− PropertyChanges { target: indicatorRevealer; openedValue: indicatorsMenu.openedHeight }
202 }
131 }
203 ]
132 ]
204}
133}
Shell.qml+2
@@ -365,6 +365,8 @@ FocusScope {
365 height: parent.height - panel.panelHeight
365 height: parent.height - panel.panelHeight
366 background: shell.background
366 background: shell.background
367
367
368+ property real showAnimationProgress: MathLocal.clamp(1 + x / width, 0, 1)
369+
368 onUnlocked: lockscreen.hide()
370 onUnlocked: lockscreen.hide()
369 onCancel: greeter.show()
371 onCancel: greeter.show()
370
372
tests/qmltests/CMakeLists.txt+2−2
@@ -60,10 +60,10 @@ add_qml_test(Hud Result)
60add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
60add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
61add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
61add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
62add_qml_test(Panel IndicatorRow)
62add_qml_test(Panel IndicatorRow)
63−add_qml_test(Panel Indicators)
63+add_qml_test(Panel Indicators IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
64add_qml_test(Panel MenuContent)
64add_qml_test(Panel MenuContent)
65add_qml_test(Panel Overview)
65add_qml_test(Panel Overview)
66−add_qml_test(Panel Panel)
66+add_qml_test(Panel Panel IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
67add_qml_test(Panel SearchIndicator)
67add_qml_test(Panel SearchIndicator)
68add_qml_test(Panel/Menus IndicatorMenuWindow IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS})
68add_qml_test(Panel/Menus IndicatorMenuWindow IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS})
69add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
69add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
tests/qmltests/Panel/tst_Indicators.qml+34−45
@@ -42,23 +42,9 @@ Item {
42 }
42 }
43 width: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
43 width: (shell.width > units.gu(60)) ? units.gu(40) : shell.width
44 y: 0
44 y: 0
45− hintValue: indicatorRevealer.hintDisplacement
46 shown: false
45 shown: false
47− revealer: indicatorRevealer
48
46
49 openedHeight: parent.height - click_me.height
47 openedHeight: parent.height - click_me.height
50−
51− showAnimation: NumberAnimation { property: "progress"; duration: 350; to: indicatorRevealer.openedValue; easing.type: Easing.OutCubic }
52− hideAnimation: NumberAnimation { property: "progress"; duration: 350; to: indicatorRevealer.closedValue; easing.type: Easing.OutCubic }
53− }
54−
55− Revealer {
56− anchors.fill: indicators
57− id: indicatorRevealer
58− hintDisplacement: indicators.panelHeight * 3
59−
60− openedValue: indicators.openedHeight - indicators.panelHeight
61− closedValue: indicators.panelHeight
62 }
48 }
63
49
64 // Just a rect for clicking to open the indicators.
50 // Just a rect for clicking to open the indicators.
@@ -153,60 +139,63 @@ Item {
153 {
139 {
154 // tests changing the lateral position of the revealer activates the correct indicator items.
140 // tests changing the lateral position of the revealer activates the correct indicator items.
155
141
156− // This "should" put the indicators in "hint" state
157− indicators.progress = indicators.hintValue;
158−
159 var indicator_row = findChild(indicators, "indicatorRow")
142 var indicator_row = findChild(indicators, "indicatorRow")
160 var row_repeater = findChild(indicators, "rowRepeater")
143 var row_repeater = findChild(indicators, "rowRepeater")
161
144
162 for (var i = 0; i < row_repeater.count; i++) {
145 for (var i = 0; i < row_repeater.count; i++) {
163 var indicator_item = row_repeater.itemAt(i);
146 var indicator_item = row_repeater.itemAt(i);
164
147
165− var indicator_position = indicator_row.row.x + indicator_item.x + indicator_item.width/2;
148+ var indicator_position = indicators.mapFromItem(indicator_item,
149+ indicator_item.width/2, indicator_item.height/2)
166
150
151+ touchFlick(indicators,
167− indicatorRevealer.lateralPosition = indicator_position;
152+ indicator_position.x, indicator_position.y,
153+ indicator_position.x, indicators.openedHeight * 0.4,
154+ true /* beginTouch */, false /* endTouch */)
168
155
169− compare(indicator_row.currentItem, indicator_item, "Incorrect item activated at position " + i);
156+ compare(indicator_row.currentItem, indicator_item,
157+ "Incorrect item activated at position " + i);
158+
159+ touchFlick(indicators,
160+ indicator_position.x, indicators.openedHeight * 0.4,
161+ indicator_position.x, indicator_position.y,
162+ false /* beginTouch */, true /* endTouch */)
163+
164+ // wait until fully closed
165+ tryCompare(indicators, "height", indicators.panelHeight)
170 }
166 }
171 }
167 }
172
168
173− // PROGRESS TESTS
174−
175− // values for specific state changes are subject to internal decisions, so we can't determine the true progress value
169+ // values for specific state changes are subject to internal decisions, so we can't
176− // which would cause the state to change without making too many assuptyions
170+ // determine the true height value which would cause the state to change without making
171+ // too many assuptyions
177− // However, we can assume that a partially opened panel will not be initial, and fully opened panel will be locked.
172+ // However, we can assume that a partially opened panel will not be initial, and fully
173+ // opened panel will be locked.
178
174
179 function test_progress_changes_state_to_not_initial() {
175 function test_progress_changes_state_to_not_initial() {
180− indicators.progress = indicatorRevealer.closedValue + (indicatorRevealer.openedValue - indicatorRevealer.closedValue)/2;
176+ indicators.height = indicators.openedHeight / 2
177+ compare(indicators.state!="initial", true,
181− compare(indicators.state!="initial", true, "Indicators should not be in initial state when partially opened.");
178+ "Indicators should not be in initial state when partially opened.")
182 }
179 }
183
180
184 function test_progress_changes_state_to_locked() {
181 function test_progress_changes_state_to_locked() {
185− indicators.progress = indicators.openedHeight;
182+ indicators.height = indicators.openedHeight - indicators.panelHeight
186− compare(indicators.state, "locked", "Indicators should be locked when fully opened.");
183+ compare(indicators.state, "locked", "Indicators should be locked when fully opened.")
187 }
184 }
188
185
189 function test_partially_open() {
186 function test_partially_open() {
190− indicators.progress = indicatorRevealer.closedValue + (indicatorRevealer.openedValue - indicatorRevealer.closedValue)/2;
187+ indicators.height = indicators.openedHeight / 2
191− compare(indicators.partiallyOpened, true, "Indicator should show as partially opened when in between revealer closedValue & openedValue height");
188+ compare(indicators.partiallyOpened, true,
189+ "Indicator should show as partially opened when height is half of openedHeight")
192− compare(indicators.fullyOpened, false, "Indicator should not show as fully opened when in between revealer closedValue & openedValue height");
190+ compare(indicators.fullyOpened, false,
191+ "Indicator should not show as fully opened when height is half of openedHeight")
193 }
192 }
194
193
195 function test_fully_open() {
194 function test_fully_open() {
196− indicators.progress = indicatorRevealer.openedValue
195+ indicators.height = indicators.openedHeight - indicators.panelHeight
197− compare(indicators.partiallyOpened, false, "Indicator should show as fully opened when in between revealer closedValue & openedValue height");
196+ compare(indicators.partiallyOpened, false);
198− compare(indicators.fullyOpened, true, "Indicator should not show as fully opened when at revealer openedValue height");
197+ compare(indicators.fullyOpened, true);
199 }
198 }
200
199
201− // The indicator menu content should be shown if the indicators are show through an animation before they
202− // enter a furthur state through a progress change (eg press indicator row, drag down a less then hint
203− // threshold and release to show
204− function test_menu_open_on_hint_drag() {
205− indicators.handlePress();
206− indicators.show()
207−
208− var menuContent = findChild(indicators, "menuContent")
209− compare(menuContent.__shown, true, "Indicator menu content should be shown after a indicator show.");
210− }
211 }
200 }
212}
201}
tests/qmltests/Panel/tst_Panel.qml+65−113
@@ -78,92 +78,56 @@ Item {
78 return panel.mapFromItem(indicator_item, indicator_item.width/2, indicator_item.height/2);
78 return panel.mapFromItem(indicator_item, indicator_item.width/2, indicator_item.height/2);
79 }
79 }
80
80
81− function test_hint_data() { return get_window_data() }
82−
83 // Pressing on the indicator panel should activate the indicator hints
81 // Pressing on the indicator panel should activate the indicator hints
84 // and expose a portion of the conent.
82 // and expose a portion of the conent.
85− function test_hint(data) {
83+ function test_hint() {
86− panel.fullscreenMode = data.fullscreenFlag;
84+ panel.fullscreenMode = false;
87−
85+ // Wait for the indicators to get into position.
88− var indicator_item_coord = get_indicator_item_position(0);
86+ // (switches between normal and fullscreen modes are animated)
89− var indicator_revealer = findChild(panel, "indicatorRevealer");
87+ tryCompare(panel.indicators, "y", 0)
90− verify(indicator_revealer != undefined)
91−
92− mousePress(panel,
93− indicator_item_coord.x, panel.panelHeight/2,
94− Qt.LeftButton, Qt.NoModifier , 0);
95−
96− if (!panel.fullscreenMode)
97− {
98− compare(indicator_revealer.hintingAnimation.running, true, "Indicator revealer hint animation should be running after mouse press on indicator panel in pinned mode");
99− tryCompare(indicator_revealer.hintingAnimation, "running", false);
100− tryCompare(panel.indicators, "partiallyOpened", true);
101− }
102− else
103− {
104− // nothing should happen
105− compare(indicator_revealer.hintingAnimation.running, false, "Indicator revealer hint animation should not be running after mouse press on indicator panel in fullscreen mode");
106− compare(panel.indicators.partiallyOpened, false, "Indicator should not be partially opened when panel is pressed in fullscreenmode");
107− compare(panel.indicators.fullyOpened, false, "Indicator should not be partially opened when panel is pressed in fullscreenmode");
108− }
109−
110− mouseRelease(panel,
111− indicator_item_coord.x, panel.panelHeight/2,
112− Qt.LeftButton, Qt.NoModifier , 0);
113− }
114−
115− function test_show_click_data() { return get_window_data() }
116−
117− // Clicking the indicator panel should fully open the inidicators
118− function test_show_click(data) {
119− panel.fullscreenMode = data.fullscreenFlag;
120
88
121 var indicator_item_coord = get_indicator_item_position(0);
89 var indicator_item_coord = get_indicator_item_position(0);
122
90
123− mouseClick(panel,
124− indicator_item_coord.x, panel.panelHeight/2,
91+ touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2)
125− Qt.LeftButton, Qt.NoModifier , 0);
126
92
127− if (!panel.fullscreenMode)
93+ // hint animation should be run, meaning that indicators will move downwards
128− {
94+ // by hintValue pixels without any drag taking place
129− compare(panel.indicators.showAnimation.running, true, "Show animation should run after panel is clicked in pinned mode.");
95+ tryCompare(panel.indicators, "height",
96+ panel.indicators.panelHeight + panel.indicators.hintValue);
97+ tryCompare(panel.indicators, "partiallyOpened", true);
130− tryCompare(panel.indicators, "fullyOpened", true);
98+ tryCompare(panel.indicators, "fullyOpened", false);
131
99
132− // click will activate device overview.
100+ touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2)
133− compare(findChild(panel.indicators, "indicatorRow").overviewActive, true, "Overview indicator should be avtive when indicators clicked.")
134− }
135− else
136− {
137− compare(panel.indicators.showAnimation.running, false, "Indicators should not open when panel is clicked in pinned mode.");
138− }
139 }
101 }
140
102
141− function test_show_press_release_data() { return get_window_data() }
103+ // Pressing on the top edge of the screen should have no effect if the panel
142−
104+ // is hidden (!pinned), which is the case when a fullscreen app is being shown
143− // Pressing and releasing on the indicator panel will fully open the indicators
105+ function test_noHintOnFullscreenMode() {
144− function test_show_press_release(data) {
145− panel.fullscreenMode = data.fullscreenFlag;
106+ panel.fullscreenMode = true;
107+ // Wait for the indicators to get into position.
108+ // (switches between normal and fullscreen modes are animated)
109+ tryCompare(panel.indicators, "y", -panel.panelHeight)
146
110
147 var indicator_item_coord = get_indicator_item_position(0);
111 var indicator_item_coord = get_indicator_item_position(0);
148
112
149− mousePress(panel,
150− indicator_item_coord.x, panel.panelHeight/2,
113+ touchPress(panel, indicator_item_coord.x, panel.panelHeight / 2)
151− Qt.LeftButton, Qt.NoModifier , 0);
152
114
153− mouseRelease(panel,
115+ // Give some time for a hint animation to change things, if any
154− indicator_item_coord.x, panel.panelHeight/2,
116+ wait(500)
155− Qt.LeftButton, Qt.NoModifier , 0);
156
117
157− if (!panel.fullscreenMode)
118+ // no hint animation when fullscreen
158− {
119+ compare(panel.indicators.y, -panel.panelHeight)
159− compare(panel.indicators.showAnimation.running, true, "Show animation should run after panel is clicked in pinned mode.");
120+ var indicatorRow = findChild(panel.indicators, "indicatorRow");
160− tryCompare(panel.indicators, "fullyOpened", true);
121+ verify(indicatorRow != undefined)
161− }
122+ compare(indicatorRow.y, 0)
162− else
123+ compare(panel.indicators.height, panel.indicators.panelHeight)
163− {
124+ compare(panel.indicators.partiallyOpened, false,
164− // nothing should happen.
125+ "Indicator should not be partially opened when panel is pressed in" +
165− compare(panel.indicators.showAnimation.running, false, "Indicators should not open when panel is clicked in pinned mode.");
126+ " fullscreenmode")
166− }
127+ compare(panel.indicators.fullyOpened, false, "Indicator should not be partially" +
128+ " opened when panel is pressed in fullscreenmode")
129+
130+ touchRelease(panel, indicator_item_coord.x, panel.panelHeight/2)
167 }
131 }
168
132
169 function test_drag_show_data() { return get_window_data() }
133 function test_drag_show_data() { return get_window_data() }
@@ -174,9 +138,6 @@ Item {
174 function test_drag_show(data) {
138 function test_drag_show(data) {
175 panel.fullscreenMode = data.fullscreenFlag;
139 panel.fullscreenMode = data.fullscreenFlag;
176
140
177− var indicator_revealer = findChild(panel, "indicatorRevealer");
178− verify(indicator_revealer != undefined)
179−
180 var indicator_row = findChild(panel.indicators, "indicatorRow");
141 var indicator_row = findChild(panel.indicators, "indicatorRow");
181 verify(indicator_row != undefined)
142 verify(indicator_row != undefined)
182
143
@@ -186,6 +147,14 @@ Item {
186 var menu_content = findChild(panel.indicators, "menuContent");
147 var menu_content = findChild(panel.indicators, "menuContent");
187 verify(indicator_row != undefined)
148 verify(indicator_row != undefined)
188
149
150+ // Wait for the indicators to get into position.
151+ // (switches between normal and fullscreen modes are animated)
152+ if (data.fullscreenFlag) {
153+ tryCompare(panel.indicators, "y", -panel.panelHeight)
154+ } else {
155+ tryCompare(panel.indicators, "y", 0)
156+ }
157+
189 // do this for each indicator item
158 // do this for each indicator item
190 for (var i = 0; i < row_repeater.count; i++) {
159 for (var i = 0; i < row_repeater.count; i++) {
191
160
@@ -194,40 +163,25 @@ Item {
194
163
195 var indicator_item_coord = get_indicator_item_position(i);
164 var indicator_item_coord = get_indicator_item_position(i);
196
165
197− // 1) Press on the panel
166+ touchPress(panel,
198− mousePress(panel,
199− indicator_item_coord.x, panel.panelHeight/2,
167+ indicator_item_coord.x, panel.panelHeight / 2)
200− Qt.LeftButton, Qt.NoModifier , 0);
201−
202− if (!panel.fullscreenMode)
203− {
204− // hint animation should be run, and panel will end in partiallyOpened state.
205− compare(indicator_revealer.hintingAnimation.running, true, "Indicator revealer hint animation should be running after mouse press on indicator panel");
206− tryCompare(indicator_revealer.hintingAnimation, "running", false);
207− tryCompare(panel.indicators, "partiallyOpened", true);
208− }
209−
210− // 2) Drag the mouse down
211− var old_progress = panel.indicators.progress
212− mouseMove(panel,
213− indicator_item_coord.x, old_progress + (panel.height - old_progress)/2,
214− 0, Qt.LeftButton);
215−
216− // progress should increase.
217− var progress_increases = panel.indicators.progress > old_progress;
218− compare(progress_increases, true, "Progress has not increased on dragging indicator.");
219
168
220− mouseMove(panel,
169+ // 1) Drag the mouse down
170+ touchFlick(panel,
221− indicator_item_coord.x, shell.y + shell.height,
171+ indicator_item_coord.x, panel.panelHeight / 2,
222− 0, Qt.LeftButton);
172+ indicator_item_coord.x, panel.height * 0.8,
173+ false /* beginTouch */, false /* endTouch */)
223
174
224− tryCompare(panel.indicators, "fullyOpened", true);
175+ // Indicators height should follow the drag, and therefore increase accordingly.
176+ // They should be at least half-way through the screen
177+ tryCompareFunction(
178+ function() {return panel.indicators.height >= panel.height * 0.5},
179+ true)
225
180
226− mouseRelease(panel,
227− indicator_item_coord.x, indicator_item_coord.y + panel.height/2,
181+ touchRelease(panel, indicator_item_coord.x, panel.height * 0.8)
228− Qt.LeftButton, Qt.NoModifier , 0);
229
182
230− compare(indicator_row.currentItem, indicator_item, "Incorrect item activated at position " + i);
183+ compare(indicator_row.currentItem, indicator_item,
184+ "Incorrect item activated at position " + i)
231 compare(menu_content.__shown, true, "Menu conetent should be enabled for item at position " + i);
185 compare(menu_content.__shown, true, "Menu conetent should be enabled for item at position " + i);
232
186
233 // init for next indicator_item
187 // init for next indicator_item
@@ -242,11 +196,10 @@ Item {
242 var search_indicator = findChild(panel, "search");
196 var search_indicator = findChild(panel, "search");
243 verify(search_indicator != undefined);
197 verify(search_indicator != undefined);
244
198
245− mouseClick(search_indicator,
199+ tap(search_indicator, 1, 1)
246− 1, 1,
247− Qt.LeftButton, Qt.NoModifier , 0);
248
200
201+ compare(search_clicked, true,
249− compare(search_clicked, true, "Clicking search indicator while it was enabled did not emit searchClicked signal")
202+ "Tapping search indicator while it was enabled did not emit searchClicked signal")
250 }
203 }
251
204
252 function test_search_click_when_not_visible() {
205 function test_search_click_when_not_visible() {
@@ -256,11 +209,10 @@ Item {
256 var search_indicator = findChild(panel, "search");
209 var search_indicator = findChild(panel, "search");
257 verify(search_indicator != undefined);
210 verify(search_indicator != undefined);
258
211
259− mouseClick(search_indicator,
212+ tap(search_indicator, 1, 1)
260− 1, 1,
261− Qt.LeftButton, Qt.NoModifier , 0);
262
213
214+ compare(search_clicked, false,
263− compare(search_clicked, false, "Clicking search indicator while it was not visible emitted searchClicked signal")
215+ "Tapping search indicator while it was not visible emitted searchClicked signal")
264 }
216 }
265 }
217 }
266}
218}