on xenial help sign in
merge new prereq
commit016093c2ac9d81ea477466976357fbc5f6bf9ee4 authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 10 Mar 2017, 12:37 (10 years ago) parentcc805e719bfe13
3 files changed+31−11
qml/Launcher/Drawer.qml+4−1 qml/Launcher/Launcher.qml+9−10 tests/qmltests/Launcher/tst_Drawer.qml+18
qml/Launcher/Drawer.qml+4−1
@@ -212,13 +212,16 @@ FocusScope {
212212 root.dragDistance += diff;
213213 oldX = mouseX
214214 }
215− onReleased: {
215+ onReleased: reset();
216+ onCanceled: reset();
217+ function reset() {
216218 if (root.draggingHorizontally) {
217219 root.draggingHorizontally = false;
218220 parent.interactive = true;
219221 }
220222 reactivateTimer.start();
221223 }
224+
222225 Timer {
223226 id: reactivateTimer
224227 interval: 0
qml/Launcher/Launcher.qml+9−10
@@ -116,7 +116,14 @@ FocusScope {
116116 if ((flags & ignoreHideIfMouseOverLauncher) && Utils.Functions.itemUnderMouse(panel)) {
117117 return;
118118 }
119− switchToNextState("")
119+ if (root.lockedVisible) {
120+ // Due to binding updates when switching between modes
121+ // it could happen that our request to show will be overwritten
122+ // with a hide request. Rewrite it when we know hiding is not allowed.
123+ switchToNextState("visible")
124+ } else {
125+ switchToNextState("")
126+ }
120127 }
121128
122129 function fadeOut() {
@@ -255,13 +262,6 @@ FocusScope {
255262 interval: 1
256263 property string nextState: ""
257264 onTriggered: {
258− if (root.lockedVisible && nextState == "") {
259− // Due to binding updates when switching between modes
260− // it could happen that our request to show will be overwritten
261− // with a hide request. Rewrite it when we know hiding is not allowed.
262− nextState = "visible"
263− }
264−
265265 // switching to an intermediate state here to make sure all the
266266 // values are restored, even if we were already in the target state
267267 root.state = "tmp"
@@ -380,8 +380,7 @@ FocusScope {
380380 }
381381
382382 Keys.onEscapePressed: {
383− switchToNextState("");
384− root.focus = false;
383+ root.hide()
385384 }
386385
387386 onDragDistanceChanged: {
tests/qmltests/Launcher/tst_Drawer.qml+18
@@ -332,5 +332,23 @@ StyledItem {
332332 keyClick(Qt.Key_Down);
333333 tryCompare(panel, "highlightIndex", 0);
334334 }
335+
336+ function test_closeWhileDragging() {
337+ launcher.openDrawer(true);
338+ waitForRendering(launcher);
339+ waitUntilTransitionsEnd(launcher);
340+
341+ var drawer = findChild(launcher, "drawer");
342+ tryCompare(drawer.anchors, "rightMargin", -drawer.width);
343+
344+ mousePress(drawer, drawer.width / 2, drawer.height / 2);
345+ mouseMove(drawer, drawer.width / 4, drawer.height / 2);
346+ tryCompare(drawer, "draggingHorizontally", true);
347+
348+ keyPress(Qt.Key_Escape);
349+
350+ tryCompare(launcher, "state", "");
351+ tryCompare(drawer, "draggingHorizontally", false);
352+ }
335353 }
336354}