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

Proposed by Lohith D Shivamurthy
Status: Rejected
Rejected by: Albert Astals Cid
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) Needs Fixing
Michał Sawicz Needs Information
Florian Boucault (community) Needs Fixing
Gerry Boland 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.
Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

Please resubmit the MR against lp:unity-2d

Revision history for this message
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
Revision history for this message
Florian Boucault (fboucault) wrote :

No need to expose GConfItem through our plugin, just:

import gconf 1.0

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

The shortcut overlay needs a blurred background, per design

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

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

Revision history for this message
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
Revision history for this message
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
Revision history for this message
Florian Boucault (fboucault) wrote :

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

review: Needs Fixing
Revision history for this message
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?

Revision history for this message
Florian Boucault (fboucault) wrote :

Please use TextCustom and its fontSize property instead of Text.

review: Needs Fixing
Revision history for this message
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

Directly import gconf 0.1

966. By Lohith D Shivamurthy

keep object id same as objectname

967. By Lohith D Shivamurthy

Add a FIXME for i18n of display strings

968. By Lohith D Shivamurthy

Remove background color

969. By Lohith D Shivamurthy

Use TextCustom instead of Text element

970. By Lohith D Shivamurthy

Fix missing parent object

971. By Lohith D Shivamurthy

Apply blur background

972. By Lohith D Shivamurthy

Activate/Deactivate overlay in shell.qml

973. By Lohith D Shivamurthy

Deactivate the overlay on tapping launcher tile shortcuts

Revision history for this message
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

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

Revision history for this message
Albert Astals Cid (aacid) wrote :

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

Revision history for this message
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

Improve background

976. By Lohith D Shivamurthy

Use workaround mentioned in the bugreport

977. By Lohith D Shivamurthy

Use regExp to replace case-insensitively

978. By Lohith D Shivamurthy

Replace Shft with Shift

979. By Lohith D Shivamurthy

Add missing file ModelElement.qml

980. By Lohith D Shivamurthy

merge

981. By Lohith D Shivamurthy

Remove extra field from ModelElement.qml

982. By Lohith D Shivamurthy

deactivate overlay when view looses focus

983. By Lohith D Shivamurthy

Apply black background with 70% opacity

984. By Tiago Salem Herrmann

merge trunk

985. By Tiago Salem Herrmann

onSuperKeyHeldChanged was moved to shellManager

986. By Tiago Salem Herrmann

remove debug

987. By Tiago Salem Herrmann

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

988. By Tiago Salem Herrmann

fix white spaces

989. By Tiago Salem Herrmann

ignore <Primary> string

990. By Tiago Salem Herrmann

merge trunk

991. By Tiago Salem Herrmann

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

992. By Gerry Boland

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

993. By Gerry Boland

QtQuick1.0 not needed to read gconf values

994. By Gerry Boland

Add basic RTL support

995. By Gerry Boland

[debian] Install shortcut overlay QML files

Revision history for this message
Albert Astals Cid (aacid) wrote :

The "Alt (Tap) shows HUD" is missing

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

review: Needs Fixing
Revision history for this message
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
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

review: Needs Fixing
Revision history for this message
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

[debian] Install shortcut overlay QML files

994. By Gerry Boland

Add basic RTL support

993. By Gerry Boland

QtQuick1.0 not needed to read gconf values

992. By Gerry Boland

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

991. By Tiago Salem Herrmann

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

990. By Tiago Salem Herrmann

merge trunk

989. By Tiago Salem Herrmann

ignore <Primary> string

988. By Tiago Salem Herrmann

fix white spaces

987. By Tiago Salem Herrmann

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

986. By Tiago Salem Herrmann

