on xenial help sign in
Add keyboard navigation for Indicators

Esc closes Left/Right selects prev/next indicator Approved by: Michael Zanetti, Unity8 CI Bot

commitc198715ddfa06635b21ab0daa59ce260c8cf8a3a authorAlbert Astals Cid <albert.astals@canonical.com> dateTue 24 Jan 2017, 07:40 (10 years ago) parentf11b59c75798bc
3 files changed+49
qml/Panel/PanelBar.qml+1 qml/Panel/PanelMenu.qml+14 tests/qmltests/Panel/tst_Panel.qml+34
qml/Panel/PanelBar.qml+1
@@ -49,6 +49,7 @@ Item {
4949 row.resetCurrentItem();
5050 }
5151 row.setCurrentItemIndex(index);
52+ d.alignIndicators();
5253 }
5354
5455 function addScrollOffset(scrollAmmout) {
qml/Panel/PanelMenu.qml+14
@@ -140,6 +140,19 @@ Showable {
140140 visible: !root.fullyClosed
141141 }
142142
143+ Keys.onPressed: {
144+ if (event.key === Qt.Key_Left) {
145+ bar.setCurrentItemIndex(bar.currentItemIndex - 1);
146+ event.accepted = true;
147+ } else if (event.key === Qt.Key_Right) {
148+ bar.setCurrentItemIndex(bar.currentItemIndex + 1);
149+ event.accepted = true;
150+ } else if (event.key === Qt.Key_Escape) {
151+ root.hide();
152+ event.accepted = true;
153+ }
154+ }
155+
143156 PanelBar {
144157 id: bar
145158 objectName: "indicatorsBar"
@@ -368,6 +381,7 @@ Showable {
368381 State {
369382 name: "commit"
370383 extend: "locked"
384+ PropertyChanges { target: root; focus: true }
371385 PropertyChanges { target: bar; interactive: true }
372386 PropertyChanges {
373387 target: d;
tests/qmltests/Panel/tst_Panel.qml+34
@@ -799,5 +799,39 @@ PanelTest {
799799 tryCompare(appTitle, "visible", false, undefined, "App title should still be visible on mouse hover when panel decorations are visible");
800800 tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover when panel decorations not visible");
801801 }
802+
803+ function test_keyboardNavigation_data() {
804+ return [
805+ {tag: "tab to start", doTab: false},
806+ {tag: "no tab to start", doTab: true}
807+ ]
808+ }
809+
810+ function test_keyboardNavigation(data) {
811+ var indicatorsBar = findChild(panel.indicators, "indicatorsBar");
812+
813+ pullDownIndicatorsMenu();
814+
815+ indicatorsBar.setCurrentItemIndex(0);
816+
817+ if (data.doTab) {
818+ keyClick(Qt.Key_Tab);
819+ }
820+
821+ keyClick(Qt.Key_Right);
822+ tryCompare(indicatorsBar, "currentItemIndex", 1);
823+
824+ keyClick(Qt.Key_Right);
825+ tryCompare(indicatorsBar, "currentItemIndex", 2);
826+
827+ keyClick(Qt.Key_Left);
828+ tryCompare(indicatorsBar, "currentItemIndex", 1);
829+
830+ keyClick(Qt.Key_Left);
831+ tryCompare(indicatorsBar, "currentItemIndex", 0);
832+
833+ keyClick(Qt.Key_Escape);
834+ tryCompare(panel.indicators, "fullyClosed", true);
835+ }
802836 }
803837}