on xenial help sign in
fix an issue where the highlight might not be removed after launching
4fa59aeMichael Zanetti
qml/Launcher/Launcher.qml+2−1
@@ -162,7 +162,7 @@ FocusScope {
162 event.accepted = true;
162 event.accepted = true;
163 break;
163 break;
164 case Qt.Key_Escape:
164 case Qt.Key_Escape:
165− panel.highlightIndex = -2
165+ panel.highlightIndex = -2;
166 // Falling through intentionally
166 // Falling through intentionally
167 case Qt.Key_Enter:
167 case Qt.Key_Enter:
168 case Qt.Key_Return:
168 case Qt.Key_Return:
@@ -172,6 +172,7 @@ FocusScope {
172 } else if (panel.highlightIndex >= 0) {
172 } else if (panel.highlightIndex >= 0) {
173 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
173 launcherApplicationSelected(LauncherModel.get(panel.highlightIndex).appId);
174 }
174 }
175+ panel.highlightIndex = -2
175 root.state = ""
176 root.state = ""
176 event.accepted = true;
177 event.accepted = true;
177 root.focus = false;
178 root.focus = false;
tests/qmltests/Launcher/tst_Launcher.qml+16−7
@@ -288,14 +288,20 @@ Item {
288 }
288 }
289
289
290 function assertFocusOnIndex(index) {
290 function assertFocusOnIndex(index) {
291+ var launcherPanel = findChild(launcherLoader.item, "launcherPanel");
291− var launcherListView = findChild(launcher, "launcherListView");
292+ var launcherListView = findChild(launcherLoader.item, "launcherListView");
292− var bfbFocusHighlight = findChild(launcher, "bfbFocusHighlight");
293+ var bfbFocusHighlight = findChild(launcherLoader.item, "bfbFocusHighlight");
293−
294− waitForRendering(launcher);
294+ waitForRendering(launcherLoader.item);
295+ tryCompare(launcherPanel, "highlightIndex", index);
295 tryCompare(bfbFocusHighlight, "visible", index === -1);
296 tryCompare(bfbFocusHighlight, "visible", index === -1);
296 for (var i = 0; i < launcherListView.count; i++) {
297 for (var i = 0; i < launcherListView.count; i++) {
297− var focusRing = findChild(findChild(launcher, "launcherDelegate" + i), "focusRing")
298+ var item = findChild(launcher, "launcherDelegate" + i);
299+ // Delegates might be destroyed when not visible. We can't check if they paint a focus highlight.
300+ // Make sure the requested index does have focus. for the others, try best effort to check if they don't
301+ if (index === i || item) {
302+ var focusRing = findChild(item, "focusRing")
298− tryCompare(focusRing, "visible", index === i);
303+ tryCompare(focusRing, "visible", index === i);
304+ }
299 }
305 }
300 }
306 }
301
307
@@ -1090,7 +1096,6 @@ Item {
1090 var last = launcherListView.count - 1;
1096 var last = launcherListView.count - 1;
1091
1097
1092 compare(bfbFocusHighlight.visible, false);
1098 compare(bfbFocusHighlight.visible, false);
1093−
1094 launcher.openForKeyboardNavigation();
1099 launcher.openForKeyboardNavigation();
1095
1100
1096 assertFocusOnIndex(-1);
1101 assertFocusOnIndex(-1);
@@ -1113,6 +1118,7 @@ Item {
1113
1118
1114 // The list should wrap around
1119 // The list should wrap around
1115 keyClick(Qt.Key_Up);
1120 keyClick(Qt.Key_Up);
1121+ waitForRendering(launcher);
1116 assertFocusOnIndex(last);
1122 assertFocusOnIndex(last);
1117
1123
1118 keyClick(Qt.Key_Down);
1124 keyClick(Qt.Key_Down);
@@ -1145,6 +1151,9 @@ Item {
1145 // Go bar to top by wrapping around
1151 // Go bar to top by wrapping around
1146 keyClick(Qt.Key_Down);
1152 keyClick(Qt.Key_Down);
1147 assertFocusOnIndex(1);
1153 assertFocusOnIndex(1);
1154+
1155+ keyClick(Qt.Key_Enter);
1156+ assertFocusOnIndex(-2);
1148 }
1157 }
1149
1158
1150 function test_selectQuicklistItemByKeyboard() {
1159 function test_selectQuicklistItemByKeyboard() {