on xenial help sign in
implement a keyboard shortcuts overlay panel
1cb9db5Lukáš Tinkl
qml/Components/KeyboardShortcutsOverlay.qmlnew file+568
@@ -0,0 +1,568 @@
1+/*
2+/*
3+ * Copyright (C) 2016 Canonical, Ltd.
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License as published by
7+ * the Free Software Foundation; version 3.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+import QtQuick 2.4
19+import QtQuick.Layouts 1.1
20+import Ubuntu.Components 1.3
21+
22+Rectangle {
23+ width: parent.width * 2/3
24+ height: parent.height * 2/3
25+ color: theme.palette.normal.background
26+ radius: units.gu(.5)
27+
28+ GridLayout {
29+ anchors.fill: parent
30+ anchors.margins: units.gu(4)
31+ columns: 2
32+ columnSpacing: units.gu(4)
33+
34+ Label {
35+ Layout.columnSpan: 2
36+ text: i18n.tr("Keyboard Shortcuts")
37+ fontSize: "large"
38+ font.weight: Font.Light
39+ lineHeight: 1.6
40+ }
41+
42+ GridLayout {
43+ columns: 2
44+ rows: 10
45+ columnSpacing: units.gu(4)
46+ Layout.alignment: Qt.AlignTop
47+
48+ // Unity 8 section
49+ Label {
50+ Layout.columnSpan: 2
51+ text: i18n.tr("Unity 8")
52+ font.weight: Font.Light
53+ color: theme.palette.normal.baseText
54+ lineHeight: 1.3
55+ }
56+
57+ Label {
58+ text: i18n.tr("PrtScr")
59+ fontSize: "small"
60+ font.weight: Font.Medium
61+ }
62+ Label {
63+ text: i18n.tr("Takes a screenshot.")
64+ fontSize: "small"
65+ font.weight: Font.Light
66+ }
67+
68+ Label {
69+ text: i18n.tr("Super + Space")
70+ fontSize: "small"
71+ font.weight: Font.Medium
72+ }
73+ Label {
74+ text: i18n.tr("Switches to next keyboard layout.")
75+ fontSize: "small"
76+ font.weight: Font.Light
77+ }
78+
79+ Label {
80+ text: i18n.tr("Super + Shift + Space")
81+ fontSize: "small"
82+ font.weight: Font.Medium
83+ }
84+ Label {
85+ text: i18n.tr("Switches to previous keyboard layout.")
86+ fontSize: "small"
87+ font.weight: Font.Light
88+ }
89+
90+
91+ // Launcher section
92+ Item { Layout.columnSpan: 2; height: units.gu(2) }
93+ Label {
94+ Layout.columnSpan: 2
95+ text: i18n.tr("Launcher")
96+ font.weight: Font.Light
97+ color: theme.palette.normal.baseText
98+ lineHeight: 1.3
99+ }
100+
101+ Label {
102+ text: i18n.tr("Super (Hold)")
103+ fontSize: "small"
104+ font.weight: Font.Medium
105+ }
106+ Label {
107+ text: i18n.tr("Opens the launcher, displays shortcuts.")
108+ fontSize: "small"
109+ font.weight: Font.Light
110+ }
111+
112+ Label {
113+ text: i18n.tr("Alt+F1")
114+ fontSize: "small"
115+ font.weight: Font.Medium
116+ }
117+ Label {
118+ text: i18n.tr("Opens launcher keyboard navigation mode.")
119+ fontSize: "small"
120+ font.weight: Font.Light
121+ }
122+
123+ Label {
124+ text: i18n.tr("Super + Tab")
125+ fontSize: "small"
126+ font.weight: Font.Medium
127+ }
128+ Label {
129+ text: i18n.tr("Switches applications via the launcher.")
130+ fontSize: "small"
131+ font.weight: Font.Light
132+ }
133+
134+ Label {
135+ text: i18n.tr("Super + 0 to 9")
136+ fontSize: "small"
137+ font.weight: Font.Medium
138+ }
139+ Label {
140+ text: i18n.tr("Same as clicking on a launcher icon.")
141+ fontSize: "small"
142+ font.weight: Font.Light
143+ }
144+
145+
146+ // Scopes section
147+ Item { Layout.columnSpan: 2; height: units.gu(2) }
148+ Label {
149+ Layout.columnSpan: 2
150+ text: i18n.tr("Scopes")
151+ font.weight: Font.Light
152+ color: theme.palette.normal.baseText
153+ lineHeight: 1.3
154+ }
155+
156+ Label {
157+ text: i18n.tr("Super (Tap)")
158+ fontSize: "small"
159+ font.weight: Font.Medium
160+ }
161+ Label {
162+ text: i18n.tr("Opens the Scopes home.")
163+ fontSize: "small"
164+ font.weight: Font.Light
165+ }
166+ }
167+
168+ GridLayout {
169+ columns: 2
170+ rows: 10
171+ columnSpacing: units.gu(4)
172+ Layout.alignment: Qt.AlignTop
173+
174+ // Switching section
175+ Label {
176+ Layout.columnSpan: 2
177+ text: i18n.tr("Switching")
178+ font.weight: Font.Light
179+ color: theme.palette.normal.baseText
180+ lineHeight: 1.3
181+ }
182+
183+ Label {
184+ text: i18n.tr("Alt + Tab")
185+ fontSize: "small"
186+ font.weight: Font.Medium
187+ }
188+ Label {
189+ text: i18n.tr("Switches between applications.")
190+ fontSize: "small"
191+ font.weight: Font.Light
192+ }
193+
194+ Label {
195+ text: i18n.tr("Super + W")
196+ fontSize: "small"
197+ font.weight: Font.Medium
198+ }
199+ Label {
200+ text: i18n.tr("Opens the desktop spread.")
201+ fontSize: "small"
202+ font.weight: Font.Light
203+ }
204+
205+ Label {
206+ text: i18n.tr("Cursor Left or Right")
207+ fontSize: "small"
208+ font.weight: Font.Medium
209+ }
210+ Label {
211+ text: i18n.tr("Moves the focus.")
212+ fontSize: "small"
213+ font.weight: Font.Light
214+ }
215+
216+
217+ // Windows section
218+ Item { Layout.columnSpan: 2; height: units.gu(2) }
219+ Label {
220+ Layout.columnSpan: 2
221+ text: i18n.tr("Windows")
222+ font.weight: Font.Light
223+ color: theme.palette.normal.baseText
224+ lineHeight: 1.3
225+ }
226+
227+ Label {
228+ text: i18n.tr("Ctrl + Super + D")
229+ fontSize: "small"
230+ font.weight: Font.Medium
231+ }
232+ Label {
233+ text: i18n.tr("Minimizes all windows.")
234+ fontSize: "small"
235+ font.weight: Font.Light
236+ }
237+
238+ Label {
239+ text: i18n.tr("Ctrl + Super + Up")
240+ fontSize: "small"
241+ font.weight: Font.Medium
242+ }
243+ Label {
244+ text: i18n.tr("Maximizes the current window.")
245+ fontSize: "small"
246+ font.weight: Font.Light
247+ }
248+
249+ Label {
250+ text: i18n.tr("Ctrl + Super + Down")
251+ fontSize: "small"
252+ font.weight: Font.Medium
253+ }
254+ Label {
255+ text: i18n.tr("Minimizes or restores the current window.")
256+ fontSize: "small"
257+ font.weight: Font.Light
258+ }
259+
260+ Label {
261+ text: i18n.tr("Ctrl + Super + Left or Right")
262+ fontSize: "small"
263+ font.weight: Font.Medium
264+ }
265+ Label {
266+ text: i18n.tr("Semi-maximizes the current window.")
267+ fontSize: "small"
268+ font.weight: Font.Light
269+ }
270+
271+ Label {
272+ text: i18n.tr("Alt + F4")
273+ fontSize: "small"
274+ font.weight: Font.Medium
275+ }
276+ Label {
277+ text: i18n.tr("Closes the current window.")
278+ fontSize: "small"
279+ font.weight: Font.Light
280+ }
281+ }
282+
283+ Item { Layout.fillHeight: true; Layout.columnSpan: 2 } // spacer
284+ }
285+}
286+ * Copyright (C) 2016 Canonical, Ltd.
287+ *
288+ * This program is free software; you can redistribute it and/or modify
289+ * it under the terms of the GNU General Public License as published by
290+ * the Free Software Foundation; version 3.
291+ *
292+ * This program is distributed in the hope that it will be useful,
293+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
294+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
295+ * GNU General Public License for more details.
296+ *
297+ * You should have received a copy of the GNU General Public License
298+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
299+ */
300+
301+import QtQuick 2.4
302+import QtQuick.Layouts 1.1
303+import Ubuntu.Components 1.3
304+
305+Rectangle {
306+ width: parent.width * 2/3
307+ height: parent.height * 2/3
308+ color: theme.palette.normal.background
309+ radius: units.gu(.5)
310+
311+ GridLayout {
312+ anchors.fill: parent
313+ anchors.margins: units.gu(4)
314+ columns: 2
315+ columnSpacing: units.gu(4)
316+
317+ Label {
318+ Layout.columnSpan: 2
319+ text: i18n.tr("Keyboard Shortcuts")
320+ fontSize: "large"
321+ font.weight: Font.Light
322+ lineHeight: 1.6
323+ }
324+
325+ GridLayout {
326+ columns: 2
327+ rows: 10
328+ columnSpacing: units.gu(4)
329+ Layout.alignment: Qt.AlignTop
330+
331+ // Unity 8 section
332+ Label {
333+ Layout.columnSpan: 2
334+ text: i18n.tr("Unity 8")
335+ font.weight: Font.Light
336+ color: theme.palette.normal.baseText
337+ lineHeight: 1.3
338+ }
339+
340+ Label {
341+ text: i18n.tr("PrtScr")
342+ fontSize: "small"
343+ font.weight: Font.Medium
344+ }
345+ Label {
346+ text: i18n.tr("Takes a screenshot.")
347+ fontSize: "small"
348+ font.weight: Font.Light
349+ }
350+
351+ Label {
352+ text: i18n.tr("Super + Space")
353+ fontSize: "small"
354+ font.weight: Font.Medium
355+ }
356+ Label {
357+ text: i18n.tr("Switches to next keyboard layout.")
358+ fontSize: "small"
359+ font.weight: Font.Light
360+ }
361+
362+ Label {
363+ text: i18n.tr("Super + Shift + Space")
364+ fontSize: "small"
365+ font.weight: Font.Medium
366+ }
367+ Label {
368+ text: i18n.tr("Switches to previous keyboard layout.")
369+ fontSize: "small"
370+ font.weight: Font.Light
371+ }
372+
373+
374+ // Launcher section
375+ Item { Layout.columnSpan: 2; height: units.gu(2) }
376+ Label {
377+ Layout.columnSpan: 2
378+ text: i18n.tr("Launcher")
379+ font.weight: Font.Light
380+ color: theme.palette.normal.baseText
381+ lineHeight: 1.3
382+ }
383+
384+ Label {
385+ text: i18n.tr("Super (Hold)")
386+ fontSize: "small"
387+ font.weight: Font.Medium
388+ }
389+ Label {
390+ text: i18n.tr("Opens the launcher, displays shortcuts.")
391+ fontSize: "small"
392+ font.weight: Font.Light
393+ }
394+
395+ Label {
396+ text: i18n.tr("Alt+F1")
397+ fontSize: "small"
398+ font.weight: Font.Medium
399+ }
400+ Label {
401+ text: i18n.tr("Opens launcher keyboard navigation mode.")
402+ fontSize: "small"
403+ font.weight: Font.Light
404+ }
405+
406+ Label {
407+ text: i18n.tr("Super + Tab")
408+ fontSize: "small"
409+ font.weight: Font.Medium
410+ }
411+ Label {
412+ text: i18n.tr("Switches applications via the launcher.")
413+ fontSize: "small"
414+ font.weight: Font.Light
415+ }
416+
417+ Label {
418+ text: i18n.tr("Super + 0 to 9")
419+ fontSize: "small"
420+ font.weight: Font.Medium
421+ }
422+ Label {
423+ text: i18n.tr("Same as clicking on a launcher icon.")
424+ fontSize: "small"
425+ font.weight: Font.Light
426+ }
427+
428+
429+ // Scopes section
430+ Item { Layout.columnSpan: 2; height: units.gu(2) }
431+ Label {
432+ Layout.columnSpan: 2
433+ text: i18n.tr("Scopes")
434+ font.weight: Font.Light
435+ color: theme.palette.normal.baseText
436+ lineHeight: 1.3
437+ }
438+
439+ Label {
440+ text: i18n.tr("Super (Tap)")
441+ fontSize: "small"
442+ font.weight: Font.Medium
443+ }
444+ Label {
445+ text: i18n.tr("Opens the Scopes home.")
446+ fontSize: "small"
447+ font.weight: Font.Light
448+ }
449+ }
450+
451+ GridLayout {
452+ columns: 2
453+ rows: 10
454+ columnSpacing: units.gu(4)
455+ Layout.alignment: Qt.AlignTop
456+
457+ // Switching section
458+ Label {
459+ Layout.columnSpan: 2
460+ text: i18n.tr("Switching")
461+ font.weight: Font.Light
462+ color: theme.palette.normal.baseText
463+ lineHeight: 1.3
464+ }
465+
466+ Label {
467+ text: i18n.tr("Alt + Tab")
468+ fontSize: "small"
469+ font.weight: Font.Medium
470+ }
471+ Label {
472+ text: i18n.tr("Switches between applications.")
473+ fontSize: "small"
474+ font.weight: Font.Light
475+ }
476+
477+ Label {
478+ text: i18n.tr("Super + W")
479+ fontSize: "small"
480+ font.weight: Font.Medium
481+ }
482+ Label {
483+ text: i18n.tr("Opens the desktop spread.")
484+ fontSize: "small"
485+ font.weight: Font.Light
486+ }
487+
488+ Label {
489+ text: i18n.tr("Cursor Left or Right")
490+ fontSize: "small"
491+ font.weight: Font.Medium
492+ }
493+ Label {
494+ text: i18n.tr("Moves the focus.")
495+ fontSize: "small"
496+ font.weight: Font.Light
497+ }
498+
499+
500+ // Windows section
501+ Item { Layout.columnSpan: 2; height: units.gu(2) }
502+ Label {
503+ Layout.columnSpan: 2
504+ text: i18n.tr("Windows")
505+ font.weight: Font.Light
506+ color: theme.palette.normal.baseText
507+ lineHeight: 1.3
508+ }
509+
510+ Label {
511+ text: i18n.tr("Ctrl + Super + D")
512+ fontSize: "small"
513+ font.weight: Font.Medium
514+ }
515+ Label {
516+ text: i18n.tr("Minimizes all windows.")
517+ fontSize: "small"
518+ font.weight: Font.Light
519+ }
520+
521+ Label {
522+ text: i18n.tr("Ctrl + Super + Up")
523+ fontSize: "small"
524+ font.weight: Font.Medium
525+ }
526+ Label {
527+ text: i18n.tr("Maximizes the current window.")
528+ fontSize: "small"
529+ font.weight: Font.Light
530+ }
531+
532+ Label {
533+ text: i18n.tr("Ctrl + Super + Down")
534+ fontSize: "small"
535+ font.weight: Font.Medium
536+ }
537+ Label {
538+ text: i18n.tr("Minimizes or restores the current window.")
539+ fontSize: "small"
540+ font.weight: Font.Light
541+ }
542+
543+ Label {
544+ text: i18n.tr("Ctrl + Super + Left or Right")
545+ fontSize: "small"
546+ font.weight: Font.Medium
547+ }
548+ Label {
549+ text: i18n.tr("Semi-maximizes the current window.")
550+ fontSize: "small"
551+ font.weight: Font.Light
552+ }
553+
554+ Label {
555+ text: i18n.tr("Alt + F4")
556+ fontSize: "small"
557+ font.weight: Font.Medium
558+ }
559+ Label {
560+ text: i18n.tr("Closes the current window.")
561+ fontSize: "small"
562+ font.weight: Font.Light
563+ }
564+ }
565+
566+ Item { Layout.fillHeight: true; Layout.columnSpan: 2 } // spacer
567+ }
568+}
qml/Launcher/Launcher.qml+1
@@ -41,6 +41,7 @@ FocusScope {
41 readonly property bool dragging: dragArea.dragging
41 readonly property bool dragging: dragArea.dragging
42 readonly property real dragDistance: dragArea.dragging ? dragArea.touchX : 0
42 readonly property real dragDistance: dragArea.dragging ? dragArea.touchX : 0
43 readonly property real visibleWidth: panel.width + panel.x
43 readonly property real visibleWidth: panel.width + panel.x
44+ readonly property alias shortcutHintsShown: panel.shortcutHintsShown
44
45
45 readonly property bool shown: panel.x > -panel.width
46 readonly property bool shown: panel.x > -panel.width
46
47
qml/Shell.qml+8
@@ -598,6 +598,14 @@ Item {
598 }
598 }
599 }
599 }
600
600
601+ KeyboardShortcutsOverlay {
602+ objectName: "shortcutsOverlay"
603+ visible: launcher.shortcutHintsShown
604+ enabled: visible
605+ anchors.centerIn: parent
606+ anchors.horizontalCenterOffset: launcher.lockedVisible ? launcher.panelWidth/2 : 0
607+ }
608+
601 Tutorial {
609 Tutorial {
602 id: tutorial
610 id: tutorial
603 objectName: "tutorial"
611 objectName: "tutorial"
tests/qmltests/tst_Shell.qml+4−1
@@ -2152,19 +2152,22 @@ Rectangle {
2152 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
2152 tryCompare(ApplicationManager, "focusedApplicationId", "unity8-dash");
2153 }
2153 }
2154
2154
2155− function test_longpressSuperOpensLauncher() {
2155+ function test_longpressSuperOpensLauncherAndShortcutsOverlay() {
2156 loadShell("desktop");
2156 loadShell("desktop");
2157 var launcher = findChild(shell, "launcher");
2157 var launcher = findChild(shell, "launcher");
2158 var shortcutHint = findChild(findChild(launcher, "launcherDelegate0"), "shortcutHint")
2158 var shortcutHint = findChild(findChild(launcher, "launcherDelegate0"), "shortcutHint")
2159+ var shortcutsOverlay = findChild(shell, "shortcutsOverlay");
2159
2160
2160 compare(launcher.state, "");
2161 compare(launcher.state, "");
2161 keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2162 keyPress(Qt.Key_Super_L, Qt.MetaModifier);
2162 tryCompare(launcher, "state", "visible");
2163 tryCompare(launcher, "state", "visible");
2163 tryCompare(shortcutHint, "visible", true);
2164 tryCompare(shortcutHint, "visible", true);
2165+ tryCompare(shortcutsOverlay, "visible", true);
2164
2166
2165 keyRelease(Qt.Key_Super_L, Qt.MetaModifier);
2167 keyRelease(Qt.Key_Super_L, Qt.MetaModifier);
2166 tryCompare(launcher, "state", "");
2168 tryCompare(launcher, "state", "");
2167 tryCompare(shortcutHint, "visible", false);
2169 tryCompare(shortcutHint, "visible", false);
2170+ tryCompare(shortcutsOverlay, "visible", false);
2168 }
2171 }
2169
2172
2170 function test_metaNumberLaunchesFromLauncher_data() {
2173 function test_metaNumberLaunchesFromLauncher_data() {