Merge lp:~unity-2d-team/unity-2d/shortcut-hint-overlay into lp:unity-2d

Proposed by Lohith D Shivamurthy on 2012-02-13
Status: Rejected
Rejected by: Albert Astals Cid on 2013-11-29
Proposed branch: lp:~unity-2d-team/unity-2d/shortcut-hint-overlay
Merge into: lp:unity-2d
Diff against target: 657 lines (+572/-0)
8 files modified
debian/unity-2d-shell.install.in (+1/-0)
shell/Shell.qml (+34/-0)
shell/app/shellmanager.cpp (+11/-0)
shell/app/shellmanager.h (+3/-0)
shell/shortcutoverlay/ModelElement.qml (+26/-0)
shell/shortcutoverlay/ShortcutHint.qml (+243/-0)
shell/shortcutoverlay/ShortcutHintSection.qml (+165/-0)
tests/shell/shortcut-hint-overlay-tests.rb (+89/-0)
To merge this branch: bzr merge lp:~unity-2d-team/unity-2d/shortcut-hint-overlay
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) 2012-02-13 Needs Fixing on 2012-03-30
Michał Sawicz 2012-02-13 Needs Information on 2012-02-14
Florian Boucault (community) 2012-02-13 Needs Fixing on 2012-02-13
Gerry Boland 2012-02-13 Pending
Review via email: mp+92747@code.launchpad.net

This proposal supersedes a proposal from 2012-02-01.

Description of the change

[launcher] Shortcut list should be shown while super key is held.

To post a comment you must log in.
Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal

Further details:
The List of keys to be displayed and the layout of the overlay can be found in the bug description https://bugs.launchpad.net/unity-2d/+bug/855532
It is discussed with the design team, that certain keys having multiple values in gconf, like 'Switch workspaces' should only be displayed when the keys are symmetric.

Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

u2d.tr(description) won't work since the text of the description won't be extracted by the update-unity-2d-pot script, the same for the title. And since the won't be in the .po file they won't be translatable. You'll have to move the u2d.tr to were you have the actual "text" so the text is extracted.

review: Needs Fixing
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

Of course, we won't merge that until unity-2d-shell is merged into lp:unity-2d.

Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Please give credit to Tiago in the commit message, for working on the UI side of this MR.

Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Hey, this looks like it could go into lp:unity-2d with minor modifications, and will reduce the diff when we actually go to merging shell into trunk, could you please have a MR against lp:unity-2d for this?

review: Needs Information
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

> Hey, this looks like it could go into lp:unity-2d with minor modifications,
> and will reduce the diff when we actually go to merging shell into trunk,
> could you please have a MR against lp:unity-2d for this?

Actually that might not be worth it, since you don't have any fullscreen part of the UI with unity-2d, you'd have to hack up the dash to go fullscreen when the hint is supposed to show.

In that case I propose that we wait with merging this for the shell to be merged into trunk and then MR that change against trunk.

Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

The overlay needs to have a blurred background, it's unreadable when you have a terminal window behind it.

Also, I wonder if the overlay should be input-shaped? Right now you can interact with windows behind the overlay, which makes sense, for it being just an overlay, but not sure that's the designed behavior.

