on xenial help sign in
merge new prereq
commit6623b1e8e32e5940e94020dbbb9d2f19bb64d713 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 28 Mar 2017, 09:57 (10 years ago) parent297aa84f0b2f8c
2 files changed+56−12
qml/Launcher/LauncherPanel.qml+24−6 tests/qmltests/Launcher/tst_Launcher.qml+32−6
qml/Launcher/LauncherPanel.qml+24−6
@@ -751,16 +751,18 @@ Rectangle {
751751 Keys.onPressed: {
752752 switch (event.key) {
753753 case Qt.Key_Down:
754− selectedIndex++;
755− if (selectedIndex >= popoverRepeater.count) {
756− selectedIndex = 0;
754+ var prevIndex = selectedIndex;
755+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
756+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
757+ selectedIndex = (selectedIndex + 1 < popoverRepeater.count) ? selectedIndex + 1 : 0;
757758 }
758759 event.accepted = true;
759760 break;
760761 case Qt.Key_Up:
761− selectedIndex--;
762− if (selectedIndex < 0) {
763− selectedIndex = popoverRepeater.count - 1;
762+ var prevIndex = selectedIndex;
763+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
764+ while (!popoverRepeater.itemAt(selectedIndex).clickable && selectedIndex != prevIndex) {
765+ selectedIndex = (selectedIndex > 0) ? selectedIndex - 1 : popoverRepeater.count - 1;
764766 }
765767 event.accepted = true;
766768 break;
@@ -806,6 +808,19 @@ Rectangle {
806808 width: parent.width
807809 height: quickListColumn.height
808810
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+
809824 Column {
810825 id: quickListColumn
811826 width: parent.width
@@ -820,6 +835,9 @@ Rectangle {
820835 }
821836
822837 ListItem {
838+ readonly property bool clickable: model.clickable
839+ readonly property int index: model.index
840+
823841 objectName: "quickListEntry" + index
824842 selected: index === quickList.selectedIndex
825843 height: label.implicitHeight + label.anchors.topMargin + label.anchors.bottomMargin
tests/qmltests/Launcher/tst_Launcher.qml+32−6
@@ -1254,14 +1254,14 @@ Rectangle {
12541254 tryCompare(quickList, "selectedIndex", 0)
12551255
12561256 // Down should move down the quicklist
1257+ // Because item 1 is not selectable
12571258 keyClick(Qt.Key_Down);
1258− tryCompare(quickList, "selectedIndex", 1)
1259+ tryCompare(quickList, "selectedIndex", 2)
12591260
12601261 // The quicklist should wrap around too
12611262 keyClick(Qt.Key_Down);
12621263 keyClick(Qt.Key_Down);
12631264 keyClick(Qt.Key_Down);
1264− keyClick(Qt.Key_Down);
12651265 tryCompare(quickList, "selectedIndex", 0)
12661266
12671267 // Left gets us back to the launcher
@@ -1286,14 +1286,14 @@ Rectangle {
12861286
12871287 keyClick(Qt.Key_Down); // Down to launcher item 0
12881288 keyClick(Qt.Key_Down); // Down to launcher item 1
1289− keyClick(Qt.Key_Right); // Into quicklist
1290− keyClick(Qt.Key_Down); // Down to quicklist item 1
1291− keyClick(Qt.Key_Down); // Down to quicklist item 2
1289+ keyClick(Qt.Key_Right); // Into quicklist, item 0 is selected
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
12921292 keyClick(Qt.Key_Enter); // Trigger it
12931293
12941294 compare(signalSpy.count, 1, "Quicklist signal wasn't triggered")
12951295 compare(signalSpy.signalArguments[0][0], LauncherModel.get(1).appId)
1296− compare(signalSpy.signalArguments[0][1], 2)
1296+ compare(signalSpy.signalArguments[0][1], 3)
12971297 assertFocusOnIndex(-2);
12981298 }
12991299
@@ -1554,5 +1554,31 @@ Rectangle {
15541554
15551555 verify(launcher.state, "visible");
15561556 }
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+ }
15571583 }
15581584}