on xenial help sign in
Tune quicklist selection
604cd88Albert Astals Cid
qml/Launcher/LauncherPanel.qml+22−6
@@ -749,16 +749,18 @@ Rectangle {
749 Keys.onPressed: {
749 Keys.onPressed: {
750 switch (event.key) {
750 switch (event.key) {
751 case Qt.Key_Down:
751 case Qt.Key_Down:
752− selectedIndex++;
752+ var prevIndex = selectedIndex;
753− if (selectedIndex >= popoverRepeater.count) {
753+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
754− selectedIndex = 0;
754+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
755+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
755 }
756 }
756 event.accepted = true;
757 event.accepted = true;
757 break;
758 break;
758 case Qt.Key_Up:
759 case Qt.Key_Up:
759− selectedIndex--;
760+ var prevIndex = selectedIndex;
760− if (selectedIndex < 0) {
761+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
762+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
761− selectedIndex = popoverRepeater.count - 1;
763+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
762 }
764 }
763 event.accepted = true;
765 event.accepted = true;
764 break;
766 break;
@@ -804,6 +806,17 @@ Rectangle {
804 width: parent.width
806 width: parent.width
805 height: quickListColumn.height
807 height: quickListColumn.height
806
808
809+ MouseArea {
810+ anchors.fill: parent
811+ hoverEnabled: true
812+ onPositionChanged: {
813+ var item = quickListColumn.childAt(mouseX, mouseY);
814+ if (item.clickable) {
815+ quickList.selectedIndex = item.index;
816+ }
817+ }
818+ }
819+
807 Column {
820 Column {
808 id: quickListColumn
821 id: quickListColumn
809 width: parent.width
822 width: parent.width
@@ -814,6 +827,9 @@ Rectangle {
814 model: quickList.model
827 model: quickList.model
815
828
816 ListItem {
829 ListItem {
830+ readonly property bool clickable: model.clickable
831+ readonly property int index: model.index
832+
817 objectName: "quickListEntry" + index
833 objectName: "quickListEntry" + index
818 selected: index === quickList.selectedIndex
834 selected: index === quickList.selectedIndex
819 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
835 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
tests/qmltests/Launcher/tst_Launcher.qml+26−6
@@ -1235,13 +1235,13 @@ Rectangle {
1235 tryCompare(quickList, "selectedIndex", 0)
1235 tryCompare(quickList, "selectedIndex", 0)
1236
1236
1237 // Down should move down the quicklist
1237 // Down should move down the quicklist
1238+ // Because item 1 is not selectable
1238 keyClick(Qt.Key_Down);
1239 keyClick(Qt.Key_Down);
1239− tryCompare(quickList, "selectedIndex", 1)
1240+ tryCompare(quickList, "selectedIndex", 2)
1240
1241
1241 // The quicklist should wrap around too
1242 // The quicklist should wrap around too
1242 keyClick(Qt.Key_Down);
1243 keyClick(Qt.Key_Down);
1243 keyClick(Qt.Key_Down);
1244 keyClick(Qt.Key_Down);
1244− keyClick(Qt.Key_Down);
1245 tryCompare(quickList, "selectedIndex", 0)
1245 tryCompare(quickList, "selectedIndex", 0)
1246
1246
1247 // Left gets us back to the launcher
1247 // Left gets us back to the launcher
@@ -1266,14 +1266,14 @@ Rectangle {
1266
1266
1267 keyClick(Qt.Key_Down); // Down to launcher item 0
1267 keyClick(Qt.Key_Down); // Down to launcher item 0
1268 keyClick(Qt.Key_Down); // Down to launcher item 1
1268 keyClick(Qt.Key_Down); // Down to launcher item 1
1269− keyClick(Qt.Key_Right); // Into quicklist
1269+ keyClick(Qt.Key_Right); // Into quicklist, item 0 is selected
1270− keyClick(Qt.Key_Down); // Down to quicklist item 1
1271− keyClick(Qt.Key_Down); // Down to quicklist item 2
1270+ keyClick(Qt.Key_Down); // Down to quicklist item 2 (because 1 is not selectable)
1271+ keyClick(Qt.Key_Down); // Down to quicklist item 3
1272 keyClick(Qt.Key_Enter); // Trigger it
1272 keyClick(Qt.Key_Enter); // Trigger it
1273
1273
1274 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
1274 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
1275 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1275 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1276− compare(signalSpy.signalArguments[0][1], 2)
1276+ compare(signalSpy.signalArguments[0][1], 3)
1277 assertFocusOnIndex(-2);
1277 assertFocusOnIndex(-2);
1278 }
1278 }
1279
1279
@@ -1500,5 +1500,25 @@ Rectangle {
1500 tryCompare(launcher, "maxPanelX", 0);
1500 tryCompare(launcher, "maxPanelX", 0);
1501 launcher.panelWidth = oldSize;
1501 launcher.panelWidth = oldSize;
1502 }
1502 }
1503+
1504+ function test_mouseHoverSelectQuickList() {
1505+ dragLauncherIntoView();
1506+ var clickedItem = findChild(launcher, "launcherDelegate5")
1507+ var quickList = findChild(launcher, "quickList")
1508+
1509+ // Initial state
1510+ tryCompare(quickList, "state", "")
1511+
1512+ // Doing longpress
1513+ mouseClick(clickedItem, clickedItem.width / 2, clickedItem.height / 2, Qt.RightButton)
1514+ verify(quickList, "state", "open")
1515+ compare(quickList.selectedIndex, -1)
1516+
1517+ var qEntry = findChild(launcher, "quickListEntry0");
1518+ mouseMove(qEntry, qEntry.width / 2 , qEntry.height / 2, 10);
1519+ mouseMove(qEntry, qEntry.width / 2 + 1, qEntry.height / 2, 10);
1520+
1521+ tryCompare(quickList, "selectedIndex", 0)
1522+ }
1503 }
1523 }
1504}
1524}