on xenial help sign in
fix cancelling kbd navigation if the launcher is locked out
commit3cf7a865affbe7193d20b431c987fac3edd70076 authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 14 Jan 2016, 18:49 (11 years ago) parentf52f718
3 files changed+29−13
qml/Launcher/Launcher.qml+4−2 qml/Launcher/LauncherPanel.qml+7−3 tests/qmltests/Launcher/tst_Launcher.qml+18−8
qml/Launcher/Launcher.qml+4−2
@@ -30,7 +30,7 @@ FocusScope {
3030 property alias inverted: panel.inverted
3131 property bool shadeBackground: true // can be used to disable background shade when launcher is visible
3232
33− property int panelWidth: units.gu(8)
33+ property int panelWidth: units.gu(10)
3434 property int dragAreaWidth: units.gu(1)
3535 property int minimizeDistance: units.gu(26)
3636 property real progress: dragArea.dragging && dragArea.touchX > panelWidth ?
@@ -312,9 +312,10 @@ FocusScope {
312312 InverseMouseArea {
313313 id: closeMouseArea
314314 anchors.fill: panel
315− enabled: root.shadeBackground && root.state == "visible" && !root.lockedVisible
315+ enabled: root.shadeBackground && root.state == "visible" && (!root.lockedVisible || panel.highlightIndex >= -1)
316316 visible: enabled
317317 onPressed: {
318+ panel.highlightIndex = -2
318319 root.hide();
319320 }
320321 }
@@ -381,6 +382,7 @@ FocusScope {
381382 }
382383
383384 onKbdNavigationCancelled: {
385+ panel.highlightIndex = -2;
384386 root.hide();
385387 root.focus = false;
386388 }
qml/Launcher/LauncherPanel.qml+7−3
@@ -664,7 +664,6 @@ Rectangle {
664664 onClicked: {
665665 quickList.state = "";
666666 quickList.focus = false;
667− root.highlightIndex = -2;
668667 root.kbdNavigationCancelled();
669668 }
670669
@@ -735,16 +734,21 @@ Rectangle {
735734 case Qt.Key_Left:
736735 case Qt.Key_Escape:
737736 quickList.selectedIndex = -1;
738− // Falling through intentionally
737+ quickList.focus = false;
738+ quickList.state = ""
739+ event.accepted = true;
740+ break;
739741 case Qt.Key_Enter:
740742 case Qt.Key_Return:
741743 case Qt.Key_Space:
742744 if (quickList.selectedIndex >= 0) {
743745 LauncherModel.quickListActionInvoked(quickList.appId, quickList.selectedIndex)
744746 }
747+ quickList.selectedIndex = -1;
745748 quickList.focus = false;
746749 quickList.state = ""
747− // Don't consume the event. We want to close the Launcher too, not just the quicklist.
750+ root.kbdNavigationCancelled();
751+ event.accepted = true;
748752 break;
749753 }
750754 }
tests/qmltests/Launcher/tst_Launcher.qml+18−8
@@ -303,10 +303,10 @@ Item {
303303 var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
304304
305305 waitForRendering(launcher);
306− tryCompare(bfbFocusHighlight, "visible", index === -1);
306+ compare(bfbFocusHighlight.visible, index === -1);
307307 for (var i = 0; i < launcherListView.count; i++) {
308308 var focusRing = findChild(findChild(launcher, "launcherDelegate" + i), "focusRing")
309− tryCompare(focusRing, "visible", index === i);
309+ compare(focusRing.visible, index === i);
310310 }
311311 }
312312
@@ -411,6 +411,7 @@ Item {
411411 wait(100)
412412 compare(launcher.maxPanelX, -launcher.panelWidth, "Launcher moved even if it shouldn't")
413413 }
414+
414415 waitUntilLauncherDisappears();
415416 launcher.available = true;
416417 }
@@ -1097,12 +1098,15 @@ Item {
10971098 function test_keyboardNavigation() {
10981099 var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
10991100 var quickList = findChild(launcher, "quickList");
1101+ var launcherPanel = findChild(launcher, "launcherPanel");
11001102 var launcherListView = findChild(launcher, "launcherListView");
11011103 var last = launcherListView.count - 1;
11021104
11031105 compare(bfbFocusHighlight.visible, false);
11041106
11051107 launcher.openForKeyboardNavigation();
1108+ tryCompare(launcherPanel, "x", 0);
1109+ waitForRendering(launcher);
11061110
11071111 assertFocusOnIndex(-1);
11081112
@@ -1175,6 +1179,7 @@ Item {
11751179 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
11761180 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
11771181 compare(signalSpy.signalArguments[0][1], 2)
1182+ assertFocusOnIndex(-2);
11781183 }
11791184
11801185 function test_hideNotWorkingWhenLockedOut_data() {
@@ -1203,12 +1208,15 @@ Item {
12031208
12041209 function test_cancelKbdNavigationWitMouse_data() {
12051210 return [
1206− {tag: "locked out", autohide: false },
1207− {tag: "autohide", autohide: true },
1211+ {tag: "locked out - no quicklist", autohide: false, withQuickList: false },
1212+ {tag: "locked out - with quicklist", autohide: false, withQuickList: true },
1213+ {tag: "autohide - no quicklist", autohide: true, withQuickList: false },
1214+ {tag: "autohide - with quicklist", autohide: true, withQuickList: true },
12081215 ]
12091216 }
12101217
12111218 function test_cancelKbdNavigationWitMouse(data) {
1219+ launcher.autohideEnabled = data.autohide;
12121220 launcher.openForKeyboardNavigation();
12131221 waitForRendering(launcher);
12141222
@@ -1219,12 +1227,14 @@ Item {
12191227
12201228 keyClick(Qt.Key_Down); // Down to launcher item 0
12211229 keyClick(Qt.Key_Down); // Down to launcher item 1
1222− keyClick(Qt.Key_Right); // Into quicklist
12231230
1231+ if (data.withQuickList) {
1232+ keyClick(Qt.Key_Right); // Into quicklist
1233+ tryCompare(quickList, "visible", true)
1234+ }
12241235 waitForRendering(launcher)
1225− tryCompare(quickList, "visible", true)
12261236
1227− mouseClick(root, root.width / 2, units.gu(2));
1237+ mouseClick(root);
12281238
12291239 if (data.autohide) {
12301240 tryCompare(launcher, "state", "");
@@ -1232,7 +1242,7 @@ Item {
12321242 tryCompare(launcher, "state", "visible");
12331243 }
12341244
1235− tryCompare(launcherPanel, "highlightIndex", -2);
1245+ assertFocusOnIndex(-2);
12361246 }
12371247 }
12381248}