review: Needs Fixing
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Looks nice! Aside from above comments:
- along with blurred background, the sheen is also needed. See Background.qml
- background has unusual colour tint set. We don't have tinting just now, so should be removed.
- shell/Shell.qml - why remove "KeyNavigation.left: launcherLoader" ?
- in symmetricKey() and getShortcutKey(), GConfItem declared in Unity2D, no need to import QtQuick
- in your javascript, your notation is mixing camelCase and underscore_separator. Use camelCase please. Some spacing between arguments in the function calls would help readability too.
- symmetricKey deserves a comment to explain why it is there.
- can you check with design about using empty strings if no key is set? I think it looks confusing.
- I have a truncation for a long key combination: https://imgur.com/a/okLFf can you also check with design to see what to do?
- overlay needs to be positioned a little higher, see comparison image: https://imgur.com/xqAVf
- there are typos, and some EnglishUK spellings instead of US (see first screenshot again). Yes they're in the mockup, but check with design
- in "Switching" - the left/right cursor keys do not move focus in Metacity. Is this something that needs to be enabled, or should this listing be removed?
- Alt+Middle Mouse drag also doesn't work for me.
- Please use fontUtils.js to specify font sizes
- you have unrelated changes from tests/run-tests.rb & tests/shell/input_shaping.rb in the diff, please remove.
- recently we decided having authors names in text files was going to be a pain, so we removed them. Will you do the same?
- have you given any thought to accessibility? How will this work with Orca? Since focus is not stolen, what will Orca do? Will it be possible to have Orca read out these shortcuts in some way? Just something to think about.
- import Unity2d 1.0 /* required by GConfItem */ <- GConfItem requires Unity2D, not other way around
- qml (I know, Tiago's) could be cleaned up a little, with both x,y coordinates & anchors being used, lots of unnecessary margin:0 scattered about for example.

review: Needs Fixing
Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal

> The overlay needs to have a blurred background, it's unreadable when you have
> a terminal window behind it.
>
I checked with design and have done what they said.

> Also, I wonder if the overlay should be input-shaped? Right now you can
> interact with windows behind the overlay, which makes sense, for it being just
> an overlay, but not sure that's the designed behavior.
Yes you can interact with windows behind it.

Lohith D Shivamurthy (dyams) wrote : Posted in a previous version of this proposal

> Looks nice! Aside from above comments:
> - along with blurred background, the sheen is also needed. See Background.qml
> - background has unusual colour tint set. We don't have tinting just now, so
> should be removed.
I checked with design, this is the conversation:
dyams rosie: should we need to have a background for overlay hint?
dyams rosie: if the overlay is displayed on a white background for ex: gedit window, the shortcuts are hardly visible
rosie dyams: there is a 35% #5e2750 layer and a -80% (-150% - 150%) brightness layer

> - shell/Shell.qml - why remove "KeyNavigation.left: launcherLoader" ?
The only difference i see in Shell.qml is
30 + Loader {
31 + id: shortcutHintLoader
32 + anchors.centerIn: parent
33 + }
34 +

> - in symmetricKey() and getShortcutKey(), GConfItem declared in Unity2D, no
> need to import QtQuick
Are you sure? FYI, i get this '[WARNING] ShortcutHint.qml:22:1: Item is not a type'
> - in your javascript, your notation is mixing camelCase and
> underscore_separator. Use camelCase please. Some spacing between arguments in
> the function calls would help readability too.
> - symmetricKey deserves a comment to explain why it is there.
Done.
> - can you check with design about using empty strings if no key is set? I
> think it looks confusing.
true, but its design decision.

> - I have a truncation for a long key combination: https://imgur.com/a/okLFf
> can you also check with design to see what to do?
Design changed a bit, I have updated the same.

> - overlay needs to be positioned a little higher, see comparison image:
> https://imgur.com/xqAVf
It is positioned to the center. I doubt we need to adjust it again.

> - there are typos, and some EnglishUK spellings instead of US (see first
> screenshot again). Yes they're in the mockup, but check with design
Done

> - in "Switching" - the left/right cursor keys do not move focus in Metacity.
> Is this something that needs to be enabled, or should this listing be removed?
No, It works

> - Alt+Middle Mouse drag also doesn't work for me.
No, It works

> - Please use fontUtils.js to specify font sizes
Done.

> - you have unrelated changes from tests/run-tests.rb &
> tests/shell/input_shaping.rb in the diff, please remove.
Is it? but they are not listed under the 'differences' here.

> - recently we decided having authors names in text files was going to be a
> pain, so we removed them. Will you do the same?
Done.

> - have you given any thought to accessibility? How will this work with Orca?
> Since focus is not stolen, what will Orca do? Will it be possible to have Orca
> read out these shortcuts in some way? Just something to think about.
No.

> - import Unity2d 1.0 /* required by GConfItem */ <- GConfItem requires
> Unity2D, not other way around
Yes I know.

> - qml (I know, Tiago's) could be cleaned up a little, with both x,y
> coordinates & anchors being used, lots of unnecessary margin:0 scattered about
> for example.
Done.

Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

Please resubmit the MR against lp:unity-2d

Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

Maybe I am out of line here but I don't see how the overlay belongs to the launcher.

review: Needs Fixing
Florian Boucault (fboucault) wrote :

No need to expose GConfItem through our plugin, just:

import gconf 1.0

review: Needs Fixing
Florian Boucault (fboucault) wrote :

The shortcut overlay needs a blurred background, per design

review: Needs Fixing
Florian Boucault (fboucault) wrote :

The borders are wrong, they look like a small image stretched

Florian Boucault (fboucault) wrote :

shell/launcher/LauncherLoader.qml refers to declarativeView.dashActive which should never be done from QML. Use Dash.qml's dash.active instead

review: Needs Fixing
Florian Boucault (fboucault) wrote :

shell/launcher/LauncherLoader.qml refers to shortcutHintLoader which is not defined anywhere in shell/launcher/LauncherLoader.qml; that is bad practice that breaks encapsulation (ie. shell/launcher/LauncherLoader.qml cannot be run on its own)

review: Needs Fixing
Florian Boucault (fboucault) wrote :

Why giving a different:
- file name: ShortcutHint.qml
- id: main
- and objectName: "shortcutHintOverlay"
to the same thing?

review: Needs Fixing
Florian Boucault (fboucault) wrote :

Why is it not part of the png for the border?

    Rectangle {
        id: totalArea
        color: Qt.lighter("#5e275023", -0.8)
        radius: 8
        smooth: true
        anchors.fill: parent
        anchors.margins: 10

Where is that color coming from?

Florian Boucault (fboucault) wrote :

Please use TextCustom and its fontSize property instead of Text.

review: Needs Fixing
Florian Boucault (fboucault) wrote :

Is the interface translatable? Did you act on Albert's comment:

"u2d.tr(description) won't work since the text of the description won't be extracted by the update-unity-2d-pot script, the same for the title. And since the won't be in the .po file they won't be translatable. You'll have to move the u2d.tr to were you have the actual "text" so the text is extracted."

review: Needs Fixing
965. By Lohith D Shivamurthy on 2012-02-13

Directly import gconf 0.1

966. By Lohith D Shivamurthy on 2012-02-13

keep object id same as objectname

967. By Lohith D Shivamurthy on 2012-02-13

Add a FIXME for i18n of display strings

968. By Lohith D Shivamurthy on 2012-02-13

Remove background color

969. By Lohith D Shivamurthy on 2012-02-13

Use TextCustom instead of Text element

970. By Lohith D Shivamurthy on 2012-02-13

Fix missing parent object

971. By Lohith D Shivamurthy on 2012-02-13

Apply blur background

972. By Lohith D Shivamurthy on 2012-02-13

Activate/Deactivate overlay in shell.qml

973. By Lohith D Shivamurthy on 2012-02-13

Deactivate the overlay on tapping launcher tile shortcuts

Albert Astals Cid (aacid) wrote :

I don't think having untranslatable strings is acceptable.

If we can't have
ListElement { defaultKey: "Super (Press)"; description: u2d.tr("Open Launcher, displays shortcuts."); gconfKey: "" }
because of that Qt bug i suggest we do this

Switch can to using
text: u2d.tr(description)
and then add somewhere in the file
    function dummyFunction() {
        u2d.tr("Open Launcher, displays shortcuts.")
        ...
        ...
    }
This way we trick po/update-unity-2d-pot to extract the descriptions into the .pot file and things are translatable again

review: Needs Fixing
974. By Lohith D Shivamurthy on 2012-02-14

Add a dummy function and call u2d.tr on all display strings

Albert Astals Cid (aacid) wrote :

I'm happy enough with the translation stuff, i'll let Florian decided if his other concerns are fixed

Michał Sawicz (saviq) wrote :

Wouldn't http://developer.qt.nokia.com/doc/qt-4.8/qml-item.html#data-prop be a good place to have those translation strings?

review: Needs Information
975. By Lohith D Shivamurthy on 2012-02-14

Improve background

976. By Lohith D Shivamurthy on 2012-02-14

Use workaround mentioned in the bugreport

977. By Lohith D Shivamurthy on 2012-02-15

Use regExp to replace case-insensitively

978. By Lohith D Shivamurthy on 2012-02-15

Replace Shft with Shift

979. By Lohith D Shivamurthy on 2012-02-15

Add missing file ModelElement.qml

980. By Lohith D Shivamurthy on 2012-02-15

merge

981. By Lohith D Shivamurthy on 2012-02-16

Remove extra field from ModelElement.qml

982. By Lohith D Shivamurthy on 2012-02-16

deactivate overlay when view looses focus

983. By Lohith D Shivamurthy on 2012-02-16

Apply black background with 70% opacity

984. By Tiago Salem Herrmann on 2012-03-19

merge trunk

985. By Tiago Salem Herrmann on 2012-03-19

onSuperKeyHeldChanged was moved to shellManager

986. By Tiago Salem Herrmann on 2012-03-20

remove debug

987. By Tiago Salem Herrmann on 2012-03-20

Force string object for the key. In some cases key is a object so replace() and substring fail

988. By Tiago Salem Herrmann on 2012-03-20

fix white spaces

989. By Tiago Salem Herrmann on 2012-03-20

ignore <Primary> string

990. By Tiago Salem Herrmann on 2012-03-21

merge trunk

991. By Tiago Salem Herrmann on 2012-03-21

add MultiMonitor support
Use the same trick as Dash to update the blurred background

992. By Gerry Boland on 2012-03-26

Replace 'KP_' with 'Num' in gconf string. Needed for Numpad keys

993. By Gerry Boland on 2012-03-26

QtQuick1.0 not needed to read gconf values

994. By Gerry Boland on 2012-03-26

Add basic RTL support

995. By Gerry Boland on 2012-03-29

[debian] Install shortcut overlay QML files

Albert Astals Cid (aacid) wrote :

The "Alt (Tap) shows HUD" is missing

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

The focus is not returned to the previous app once the super key is released

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

the onDashActiveChanged code for declarativeView is wrong and needs to be merged with the existing onDashActiveChanged for the shellManager

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

Key descriptions (e.g. "Cursors Keys") need to be translatable

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

symmetricKey also needs i18n work, it prepends "Cursors" in some cases

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

Don't we need

install(DIRECTORY shortcutoverlay
    DESTINATION ${UNITY_2D_DIR}/shell
    )

in shell/CMakelists.txt?

review: Needs Fixing

Unmerged revisions

995. By Gerry Boland on 2012-03-29

[debian] Install shortcut overlay QML files

994. By Gerry Boland on 2012-03-26

Add basic RTL support

993. By Gerry Boland on 2012-03-26

QtQuick1.0 not needed to read gconf values

992. By Gerry Boland on 2012-03-26

Replace 'KP_' with 'Num' in gconf string. Needed for Numpad keys

991. By Tiago Salem Herrmann on 2012-03-21

add MultiMonitor support
Use the same trick as Dash to update the blurred background

990. By Tiago Salem Herrmann on 2012-03-21

merge trunk

989. By Tiago Salem Herrmann on 2012-03-20

ignore <Primary> string

988. By Tiago Salem Herrmann on 2012-03-20

fix white spaces

987. By Tiago Salem Herrmann on 2012-03-20

Force string object for the key. In some cases key is a object so replace() and substring fail

986. By Tiago Salem Herrmann on 2012-03-20

remove debug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity-2d-shell.install.in'
2--- debian/unity-2d-shell.install.in 2012-03-02 10:29:40 +0000
3+++ debian/unity-2d-shell.install.in 2012-03-29 12:58:23 +0000
4@@ -7,3 +7,4 @@
5 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/launcher
6 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/common
7 @DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/artwork
8+@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/shortcutoverlay
9
10=== modified file 'shell/Shell.qml'
11--- shell/Shell.qml 2012-03-20 14:50:42 +0000
12+++ shell/Shell.qml 2012-03-29 12:58:23 +0000
13@@ -108,6 +108,20 @@
14
15 Behavior on x { NumberAnimation { id: launcherLoaderXAnimation; duration: 125 } }
16
17+ Connections {
18+ target: declarativeView
19+ onDashActiveChanged: {
20+ if (declarativeView.dashActive) {
21+ shortcutHintLoader.source = ""
22+ launcherLoader.visibilityController.beginForceVisible("dash")
23+ }
24+ else {
25+ launcherLoader.visibilityController.endForceVisible("dash")
26+ if (dashLoader.status == Loader.Ready) dashLoader.item.deactivateAllLenses()
27+ }
28+ }
29+ }
30+
31 SpreadMonitor {
32 id: spread
33 onShownChanged: if (shown) {
34@@ -153,6 +167,23 @@
35 }
36 }
37 }
38+ onSuperKeyHeldChanged: {
39+ shortcutHintLoader.source = ""
40+ if(superKeyHeld && (shell.width > 1024 || shell.height > 768) &&
41+ declarativeView.screen.screen == shellManager.activeShellScreen) {
42+ shortcutHintLoader.source = "shortcutoverlay/ShortcutHint.qml"
43+ shortcutHintLoader.item.trigger()
44+ if (dashLoader.item.active) {
45+ dashLoader.item.active = false
46+ }
47+ }
48+ }
49+ }
50+
51+ Loader {
52+ id: shortcutHintLoader
53+ anchors.centerIn: parent
54+ onLoaded: { declarativeView.forceActivateWindow(); item.forceActiveFocus(); }
55 }
56
57 Connections {
58@@ -171,6 +202,9 @@
59 the shell doesn't react to activeFocus at all.
60 See: https://bugreports.qt.nokia.com/browse/QTBUG-19688 */
61 if (!declarativeView.focus && launcherLoader.activeFocus) shell.focus = true
62+ if (!declarativeView.focus && shortcutHintLoader.status == Loader.Ready) {
63+ shortcutHintLoader.source = ""
64+ }
65 }
66 }
67
68
69=== modified file 'shell/app/shellmanager.cpp'
70--- shell/app/shellmanager.cpp 2012-03-16 11:03:24 +0000
71+++ shell/app/shellmanager.cpp 2012-03-29 12:58:23 +0000
72@@ -541,6 +541,17 @@
73 }
74 }
75
76+int
77+ShellManager::activeShellScreen() const
78+{
79+ ShellDeclarativeView * activeShell = d->activeShell(ShellManagerPrivate::ActiveShellLauncherRelatedUse);
80+ if (activeShell) {
81+ return activeShell->screen()->screen();
82+ } else {
83+ return -1;
84+ }
85+}
86+
87 /*------------------ Hotkeys Handling -----------------------*/
88
89 void
90
91=== modified file 'shell/app/shellmanager.h'
92--- shell/app/shellmanager.h 2012-03-14 08:29:06 +0000
93+++ shell/app/shellmanager.h 2012-03-29 12:58:23 +0000
94@@ -44,6 +44,7 @@
95 Q_PROPERTY(int hudScreen READ hudScreen NOTIFY hudScreenChanged)
96 Q_PROPERTY(unsigned int lastFocusedWindow READ lastFocusedWindow NOTIFY lastFocusedWindowChanged)
97
98+ Q_PROPERTY(int activeShellScreen READ activeShellScreen)
99 public:
100 enum DashMode {
101 DesktopMode,
102@@ -79,6 +80,8 @@
103
104 int hudScreen() const;
105
106+ int activeShellScreen() const;
107+
108 unsigned int lastFocusedWindow() const;
109
110 void forceActivateShell(ShellDeclarativeView *shell);
111
112=== added directory 'shell/shortcutoverlay'
113=== added file 'shell/shortcutoverlay/ModelElement.qml'
114--- shell/shortcutoverlay/ModelElement.qml 1970-01-01 00:00:00 +0000
115+++ shell/shortcutoverlay/ModelElement.qml 2012-03-29 12:58:23 +0000
116@@ -0,0 +1,26 @@
117+/*
118+ * This file is part of unity-2d
119+ *
120+ * Copyright 2012 Canonical Ltd.
121+ *
122+ * This program is free software; you can redistribute it and/or modify
123+ * it under the terms of the GNU General Public License as published by
124+ * the Free Software Foundation; version 3.
125+ *
126+ * This program is distributed in the hope that it will be useful,
127+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
128+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129+ * GNU General Public License for more details.
130+ *
131+ * You should have received a copy of the GNU General Public License
132+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
133+ */
134+
135+import QtQuick 1.1
136+
137+QtObject {
138+ property string sectionId
139+ property string defaultKey
140+ property string gconfKey
141+ property string description
142+}
143
144=== added file 'shell/shortcutoverlay/ShortcutHint.qml'
145--- shell/shortcutoverlay/ShortcutHint.qml 1970-01-01 00:00:00 +0000
146+++ shell/shortcutoverlay/ShortcutHint.qml 2012-03-29 12:58:23 +0000
147@@ -0,0 +1,243 @@
148+/*
149+ * This file is part of unity-2d
150+ *
151+ * Copyright 2011 Canonical Ltd.
152+ *
153+ * This program is free software; you can redistribute it and/or modify
154+ * it under the terms of the GNU General Public License as published by
155+ * the Free Software Foundation; version 3.
156+ *
157+ * This program is distributed in the hope that it will be useful,
158+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
159+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
160+ * GNU General Public License for more details.
161+ *
162+ * You should have received a copy of the GNU General Public License
163+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
164+ */
165+import QtQuick 1.1
166+import Effects 1.0
167+import "../common"
168+import "../common/utils.js" as Utils
169+
170+Item {
171+ id: shortcutHintOverlay
172+ objectName: "shortcutHintOverlay"
173+ width: 950
174+ height: 660
175+ focus: true
176+
177+ Accessible.name: "Shortcut Hints"
178+
179+ LayoutMirroring.enabled: Utils.isRightToLeft()
180+ LayoutMirroring.childrenInherit: true
181+
182+ property bool active: false
183+ property bool activeTriggerHelper: true
184+ property bool reallyActive: active && activeTriggerHelper
185+ function trigger()
186+ {
187+ activeTriggerHelper = false
188+ activeTriggerHelper = true
189+ }
190+
191+ BorderImage {
192+ id: border
193+ smooth: true
194+ anchors.fill: parent
195+ border { left: 20; top: 20; right: 20; bottom: 20 }
196+ source: "artwork/shortcut_hint_borders.png"
197+ horizontalTileMode: BorderImage.Repeat
198+ verticalTileMode: BorderImage.Repeat
199+ }
200+
201+ /* Note: ListElement: cannot use script for property value
202+ So we can't use u2d.tr for display text directly.
203+ Workaround for QML bug : https://bugreports.qt-project.org/browse/QTBUG-16289
204+ */
205+ property list<ModelElement> leftColumnModel: [
206+ ModelElement { sectionId: "launcher"; description: u2d.tr("Launcher") },
207+ ModelElement { sectionId: "dash"; description: u2d.tr("Dash") },
208+ ModelElement { sectionId: "topBar"; description: u2d.tr("Top Bar") }
209+ ]
210+
211+ property list<ModelElement> rightColumnModel: [
212+ ModelElement { sectionId: "switching"; description: u2d.tr("Switching") },
213+ ModelElement { sectionId: "workspaces"; description: u2d.tr("Workspaces") },
214+ ModelElement { sectionId: "windows"; description: u2d.tr("Windows") }
215+ ]
216+
217+ property list<ModelElement> launcherModel: [
218+ ModelElement { defaultKey: "Super (Press)"; description: u2d.tr("Open Launcher, displays shortcuts."); gconfKey: "" },
219+ ModelElement { defaultKey: "Alt + F1"; description: u2d.tr("Open Launcher keyboard navigation mode."); gconfKey: "" },
220+ ModelElement { defaultKey: "Super + Tab"; description: u2d.tr("Switch applications via Launcher."); gconfKey: ""},
221+ ModelElement { defaultKey: "Super + 1 to 9"; description: u2d.tr("Same as clicking on a Launcher icon."); gconfKey: "" },
222+ ModelElement { defaultKey: "Super + Shift + 1 to 9"; description: u2d.tr("Open new window of the app."); gconfKey: "" },
223+ ModelElement { defaultKey: "Super + T"; description: u2d.tr("Open the Rubbish Bin."); gconfKey: "" }
224+ ]
225+
226+ property list<ModelElement> dashModel: [
227+ ModelElement { defaultKey: "Super (Tap)"; description: u2d.tr("Open the Dash home."); gconfKey: "" },
228+ ModelElement { defaultKey: "Super + A"; description: u2d.tr("Open the Dash App Lens."); gconfKey: "" },
229+ ModelElement { defaultKey: "Super + F"; description: u2d.tr("Open the Dash Files Lens."); gconfKey: "" },
230+ ModelElement { defaultKey: "Super + M"; description: u2d.tr("Open the Dash Files Music."); gconfKey: "" },
231+ ModelElement { defaultKey: "Ctrl + Tab"; description: u2d.tr("Switches between Lenses."); gconfKey: "" },
232+ ModelElement { defaultKey: "Cursors Keys"; description: u2d.tr("Moves the focus."); gconfKey: "" },
233+ ModelElement { defaultKey: "Enter / Return"; description: u2d.tr("Open currently focused item."); gconfKey: "" },
234+ ModelElement { defaultKey: "Alt + F2"; description: u2d.tr("'Run Command' mode."); gconfKey: "" }
235+ ]
236+
237+ property list<ModelElement> topBarModel: [
238+ ModelElement { defaultKey: "Alt"; description: u2d.tr("Reveals application menu."); gconfKey: "" },
239+ ModelElement { defaultKey: "Alt + F10"; description: u2d.tr("Open the indicator menu."); gconfKey: "" },
240+ ModelElement { defaultKey: "Cursor Left & Right"; description: u2d.tr("Moves focus between indicators."); gconfKey: "" }
241+ ]
242+
243+ property list<ModelElement> switchingModel: [
244+ ModelElement { defaultKey: "Alt + Tab"; description: u2d.tr("Switch between applications."); gconfKey: "/apps/metacity/global_keybindings/switch_windows" },
245+ ModelElement { defaultKey: "Alt + Grave"; description: u2d.tr("Switch windows of current application."); gconfKey: "/apps/metacity/global_keybindings/cycle_group" },
246+ ModelElement { defaultKey: "Cursor Up"; description: u2d.tr("Close window switch, return to app switch."); gconfKey: "" },
247+ ModelElement { defaultKey: "Cursor Left & Right"; description: u2d.tr("Moves the focus."); gconfKey: "" }
248+ ]
249+
250+ property list<ModelElement> workspacesModel: [
251+ ModelElement { defaultKey: "Super + S"; description: u2d.tr("Spread workspaces."); gconfKey: "" },
252+ ModelElement { defaultKey: "Super + Cursors"; description: u2d.tr("Switch workspaces."); gconfKey: "/apps/metacity/global_keybindings/;switch_to_workspace_down;switch_to_workspace_up;switch_to_workspace_left;switch_to_workspace_right" },
253+ ModelElement { defaultKey: "Super + Alt + Cursors"; description: u2d.tr("Move focused window to other workspace."); gconfKey: "/apps/metacity/window_keybindings/;move_to_workspace_down;move_to_workspace_left;move_to_workspace_right;move_to_workspace_up" }
254+ ]
255+
256+ property list<ModelElement> windowModel: [
257+ ModelElement { defaultKey: "Super + W"; description: u2d.tr("Spreads all windows in the current workspace."); gconfKey: "" },
258+ ModelElement { defaultKey: "Super + D"; description: u2d.tr("Minimizes all windows."); gconfKey: "/apps/metacity/global_keybindings/show_desktop" },
259+ ModelElement { defaultKey: "Alt + Space"; description: u2d.tr("Opens window accessibility menu."); gconfKey: "/apps/metacity/window_keybindings/activate_window_menu" },
260+ ModelElement { defaultKey: "Alt + F10"; description: u2d.tr("Maximizes or un-maximizes current window."); gconfKey: "/apps/metacity/window_keybindings/toggle_maximized" },
261+ ModelElement { defaultKey: "Alt + F9"; description: u2d.tr("Minimizes current window."); gconfKey: "/apps/metacity/window_keybindings/minimize" },
262+ ModelElement { defaultKey: "Alt + F8"; description: u2d.tr("Resizes current window."); gconfKey: "/apps/metacity/window_keybindings/begin_resize" },
263+ ModelElement { defaultKey: "Alt + F4"; description: u2d.tr("Closes current window."); gconfKey: "/apps/metacity/window_keybindings/close" },
264+ ModelElement { defaultKey: "Ctrl + Alt + Num"; description: u2d.tr("Places window in corresponding positions."); gconfKey: "/apps/metacity/window_keybindings/;move_to_corner_ne;move_to_corner_nw;move_to_corner_se;move_to_corner_sw;move_to_side_e;move_to_side_n;move_to_side_s;move_to_side_w" },
265+ ModelElement { defaultKey: "Alt + Left Mouse Drag"; description: u2d.tr("Move window."); gconfKey: "" },
266+ ModelElement { defaultKey: "Alt + Middle Mouse Drag"; description: u2d.tr("Resize window."); gconfKey: "" }
267+ ]
268+
269+ Rectangle {
270+ id: totalArea
271+ color: "#00000000"
272+ radius: 8
273+ smooth: true
274+ anchors.fill: parent
275+ anchors.margins: 12
276+ clip: true
277+
278+ Item {
279+ anchors.fill: parent
280+ clip: true
281+
282+ Image {
283+ id: blurredBackground
284+ effect: Blur {}
285+ source: reallyActive ? "image://window/root" : ""
286+ fillMode: Image.PreserveAspectCrop
287+ cache: false
288+ x: -blurredBackground.mapToItem(null, 0, 0).x-totalArea.anchors.leftMargin
289+ y: -blurredBackground.mapToItem(null, 0, 0).y-totalArea.anchors.topMargin-declarativeView.screen.availableGeometry.y
290+ }
291+
292+ Rectangle {
293+ anchors.fill: parent
294+ color: "#000000"
295+ opacity: 0.70
296+ }
297+ }
298+
299+ Item {
300+ id: headerArea
301+ y: 0
302+ height: 75
303+ anchors.left: parent.left
304+ anchors.right: parent.right
305+ smooth: false
306+
307+ TextCustom {
308+ id: title
309+ x: 350
310+ y: 25
311+ text: u2d.tr("Keyboard Shortcuts")
312+ anchors.bottom: parent.bottom
313+ anchors.bottomMargin: 22
314+ anchors.horizontalCenterOffset: 0
315+ verticalAlignment: Text.AlignTop
316+ anchors.horizontalCenter: parent.horizontalCenter
317+ smooth: true
318+ font.bold: true
319+ horizontalAlignment: Text.AlignHCenter
320+ fontSize: "x-large"
321+ }
322+ }
323+
324+ Item {
325+ id: contentsArea
326+ anchors.top: headerArea.bottom
327+ anchors.right: parent.right
328+ anchors.bottom: parent.bottom
329+ anchors.left: parent.left
330+ anchors.leftMargin: 20
331+ anchors.rightMargin: 20
332+
333+ Rectangle {
334+ id: topDivider
335+ width: 200
336+ height: 1
337+ color: "#ffffff"
338+ opacity: 0.2
339+ smooth: true
340+ anchors.left: parent.left
341+ anchors.right: parent.right
342+ anchors.top: parent.top
343+ }
344+
345+ Item {
346+ id: contentLeft
347+ anchors.left: parent.left
348+ anchors.right: contentCenter.left
349+ anchors.top: topDivider.bottom
350+ anchors.bottom: parent.bottom
351+
352+ Column {
353+ id: leftColumn
354+ Repeater {
355+ model: leftColumnModel
356+ ShortcutHintSection {}
357+ }
358+ }
359+ }
360+
361+ Item {
362+ id: contentCenter
363+ x: 438
364+ width: 40
365+ anchors.top: parent.top
366+ anchors.bottom: parent.bottom
367+ anchors.horizontalCenter: parent.horizontalCenter
368+ }
369+
370+ Item {
371+ id: contentRight
372+ x: 445
373+ y: 0
374+ width: 445
375+ anchors.left: contentCenter.right
376+ anchors.right: parent.right
377+ anchors.top: parent.top
378+ anchors.bottom: parent.bottom
379+
380+ Column {
381+ id: rightColumn
382+ Repeater {
383+ model: rightColumnModel
384+ ShortcutHintSection {}
385+ }
386+ }
387+ }
388+ }
389+ }
390+}
391
392=== added file 'shell/shortcutoverlay/ShortcutHintSection.qml'
393--- shell/shortcutoverlay/ShortcutHintSection.qml 1970-01-01 00:00:00 +0000
394+++ shell/shortcutoverlay/ShortcutHintSection.qml 2012-03-29 12:58:23 +0000
395@@ -0,0 +1,165 @@
396+/*
397+ * This file is part of unity-2d
398+ *
399+ * Copyright 2011 Canonical Ltd.
400+ *
401+ * This program is free software; you can redistribute it and/or modify
402+ * it under the terms of the GNU General Public License as published by
403+ * the Free Software Foundation; version 3.
404+ *
405+ * This program is distributed in the hope that it will be useful,
406+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
407+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
408+ * GNU General Public License for more details.
409+ *
410+ * You should have received a copy of the GNU General Public License
411+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
412+ */
413+import QtQuick 1.0
414+import "../common"
415+
416+Item {
417+ id: shortcutHitSection
418+ width: 430
419+ height: list.height + sectionTitle.height + sectionTitle.y + bottomSpacing.height + divider.height
420+
421+ // It is decided by design, that certain keys having multiple values in gconf,
422+ // like 'Switch workspaces' should only be displayed when the keys are symmetric.
423+ function symmetricKey( gconfKey ) {
424+ var gconfKeys = gconfKey.split(";");
425+ var previousModifier = ""
426+ var count = gconfKeys.length
427+ var gconfKey_base = gconfKeys[0]
428+ for (var i = 1; i < count; i++) {
429+ var gconfItem = Qt.createQmlObject('import gconf 0.1; GConfItem {}', shortcutHintOverlay);
430+ gconfItem.key = gconfKey_base+gconfKeys[i]
431+ var gconfValue = String(gconfItem.value)
432+ var modifier = gconfValue.substring(0,gconfValue.lastIndexOf(">")+1)
433+ var key = gconfValue.substring(gconfValue.lastIndexOf(">")+1)
434+ if (previousModifier == "") {
435+ previousModifier = gconfValue.substring(0,gconfValue.lastIndexOf(">")+1)
436+ continue
437+ } else {
438+ if (modifier != previousModifier) {
439+ return ""
440+ }
441+ }
442+ }
443+
444+ if (key.toLowerCase().indexOf("kp") == 0){
445+ previousModifier = previousModifier + "Num"
446+ } else {
447+ previousModifier = previousModifier + "Cursors"
448+ }
449+
450+ return previousModifier;
451+ }
452+
453+ Component {
454+ id: itemDelegate
455+ Item {
456+ anchors.right: parent.right
457+ anchors.left: parent.left
458+
459+ function getShortcutKey() {
460+ if (model.modelData.gconfKey === "") {
461+ return model.modelData.defaultKey;
462+ }
463+
464+ var key = ""
465+ // Check is symmetric
466+ if (gconfKey.indexOf(";") != -1) {
467+ key = symmetricKey(gconfKey);
468+ if (key == "") {
469+ return ""
470+ }
471+ } else {
472+ var gconfItem = Qt.createQmlObject('import gconf 0.1; GConfItem {}', shortcutHintOverlay);
473+ gconfItem.key = gconfKey
474+ key = gconfItem.value
475+ }
476+
477+ key = String(key)
478+ if (key === "") {
479+ return model.modelData.defaultKey
480+ }
481+
482+ key = key.replace(new RegExp( "<Control>", 'gi' ), "Ctrl + ")
483+ key = key.replace(new RegExp( "<Shift>", 'gi' ), "Shift + ")
484+ key = key.replace(new RegExp( "<Primary>", 'gi' ), "")
485+ key = key.replace(new RegExp( "<Alt>", 'gi' ), "Alt + ")
486+ key = key.replace(new RegExp( "<Mod4>", 'gi' ), "Super + ")
487+ key = key.replace(new RegExp( "<Super>", 'gi' ), "Super + ")
488+ key = key.replace(new RegExp( "KP_", 'gi' ), "Num")
489+ key = key.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
490+ return key
491+ }
492+
493+ Item {
494+ id: key
495+ anchors.left: parent.left
496+ anchors.leftMargin: 0
497+ width: 150
498+ TextCustom { id: keyText; text: getShortcutKey(); fontSize: "small" }
499+ }
500+
501+ Item {
502+ id: spacing
503+ anchors.left: key.right
504+ width: 10
505+ }
506+
507+ Item {
508+ id: value
509+ width: 265
510+ anchors.left: spacing.right
511+ TextCustom { text: model.modelData.description; fontSize: "small" }
512+ }
513+ }
514+ }
515+
516+ TextCustom {
517+ id: sectionTitle
518+ y: 27
519+ text: model.modelData.description
520+ anchors.left: parent.left
521+ font.bold: true
522+ fontSize: "large"
523+ }
524+
525+ ListView {
526+ id: list
527+ model: {
528+ if (sectionId == "launcher") return launcherModel
529+ else if (sectionId == "dash") return dashModel
530+ else if (sectionId == "topBar") return topBarModel
531+ else if (sectionId == "switching") return switchingModel
532+ else if (sectionId == "workspaces") return workspacesModel
533+ else if (sectionId == "windows") return windowModel
534+ else return ""
535+ }
536+ spacing: 18
537+ anchors.left: parent.left
538+ anchors.top: sectionTitle.bottom
539+ anchors.topMargin: 14
540+ height: (spacing * count) + anchors.topMargin
541+ delegate: itemDelegate
542+ }
543+
544+ Item {
545+ id: bottomSpacing
546+ height: 20
547+ }
548+
549+ Rectangle {
550+ id: divider
551+ height: 1
552+ color: "#ffffff"
553+ smooth: true
554+ anchors.top: shortcutHitSection.bottom
555+ anchors.right: parent.right
556+ anchors.left: parent.left
557+ opacity: 0.2
558+ visible: (index != 2)
559+ }
560+}
561
562=== added directory 'shell/shortcutoverlay/artwork'
563=== added file 'shell/shortcutoverlay/artwork/shortcut_hint_borders.png'
564Binary files shell/shortcutoverlay/artwork/shortcut_hint_borders.png 1970-01-01 00:00:00 +0000 and shell/shortcutoverlay/artwork/shortcut_hint_borders.png 2012-03-29 12:58:23 +0000 differ
565=== added file 'tests/shell/shortcut-hint-overlay-tests.rb'
566--- tests/shell/shortcut-hint-overlay-tests.rb 1970-01-01 00:00:00 +0000
567+++ tests/shell/shortcut-hint-overlay-tests.rb 2012-03-29 12:58:23 +0000
568@@ -0,0 +1,89 @@
569+#!/usr/bin/env ruby1.8
570+=begin
571+/*
572+ * This file is part of unity-2d
573+ *
574+ * Copyright 2011 Canonical Ltd.
575+ *
576+ * This program is free software; you can redistribute it and/or modify
577+ * it under the terms of the GNU General Public License as published by
578+ * the Free Software Foundation; version 3.
579+ *
580+ * This program is distributed in the hope that it will be useful,
581+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
582+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
583+ * GNU General Public License for more details.
584+ *
585+ * You should have received a copy of the GNU General Public License
586+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
587+ */
588+=end
589+
590+require '../run-tests.rb' unless $INIT_COMPLETED
591+require 'xdo/xwindow'
592+require 'xdo/keyboard'
593+
594+############################# Test Suite #############################
595+context "Launcher Shortcut hint overlay Tests" do
596+ # Run once at the beginning of this test suite
597+ startup do
598+ $SUT.execute_shell_command 'killall unity-2d-shell'
599+ $SUT.execute_shell_command 'killall unity-2d-shell'
600+
601+ # Minimize all windows
602+ XDo::XWindow.toggle_minimize_all
603+ end
604+
605+ # Run once at the end of this test suite
606+ shutdown do
607+ end
608+
609+ # Run before each test case begins
610+ setup do
611+ # Execute the application
612+ @app = $SUT.run( :name => UNITY_2D_SHELL,
613+ :arguments => "-testability",
614+ :sleeptime => 2 )
615+ # Make certain application is ready for testing
616+ verify{ @app.Launcher() }
617+ end
618+
619+ # Run after each test case completes
620+ teardown do
621+ $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
622+ end
623+
624+ #####################################################################################
625+ # Test cases
626+ # Test case objectives:
627+ # * Check shortcut hint overlay display/close
628+ # Pre-conditions
629+ # * None
630+ # Test steps
631+ # * Hold super key
632+ # * Check the shortcut hint overlay is displayed
633+ # * Release super key
634+ # * Check that shortcut hint overlay is closed
635+ # Post-conditions
636+ # * None
637+ # References
638+ # * lp:#855532
639+ test "Check shortcut hint overlay display/close" do
640+ # Check the hint window is not displayed initially
641+ verify_not(TIMEOUT, 'Shortcut hint overlay should be closed, but visible') {
642+ @app.ShellDeclarativeView().ShortcutHint();
643+ }
644+
645+ XDo::Keyboard.key_down('SUPER')
646+ # Check the hint window is displayed when 'super' is pressed
647+ verify(TIMEOUT, 'Shortcut hint overlay should be displayed, but it is not') {
648+ @app.ShellDeclarativeView().ShortcutHint();
649+ }
650+
651+ XDo::Keyboard.key_up('SUPER')
652+ # Check the hint window is closed when 'super' is released
653+ verify_not(TIMEOUT, 'Shortcut hint overlay should be closed, but visible') {
654+ @app.ShellDeclarativeView().ShortcutHint();
655+ }
656+ end
657+end

Subscribers

People subscribed via source and target branches