on xenial help sign in
Merge pull request #203 from ubports/xenial_-_edge_-_panel-menu-reject-drags
1d07cc1Marius Gripsgard
qml/Panel/PanelMenu.qml+3−1
@@ -49,6 +49,8 @@ Showable {
49 readonly property int barWidth: adjustDragHandleSizeToContents ? Math.min(bar.width, bar.implicitWidth) : bar.width
49 readonly property int barWidth: adjustDragHandleSizeToContents ? Math.min(bar.width, bar.implicitWidth) : bar.width
50 readonly property alias currentMenuIndex: bar.currentItemIndex
50 readonly property alias currentMenuIndex: bar.currentItemIndex
51
51
52+ // The user tapped the panel and did not move.
53+ // Note that this does not fire on mouse events, only touch events.
52 signal showTapped()
54 signal showTapped()
53
55
54 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
56 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
@@ -242,7 +244,7 @@ Showable {
242 touchPressTime = new Date().getTime();
244 touchPressTime = new Date().getTime();
243 } else {
245 } else {
244 var touchReleaseTime = new Date().getTime();
246 var touchReleaseTime = new Date().getTime();
245− if (touchReleaseTime - touchPressTime <= 300) {
247+ if (touchReleaseTime - touchPressTime <= 300 && distance < units.gu(1)) {
246 root.showTapped();
248 root.showTapped();
247 }
249 }
248 }
250 }
tests/qmltests/Panel/tst_PanelMenu.qml+24
@@ -31,6 +31,12 @@ PanelTest {
31 target: clickThroughTester
31 target: clickThroughTester
32 }
32 }
33
33
34+ SignalSpy {
35+ id: showTappedSpy
36+ target: indicatorsMenu
37+ signalName: "showTapped"
38+ }
39+
34 MouseArea {
40 MouseArea {
35 id: clickThroughTester
41 id: clickThroughTester
36 anchors.fill: root
42 anchors.fill: root
@@ -140,6 +146,7 @@ PanelTest {
140
146
141 function cleanup() {
147 function cleanup() {
142 clickThroughSpy.clear();
148 clickThroughSpy.clear();
149+ showTappedSpy.clear();
143 }
150 }
144
151
145 function get_indicator_item(index) {
152 function get_indicator_item(index) {
@@ -321,5 +328,22 @@ PanelTest {
321 indicatorsMenu.available = true;
328 indicatorsMenu.available = true;
322 indicatorsMenu.hide();
329 indicatorsMenu.hide();
323 }
330 }
331+
332+ // Ensure that showTapped is only signaled when the user hasn't moved
333+ // thir tap point
334+ // Prior to this, the user could press and drag down very fast but
335+ // still call showTapped
336+ function test_showTapped() {
337+ // Get the first indicator
338+ var firstItem = get_indicator_item(0);
339+ var firstItemMappedPosition = indicatorsMenu.mapFromItem(firstItem, firstItem.width/2, firstItem.height/2);
340+
341+ touchFlick(indicatorsMenu,
342+ firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight / 2,
343+ firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 7,
344+ true /* beginTouch */, true /* endTouch */, 100, 2);
345+
346+ verify(showTappedSpy.count === 0);
347+ }
324 }
348 }
325}
349}