on xenial help sign in
merge new prereq
6623b1eMichael Zanetti
qml/Launcher/LauncherPanel.qml+24−6
@@ -751,16 +751,18 @@ Rectangle {
751 Keys.onPressed: {
751 Keys.onPressed: {
752 switch (event.key) {
752 switch (event.key) {
753 case Qt.Key_Down:
753 case Qt.Key_Down:
754− selectedIndex++;
754+ var prevIndex = selectedIndex;
755− if (selectedIndex >= popoverRepeater.count) {
755+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
756− selectedIndex = 0;
756+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
757+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
757 }
758 }
758 event.accepted = true;
759 event.accepted = true;
759 break;
760 break;
760 case Qt.Key_Up:
761 case Qt.Key_Up:
761− selectedIndex--;
762+ var prevIndex = selectedIndex;
762− if (selectedIndex < 0) {
763+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
764+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
763− selectedIndex = popoverRepeater.count - 1;
765+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
764 }
766 }
765 event.accepted = true;
767 event.accepted = true;
766 break;
768 break;
@@ -806,6 +808,19 @@ Rectangle {
806 width: parent.width
808 width: parent.width
807 height: quickListColumn.height
809 height: quickListColumn.height
808
810
811+ MouseArea {
812+ anchors.fill: parent
813+ hoverEnabled: true
814+ onPositionChanged: {
815+ var item = quickListColumn.childAt(mouseX, mouseY);
816+ if (item.clickable) {
817+ quickList.selectedIndex = item.index;
818+ } else {
819+ quickList.selectedIndex = -1;
820+ }
821+ }
822+ }
823+
809 Column {
824 Column {
810 id: quickListColumn
825 id: quickListColumn
811 width: parent.width
826 width: parent.width
@@ -820,6 +835,9 @@ Rectangle {
820 }
835 }
821
836
822 ListItem {
837 ListItem {
838+ readonly property bool clickable: model.clickable
839+ readonly property int index: model.index
840+
823 objectName: "quickListEntry" + index
841 objectName: "quickListEntry" + index
824 selected: index === quickList.selectedIndex
842 selected: index === quickList.selectedIndex
825 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
843 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
tests/qmltests/Launcher/tst_Launcher.qml+32−6
@@ -1254,14 +1254,14 @@ Rectangle {
1254 tryCompare(quickList, "selectedIndex", 0)
1254 tryCompare(quickList, "selectedIndex", 0)
1255
1255
1256 // Down should move down the quicklist
1256 // Down should move down the quicklist
1257+ // Because item 1 is not selectable
1257 keyClick(Qt.Key_Down);
1258 keyClick(Qt.Key_Down);
1258− tryCompare(quickList, "selectedIndex", 1)
1259+ tryCompare(quickList, "selectedIndex", 2)
1259
1260
1260 // The quicklist should wrap around too
1261 // The quicklist should wrap around too
1261 keyClick(Qt.Key_Down);
1262 keyClick(Qt.Key_Down);
1262 keyClick(Qt.Key_Down);
1263 keyClick(Qt.Key_Down);
1263 keyClick(Qt.Key_Down);
1264 keyClick(Qt.Key_Down);
1264− keyClick(Qt.Key_Down);
1265 tryCompare(quickList, "selectedIndex", 0)
1265 tryCompare(quickList, "selectedIndex", 0)
1266
1266
1267 // Left gets us back to the launcher
1267 // Left gets us back to the launcher
@@ -1286,14 +1286,14 @@ Rectangle {
1286
1286
1287 keyClick(Qt.Key_Down); // Down to launcher item 0
1287 keyClick(Qt.Key_Down); // Down to launcher item 0
1288 keyClick(Qt.Key_Down); // Down to launcher item 1
1288 keyClick(Qt.Key_Down); // Down to launcher item 1
1289− keyClick(Qt.Key_Right); // Into quicklist
1289+ keyClick(Qt.Key_Right); // Into quicklist, item 0 is selected
1290− keyClick(Qt.Key_Down); // Down to quicklist item 1
1291− keyClick(Qt.Key_Down); // Down to quicklist item 2
1290+ keyClick(Qt.Key_Down); // Down to quicklist item 2 (because 1 is not selectable)
1291+ keyClick(Qt.Key_Down); // Down to quicklist item 3
1292 keyClick(Qt.Key_Enter); // Trigger it
1292 keyClick(Qt.Key_Enter); // Trigger it
1293
1293
1294 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
1294 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
1295 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1295 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1296− compare(signalSpy.signalArguments[0][1], 2)
1296+ compare(signalSpy.signalArguments[0][1], 3)
1297 assertFocusOnIndex(-2);
1297 assertFocusOnIndex(-2);
1298 }
1298 }
1299
1299
@@ -1554,5 +1554,31 @@ Rectangle {
1554
1554
1555 verify(launcher.state, "visible");
1555 verify(launcher.state, "visible");
1556 }
1556 }
1557+
1558+ function test_mouseHoverSelectQuickList() {
1559+ dragLauncherIntoView();
1560+ var clickedItem = findChild(launcher, "launcherDelegate5")
1561+ var quickList = findChild(launcher, "quickList")
1562+
1563+ // Initial state
1564+ tryCompare(quickList, "state", "")
1565+
1566+ // Open quickList
1567+ mouseClick(clickedItem, clickedItem.width / 2, clickedItem.height / 2, Qt.RightButton)
1568+ verify(quickList, "state", "open")
1569+ compare(quickList.selectedIndex, -1)
1570+
1571+ var qEntry = findChild(launcher, "quickListEntry0");
1572+ mouseMove(qEntry, qEntry.width / 2 , qEntry.height / 2, 10);
1573+ mouseMove(qEntry, qEntry.width / 2 + 1, qEntry.height / 2, 10);
1574+
1575+ tryCompare(quickList, "selectedIndex", 0)
1576+
1577+ qEntry = findChild(launcher, "quickListEntry1");
1578+ mouseMove(qEntry, qEntry.width / 2 , qEntry.height / 2, 10);
1579+ mouseMove(qEntry, qEntry.width / 2 + 1, qEntry.height / 2, 10);
1580+
1581+ tryCompare(quickList, "selectedIndex", -1)
1582+ }
1557 }
1583 }
1558}
1584}