on xenial help sign in
Add keyboard navigation for Indicators
c198715Albert Astals Cid
qml/Panel/PanelBar.qml+1
@@ -49,6 +49,7 @@ Item {
49 row.resetCurrentItem();
49 row.resetCurrentItem();
50 }
50 }
51 row.setCurrentItemIndex(index);
51 row.setCurrentItemIndex(index);
52+ d.alignIndicators();
52 }
53 }
53
54
54 function addScrollOffset(scrollAmmout) {
55 function addScrollOffset(scrollAmmout) {
qml/Panel/PanelMenu.qml+14
@@ -140,6 +140,19 @@ Showable {
140 visible: !root.fullyClosed
140 visible: !root.fullyClosed
141 }
141 }
142
142
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+
143 PanelBar {
156 PanelBar {
144 id: bar
157 id: bar
145 objectName: "indicatorsBar"
158 objectName: "indicatorsBar"
@@ -368,6 +381,7 @@ Showable {
368 State {
381 State {
369 name: "commit"
382 name: "commit"
370 extend: "locked"
383 extend: "locked"
384+ PropertyChanges { target: root; focus: true }
371 PropertyChanges { target: bar; interactive: true }
385 PropertyChanges { target: bar; interactive: true }
372 PropertyChanges {
386 PropertyChanges {
373 target: d;
387 target: d;
tests/qmltests/Panel/tst_Panel.qml+34
@@ -799,5 +799,39 @@ PanelTest {
799 tryCompare(appTitle, "visible", false, undefined, "App title should still be visible on mouse hover when panel decorations are visible");
799 tryCompare(appTitle, "visible", false, undefined, "App title should still be visible on mouse hover when panel decorations are visible");
800 tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover when panel decorations not visible");
800 tryCompare(appMenuBar, "visible", true, undefined, "App menu bar should be visible on mouse hover when panel decorations not visible");
801 }
801 }
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+ }
802 }
836 }
803}
837}