Merge lp:~agateau/unity-2d/keep-launcher-when-menu-is-visible into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Merged
Approved by: Ugo Riboni
Approved revision: 446
Merged at revision: 452
Proposed branch: lp:~agateau/unity-2d/keep-launcher-when-menu-is-visible
Merge into: lp:unity-2d/3.0
Prerequisite: lp:~agateau/unity-2d/launcher-need-attention
Diff against target: 74 lines (+31/-0)
3 files modified
launcher/LauncherList.qml (+11/-0)
launcher/UnityApplications/launchermenu.cpp (+14/-0)
launcher/UnityApplications/launchermenu.h (+6/-0)
To merge this branch: bzr merge lp:~agateau/unity-2d/keep-launcher-when-menu-is-visible
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
Review via email: mp+52866@code.launchpad.net

Commit message

[launcher] Do not hide launcher while a menu is visible

Adds two signals to LauncherContextualMenu to let QML LauncherList know when a menu is shown or hidden. I first tried to use the aboutToShow() and aboutToHide() signals, but aboutToShow() is not emitted due to the way we use QMenu.

Description of the change

Do not hide launcher while a menu is visible

Adds two signals to LauncherContextualMenu to let QML LauncherList know when a menu is shown or hidden. I first tried to use the aboutToShow() and aboutToHide() signals, but aboutToShow() is not emitted due to the way we use QMenu.

Note that this is built on top of this branch: lp:~agateau/unity-2d/launcher-need-attention

To post a comment you must log in.
Revision history for this message
Ugo Riboni (uriboni) wrote :

From a general design point of view, wouldn't it be more consistent with the QML way of doing things to have a bool property visible and then connecting to onVisibleChanged ?

Having it as a property will help for the cases where we don't need to call functions as an effect of the menu visibility change, but we can just bind the property to some other property.

review: Needs Fixing
Revision history for this message
Aurélien Gâteau (agateau) wrote :

What worries me is that there is already a "visible" property because LauncherContextualMenu inherits QMenu so I wanted to avoid overlapping with it, but now that I think about it, maybe I can just add the visibleChanged signal and we would be good.

Revision history for this message
Ugo Riboni (uriboni) wrote :

Works for me and the code seems ok too.
I have just one comment (not blocking): usually in QML most of us don't follow the C++ guideline for braces around ifs, so code can be leaner like:

if (item.menu.visible) visibilityController.beginForceVisible();
else visibilityController.endForceVisible();

But I don't mind if you leave it that way.

review: Approve
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Mmm... I thought only historical code did not follow the guidelines. no-brace-on-single-line-if is as evil in Javascript as it is in C++. I'd prefer to leave it that way.

Revision history for this message
Ugo Riboni (uriboni) wrote :

Well, the C++ and QML guidelines ATM are differnet (with the QMl ones being less strict) AFAIK.
But I am not against what you said, so: code approved.

(let's discuss the guidelines in IRC with all the others, or email, if you want to change them)

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

The prerequisite lp:~agateau/unity-2d/launcher-need-attention has not yet been merged into lp:unity-2d.

446. By Aurélien Gâteau

Merged from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherList.qml'
2--- launcher/LauncherList.qml 2011-03-14 15:25:50 +0000
3+++ launcher/LauncherList.qml 2011-03-14 17:27:08 +0000
4@@ -123,6 +123,17 @@
5 onDraggedTileIdChanged: if (reorder.draggedTileId != "") item.menu.hide()
6 }
7
8+ Connections {
9+ target: item.menu
10+ onVisibleChanged: {
11+ if (item.menu.visible) {
12+ visibilityController.beginForceVisible();
13+ } else {
14+ visibilityController.endForceVisible();
15+ }
16+ }
17+ }
18+
19 function setIconGeometry() {
20 if (running) {
21 item.setIconGeometry(x + panel.x, y + panel.y, width, height)
22
23=== modified file 'launcher/UnityApplications/launchermenu.cpp'
24--- launcher/UnityApplications/launchermenu.cpp 2011-03-11 13:11:12 +0000
25+++ launcher/UnityApplications/launchermenu.cpp 2011-03-14 17:27:08 +0000
26@@ -245,3 +245,17 @@
27 {
28 m_launcherItem = launcherItem;
29 }
30+
31+void
32+LauncherContextualMenu::showEvent(QShowEvent* event)
33+{
34+ QMenu::showEvent(event);
35+ visibleChanged(true);
36+}
37+
38+void
39+LauncherContextualMenu::hideEvent(QHideEvent* event)
40+{
41+ QMenu::hideEvent(event);
42+ visibleChanged(false);
43+}
44
45=== modified file 'launcher/UnityApplications/launchermenu.h'
46--- launcher/UnityApplications/launchermenu.h 2011-03-03 15:18:08 +0000
47+++ launcher/UnityApplications/launchermenu.h 2011-03-14 17:27:08 +0000
48@@ -33,6 +33,7 @@
49 Q_PROPERTY(bool transparencyAvailable READ transparencyAvailable)
50 Q_PROPERTY(bool folded READ folded WRITE setFolded NOTIFY foldedChanged)
51 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
52+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
53
54 public:
55 LauncherContextualMenu();
56@@ -52,13 +53,18 @@
57 Q_INVOKABLE void show(int x, int y);
58 Q_INVOKABLE void hide();
59 Q_INVOKABLE void hideWithDelay(int delay);
60+
61+protected:
62 void resizeEvent(QResizeEvent* event);
63 void leaveEvent(QEvent* event);
64 void enterEvent(QEvent* event);
65+ void showEvent(QShowEvent* event);
66+ void hideEvent(QHideEvent* event);
67
68 Q_SIGNALS:
69 void foldedChanged(bool);
70 void titleChanged(QString);
71+ void visibleChanged(bool);
72
73 protected:
74 void paintEvent(QPaintEvent* event);

Subscribers

People subscribed via source and target branches