remove debug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/unity-2d-shell.install.in'
--- debian/unity-2d-shell.install.in 2012-03-02 10:29:40 +0000
+++ debian/unity-2d-shell.install.in 2012-03-29 12:58:23 +0000
@@ -7,3 +7,4 @@
7@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/launcher7@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/launcher
8@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/common8@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/common
9@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/artwork9@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/artwork
10@DEBIAN_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/unity-2d/shell/shortcutoverlay
1011
=== modified file 'shell/Shell.qml'
--- shell/Shell.qml 2012-03-20 14:50:42 +0000
+++ shell/Shell.qml 2012-03-29 12:58:23 +0000
@@ -108,6 +108,20 @@
108108
109 Behavior on x { NumberAnimation { id: launcherLoaderXAnimation; duration: 125 } }109 Behavior on x { NumberAnimation { id: launcherLoaderXAnimation; duration: 125 } }
110110
111 Connections {
112 target: declarativeView
113 onDashActiveChanged: {
114 if (declarativeView.dashActive) {
115 shortcutHintLoader.source = ""
116 launcherLoader.visibilityController.beginForceVisible("dash")
117 }
118 else {
119 launcherLoader.visibilityController.endForceVisible("dash")
120 if (dashLoader.status == Loader.Ready) dashLoader.item.deactivateAllLenses()
121 }
122 }
123 }
124
111 SpreadMonitor {125 SpreadMonitor {
112 id: spread126 id: spread
113 onShownChanged: if (shown) {127 onShownChanged: if (shown) {
@@ -153,6 +167,23 @@
153 }167 }
154 }168 }
155 }169 }
170 onSuperKeyHeldChanged: {
171 shortcutHintLoader.source = ""
172 if(superKeyHeld && (shell.width > 1024 || shell.height > 768) &&
173 declarativeView.screen.screen == shellManager.activeShellScreen) {
174 shortcutHintLoader.source = "shortcutoverlay/ShortcutHint.qml"
175 shortcutHintLoader.item.trigger()
176 if (dashLoader.item.active) {
177 dashLoader.item.active = false
178 }
179 }
180 }
181 }
182
183 Loader {
184 id: shortcutHintLoader
185 anchors.centerIn: parent
186 onLoaded: { declarativeView.forceActivateWindow(); item.forceActiveFocus(); }
156 }187 }
157188
158 Connections {189 Connections {
@@ -171,6 +202,9 @@
171 the shell doesn't react to activeFocus at all.202 the shell doesn't react to activeFocus at all.
172 See: https://bugreports.qt.nokia.com/browse/QTBUG-19688 */203 See: https://bugreports.qt.nokia.com/browse/QTBUG-19688 */
173 if (!declarativeView.focus && launcherLoader.activeFocus) shell.focus = true204 if (!declarativeView.focus && launcherLoader.activeFocus) shell.focus = true
205 if (!declarativeView.focus && shortcutHintLoader.status == Loader.Ready) {
206 shortcutHintLoader.source = ""
207 }
174 }208 }
175 }209 }
176210
177211
=== modified file 'shell/app/shellmanager.cpp'
--- shell/app/shellmanager.cpp 2012-03-16 11:03:24 +0000
+++ shell/app/shellmanager.cpp 2012-03-29 12:58:23 +0000
@@ -541,6 +541,17 @@
541 }541 }
542}542}
543543
544int
545ShellManager::activeShellScreen() const
546{
547 ShellDeclarativeView * activeShell = d->activeShell(ShellManagerPrivate::ActiveShellLauncherRelatedUse);
548 if (activeShell) {
549 return activeShell->screen()->screen();
550 } else {
551 return -1;
552 }
553}
554
544/*------------------ Hotkeys Handling -----------------------*/555/*------------------ Hotkeys Handling -----------------------*/
545556
546void557void
547558
=== modified file 'shell/app/shellmanager.h'
--- shell/app/shellmanager.h 2012-03-14 08:29:06 +0000
+++ shell/app/shellmanager.h 2012-03-29 12:58:23 +0000
@@ -44,6 +44,7 @@
44 Q_PROPERTY(int hudScreen READ hudScreen NOTIFY hudScreenChanged)44 Q_PROPERTY(int hudScreen READ hudScreen NOTIFY hudScreenChanged)
45 Q_PROPERTY(unsigned int lastFocusedWindow READ lastFocusedWindow NOTIFY lastFocusedWindowChanged)45 Q_PROPERTY(unsigned int lastFocusedWindow READ lastFocusedWindow NOTIFY lastFocusedWindowChanged)
4646
47 Q_PROPERTY(int activeShellScreen READ activeShellScreen)
47public:48public:
48 enum DashMode {49 enum DashMode {
49 DesktopMode,50 DesktopMode,
@@ -79,6 +80,8 @@
7980
80 int hudScreen() const;81 int hudScreen() const;
8182
83 int activeShellScreen() const;
84
82 unsigned int lastFocusedWindow() const;85 unsigned int lastFocusedWindow() const;
8386
84 void forceActivateShell(ShellDeclarativeView *shell);87 void forceActivateShell(ShellDeclarativeView *shell);
8588
=== added directory 'shell/shortcutoverlay'
=== added file 'shell/shortcutoverlay/ModelElement.qml'
--- shell/shortcutoverlay/ModelElement.qml 1970-01-01 00:00:00 +0000
+++ shell/shortcutoverlay/ModelElement.qml 2012-03-29 12:58:23 +0000
@@ -0,0 +1,26 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2012 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19import QtQuick 1.1
20
21QtObject {
22 property string sectionId
23 property string defaultKey
24 property string gconfKey
25 property string description
26}
027
=== added file 'shell/shortcutoverlay/ShortcutHint.qml'
--- shell/shortcutoverlay/ShortcutHint.qml 1970-01-01 00:00:00 +0000
+++ shell/shortcutoverlay/ShortcutHint.qml 2012-03-29 12:58:23 +0000
@@ -0,0 +1,243 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18import QtQuick 1.1
19import Effects 1.0
20import "../common"
21import "../common/utils.js" as Utils
22
23Item {
24 id: shortcutHintOverlay
25 objectName: "shortcutHintOverlay"
26 width: 950
27 height: 660
28 focus: true
29
30 Accessible.name: "Shortcut Hints"
31
32 LayoutMirroring.enabled: Utils.isRightToLeft()
33 LayoutMirroring.childrenInherit: true
34
35 property bool active: false
36 property bool activeTriggerHelper: true
37 property bool reallyActive: active && activeTriggerHelper
38 function trigger()
39 {
40 activeTriggerHelper = false
41 activeTriggerHelper = true
42 }
43
44 BorderImage {
45 id: border
46 smooth: true
47 anchors.fill: parent
48 border { left: 20; top: 20; right: 20; bottom: 20 }
49 source: "artwork/shortcut_hint_borders.png"
50 horizontalTileMode: BorderImage.Repeat
51 verticalTileMode: BorderImage.Repeat
52 }
53
54 /* Note: ListElement: cannot use script for property value
55 So we can't use u2d.tr for display text directly.
56 Workaround for QML bug : https://bugreports.qt-project.org/browse/QTBUG-16289
57 */
58 property list<ModelElement> leftColumnModel: [
59 ModelElement { sectionId: "launcher"; description: u2d.tr("Launcher") },
60 ModelElement { sectionId: "dash"; description: u2d.tr("Dash") },
61 ModelElement { sectionId: "topBar"; description: u2d.tr("Top Bar") }
62 ]
63
64 property list<ModelElement> rightColumnModel: [
65 ModelElement { sectionId: "switching"; description: u2d.tr("Switching") },
66 ModelElement { sectionId: "workspaces"; description: u2d.tr("Workspaces") },
67 ModelElement { sectionId: "windows"; description: u2d.tr("Windows") }
68 ]
69
70 property list<ModelElement> launcherModel: [
71 ModelElement { defaultKey: "Super (Press)"; description: u2d.tr("Open Launcher, displays shortcuts."); gconfKey: "" },
72 ModelElement { defaultKey: "Alt + F1"; description: u2d.tr("Open Launcher keyboard navigation mode."); gconfKey: "" },
73 ModelElement { defaultKey: "Super + Tab"; description: u2d.tr("Switch applications via Launcher."); gconfKey: ""},
74 ModelElement { defaultKey: "Super + 1 to 9"; description: u2d.tr("Same as clicking on a Launcher icon."); gconfKey: "" },
75 ModelElement { defaultKey: "Super + Shift + 1 to 9"; description: u2d.tr("Open new window of the app."); gconfKey: "" },
76 ModelElement { defaultKey: "Super + T"; description: u2d.tr("Open the Rubbish Bin."); gconfKey: "" }
77 ]
78
79 property list<ModelElement> dashModel: [
80 ModelElement { defaultKey: "Super (Tap)"; description: u2d.tr("Open the Dash home."); gconfKey: "" },
81 ModelElement { defaultKey: "Super + A"; description: u2d.tr("Open the Dash App Lens."); gconfKey: "" },
82 ModelElement { defaultKey: "Super + F"; description: u2d.tr("Open the Dash Files Lens."); gconfKey: "" },
83 ModelElement { defaultKey: "Super + M"; description: u2d.tr("Open the Dash Files Music."); gconfKey: "" },
84 ModelElement { defaultKey: "Ctrl + Tab"; description: u2d.tr("Switches between Lenses."); gconfKey: "" },
85 ModelElement { defaultKey: "Cursors Keys"; description: u2d.tr("Moves the focus."); gconfKey: "" },
86 ModelElement { defaultKey: "Enter / Return"; description: u2d.tr("Open currently focused item."); gconfKey: "" },
87 ModelElement { defaultKey: "Alt + F2"; description: u2d.tr("'Run Command' mode."); gconfKey: "" }
88 ]
89
90 property list<ModelElement> topBarModel: [
91 ModelElement { defaultKey: "Alt"; description: u2d.tr("Reveals application menu."); gconfKey: "" },
92 ModelElement { defaultKey: "Alt + F10"; description: u2d.tr("Open the indicator menu."); gconfKey: "" },
93 ModelElement { defaultKey: "Cursor Left & Right"; description: u2d.tr("Moves focus between indicators."); gconfKey: "" }
94 ]
95
96 property list<ModelElement> switchingModel: [
97 ModelElement { defaultKey: "Alt + Tab"; description: u2d.tr("Switch between applications."); gconfKey: "/apps/metacity/global_keybindings/switch_windows" },
98 ModelElement { defaultKey: "Alt + Grave"; description: u2d.tr("Switch windows of current application."); gconfKey: "/apps/metacity/global_keybindings/cycle_group" },
99 ModelElement { defaultKey: "Cursor Up"; description: u2d.tr("Close window switch, return to app switch."); gconfKey: "" },
100 ModelElement { defaultKey: "Cursor Left & Right"; description: u2d.tr("Moves the focus."); gconfKey: "" }
101 ]
102
103 property list<ModelElement> workspacesModel: [
104 ModelElement { defaultKey: "Super + S"; description: u2d.tr("Spread workspaces."); gconfKey: "" },
105 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" },
106 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" }
107 ]
108
109 property list<ModelElement> windowModel: [
110 ModelElement { defaultKey: "Super + W"; description: u2d.tr("Spreads all windows in the current workspace."); gconfKey: "" },
111 ModelElement { defaultKey: "Super + D"; description: u2d.tr("Minimizes all windows."); gconfKey: "/apps/metacity/global_keybindings/show_desktop" },
112 ModelElement { defaultKey: "Alt + Space"; description: u2d.tr("Opens window accessibility menu."); gconfKey: "/apps/metacity/window_keybindings/activate_window_menu" },
113 ModelElement { defaultKey: "Alt + F10"; description: u2d.tr("Maximizes or un-maximizes current window."); gconfKey: "/apps/metacity/window_keybindings/toggle_maximized" },
114 ModelElement { defaultKey: "Alt + F9"; description: u2d.tr("Minimizes current window."); gconfKey: "/apps/metacity/window_keybindings/minimize" },
115 ModelElement { defaultKey: "Alt + F8"; description: u2d.tr("Resizes current window."); gconfKey: "/apps/metacity/window_keybindings/begin_resize" },
116 ModelElement { defaultKey: "Alt + F4"; description: u2d.tr("Closes current window."); gconfKey: "/apps/metacity/window_keybindings/close" },
117 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" },
118 ModelElement { defaultKey: "Alt + Left Mouse Drag"; description: u2d.tr("Move window."); gconfKey: "" },
119 ModelElement { defaultKey: "Alt + Middle Mouse Drag"; description: u2d.tr("Resize window."); gconfKey: "" }
120 ]
121
122 Rectangle {
123 id: totalArea
124 color: "#00000000"
125 radius: 8
126 smooth: true
127 anchors.fill: parent
128 anchors.margins: 12
129 clip: true
130
131 Item {
132 anchors.fill: parent
133 clip: true
134
135 Image {
136 id: blurredBackground
137 effect: Blur {}
138 source: reallyActive ? "image://window/root" : ""
139 fillMode: Image.PreserveAspectCrop
140 cache: false
141 x: -blurredBackground.mapToItem(null, 0, 0).x-totalArea.anchors.leftMargin
142 y: -blurredBackground.mapToItem(null, 0, 0).y-totalArea.anchors.topMargin-declarativeView.screen.availableGeometry.y
143 }
144
145 Rectangle {
146 anchors.fill: parent
147 color: "#000000"
148 opacity: 0.70
149 }
150 }
151
152 Item {
153 id: headerArea
154 y: 0
155 height: 75
156 anchors.left: parent.left
157 anchors.right: parent.right
158 smooth: false
159
160 TextCustom {
161 id: title
162 x: 350
163 y: 25
164 text: u2d.tr("Keyboard Shortcuts")
165 anchors.bottom: parent.bottom
166 anchors.bottomMargin: 22
167 anchors.horizontalCenterOffset: 0
168 verticalAlignment: Text.AlignTop
169 anchors.horizontalCenter: parent.horizontalCenter
170 smooth: true
171 font.bold: true
172 horizontalAlignment: Text.AlignHCenter
173 fontSize: "x-large"
174 }
175 }
176
177 Item {
178 id: contentsArea
179 anchors.top: headerArea.bottom
180 anchors.right: parent.right
181 anchors.bottom: parent.bottom
182 anchors.left: parent.left
183 anchors.leftMargin: 20
184 anchors.rightMargin: 20
185
186 Rectangle {
187 id: topDivider
188 width: 200
189 height: 1
190 color: "#ffffff"
191 opacity: 0.2
192 smooth: true
193 anchors.left: parent.left
194 anchors.right: parent.right
195 anchors.top: parent.top
196 }
197
198 Item {
199 id: contentLeft
200 anchors.left: parent.left
201 anchors.right: contentCenter.left
202 anchors.top: topDivider.bottom
203 anchors.bottom: parent.bottom
204
205 Column {
206 id: leftColumn
207 Repeater {
208 model: leftColumnModel
209 ShortcutHintSection {}
210 }
211 }
212 }
213
214 Item {
215 id: contentCenter
216 x: 438
217 width: 40
218 anchors.top: parent.top
219 anchors.bottom: parent.bottom
220 anchors.horizontalCenter: parent.horizontalCenter
221 }
222
223 Item {
224 id: contentRight
225 x: 445
226 y: 0
227 width: 445
228 anchors.left: contentCenter.right
229 anchors.right: parent.right
230 anchors.top: parent.top
231 anchors.bottom: parent.bottom
232
233 Column {
234 id: rightColumn
235 Repeater {
236 model: rightColumnModel
237 ShortcutHintSection {}
238 }
239 }
240 }
241 }
242 }
243}
0244
=== added file 'shell/shortcutoverlay/ShortcutHintSection.qml'
--- shell/shortcutoverlay/ShortcutHintSection.qml 1970-01-01 00:00:00 +0000
+++ shell/shortcutoverlay/ShortcutHintSection.qml 2012-03-29 12:58:23 +0000
@@ -0,0 +1,165 @@
1/*
2 * This file is part of unity-2d
3 *
4 * Copyright 2011 Canonical Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18import QtQuick 1.0
19import "../common"
20
21Item {
22 id: shortcutHitSection
23 width: 430
24 height: list.height + sectionTitle.height + sectionTitle.y + bottomSpacing.height + divider.height
25
26 // It is decided by design, that certain keys having multiple values in gconf,
27 // like 'Switch workspaces' should only be displayed when the keys are symmetric.
28 function symmetricKey( gconfKey ) {
29 var gconfKeys = gconfKey.split(";");
30 var previousModifier = ""
31 var count = gconfKeys.length
32 var gconfKey_base = gconfKeys[0]
33 for (var i = 1; i < count; i++) {
34 var gconfItem = Qt.createQmlObject('import gconf 0.1; GConfItem {}', shortcutHintOverlay);
35 gconfItem.key = gconfKey_base+gconfKeys[i]
36 var gconfValue = String(gconfItem.value)
37 var modifier = gconfValue.substring(0,gconfValue.lastIndexOf(">")+1)
38 var key = gconfValue.substring(gconfValue.lastIndexOf(">")+1)
39 if (previousModifier == "") {
40 previousModifier = gconfValue.substring(0,gconfValue.lastIndexOf(">")+1)
41 continue
42 } else {
43 if (modifier != previousModifier) {
44 return ""
45 }
46 }
47 }
48
49 if (key.toLowerCase().indexOf("kp") == 0){
50 previousModifier = previousModifier + "Num"
51 } else {
52 previousModifier = previousModifier + "Cursors"
53 }
54
55 return previousModifier;
56 }
57
58 Component {
59 id: itemDelegate
60 Item {
61 anchors.right: parent.right
62 anchors.left: parent.left
63
64 function getShortcutKey() {
65 if (model.modelData.gconfKey === "") {
66 return model.modelData.defaultKey;
67 }
68
69 var key = ""
70 // Check is symmetric
71 if (gconfKey.indexOf(";") != -1) {
72 key = symmetricKey(gconfKey);
73 if (key == "") {
74 return ""
75 }
76 } else {
77 var gconfItem = Qt.createQmlObject('import gconf 0.1; GConfItem {}', shortcutHintOverlay);
78 gconfItem.key = gconfKey
79 key = gconfItem.value
80 }
81
82 key = String(key)
83 if (key === "") {
84 return model.modelData.defaultKey
85 }
86
87 key = key.replace(new RegExp( "<Control>", 'gi' ), "Ctrl + ")
88 key = key.replace(new RegExp( "<Shift>", 'gi' ), "Shift + ")
89 key = key.replace(new RegExp( "<Primary>", 'gi' ), "")
90 key = key.replace(new RegExp( "<Alt>", 'gi' ), "Alt + ")
91 key = key.replace(new RegExp( "<Mod4>", 'gi' ), "Super + ")
92 key = key.replace(new RegExp( "<Super>", 'gi' ), "Super + ")
93 key = key.replace(new RegExp( "KP_", 'gi' ), "Num")
94 key = key.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
95 return key
96 }
97
98 Item {
99 id: key
100 anchors.left: parent.left
101 anchors.leftMargin: 0
102 width: 150
103 TextCustom { id: keyText; text: getShortcutKey(); fontSize: "small" }
104 }
105
106 Item {
107 id: spacing
108 anchors.left: key.right
109 width: 10
110 }
111
112 Item {
113 id: value
114 width: 265
115 anchors.left: spacing.right
116 TextCustom { text: model.modelData.description; fontSize: "small" }
117 }
118 }
119 }
120
121 TextCustom {
122 id: sectionTitle
123 y: 27
124 text: model.modelData.description
125 anchors.left: parent.left
126 font.bold: true
127 fontSize: "large"
128 }
129
130 ListView {
131 id: list
132 model: {
133 if (sectionId == "launcher") return launcherModel
134 else if (sectionId == "dash") return dashModel
135 else if (sectionId == "topBar") return topBarModel
136 else if (sectionId == "switching") return switchingModel
137 else if (sectionId == "workspaces") return workspacesModel
138 else if (sectionId == "windows") return windowModel
139 else return ""
140 }
141 spacing: 18
142 anchors.left: parent.left
143 anchors.top: sectionTitle.bottom
144 anchors.topMargin: 14
145 height: (spacing * count) + anchors.topMargin
146 delegate: itemDelegate
147 }
148
149 Item {
150 id: bottomSpacing
151 height: 20
152 }
153
154 Rectangle {
155 id: divider
156 height: 1
157 color: "#ffffff"
158 smooth: true
159 anchors.top: shortcutHitSection.bottom
160 anchors.right: parent.right
161 anchors.left: parent.left
162 opacity: 0.2
163 visible: (index != 2)
164 }
165}
0166
=== added directory 'shell/shortcutoverlay/artwork'
=== added file 'shell/shortcutoverlay/artwork/shortcut_hint_borders.png'
1Binary 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 differ167Binary 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
=== added file 'tests/shell/shortcut-hint-overlay-tests.rb'
--- tests/shell/shortcut-hint-overlay-tests.rb 1970-01-01 00:00:00 +0000
+++ tests/shell/shortcut-hint-overlay-tests.rb 2012-03-29 12:58:23 +0000
@@ -0,0 +1,89 @@
1#!/usr/bin/env ruby1.8
2=begin
3/*
4 * This file is part of unity-2d
5 *
6 * Copyright 2011 Canonical Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 3.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20=end
21
22require '../run-tests.rb' unless $INIT_COMPLETED
23require 'xdo/xwindow'
24require 'xdo/keyboard'
25
26############################# Test Suite #############################
27context "Launcher Shortcut hint overlay Tests" do
28 # Run once at the beginning of this test suite
29 startup do
30 $SUT.execute_shell_command 'killall unity-2d-shell'
31 $SUT.execute_shell_command 'killall unity-2d-shell'
32
33 # Minimize all windows
34 XDo::XWindow.toggle_minimize_all
35 end
36
37 # Run once at the end of this test suite
38 shutdown do
39 end
40
41 # Run before each test case begins
42 setup do
43 # Execute the application
44 @app = $SUT.run( :name => UNITY_2D_SHELL,
45 :arguments => "-testability",
46 :sleeptime => 2 )
47 # Make certain application is ready for testing
48 verify{ @app.Launcher() }
49 end
50
51 # Run after each test case completes
52 teardown do
53 $SUT.execute_shell_command 'pkill -nf unity-2d-shell'
54 end
55
56 #####################################################################################
57 # Test cases
58 # Test case objectives:
59 # * Check shortcut hint overlay display/close
60 # Pre-conditions
61 # * None
62 # Test steps
63 # * Hold super key
64 # * Check the shortcut hint overlay is displayed
65 # * Release super key
66 # * Check that shortcut hint overlay is closed
67 # Post-conditions
68 # * None
69 # References
70 # * lp:#855532
71 test "Check shortcut hint overlay display/close" do
72 # Check the hint window is not displayed initially
73 verify_not(TIMEOUT, 'Shortcut hint overlay should be closed, but visible') {
74 @app.ShellDeclarativeView().ShortcutHint();
75 }
76
77 XDo::Keyboard.key_down('SUPER')
78 # Check the hint window is displayed when 'super' is pressed
79 verify(TIMEOUT, 'Shortcut hint overlay should be displayed, but it is not') {
80 @app.ShellDeclarativeView().ShortcutHint();
81 }
82
83 XDo::Keyboard.key_up('SUPER')
84 # Check the hint window is closed when 'super' is released
85 verify_not(TIMEOUT, 'Shortcut hint overlay should be closed, but visible') {
86 @app.ShellDeclarativeView().ShortcutHint();
87 }
88 end
89end

Subscribers

People subscribed via source and target branches