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
=== modified file 'launcher/LauncherList.qml'
--- launcher/LauncherList.qml 2011-03-14 15:25:50 +0000
+++ launcher/LauncherList.qml 2011-03-14 17:27:08 +0000
@@ -123,6 +123,17 @@
123 onDraggedTileIdChanged: if (reorder.draggedTileId != "") item.menu.hide()123 onDraggedTileIdChanged: if (reorder.draggedTileId != "") item.menu.hide()
124 }124 }
125125
126 Connections {
127 target: item.menu
128 onVisibleChanged: {
129 if (item.menu.visible) {
130 visibilityController.beginForceVisible();
131 } else {
132 visibilityController.endForceVisible();
133 }
134 }
135 }
136
126 function setIconGeometry() {137 function setIconGeometry() {
127 if (running) {138 if (running) {
128 item.setIconGeometry(x + panel.x, y + panel.y, width, height)139 item.setIconGeometry(x + panel.x, y + panel.y, width, height)
129140
=== modified file 'launcher/UnityApplications/launchermenu.cpp'
--- launcher/UnityApplications/launchermenu.cpp 2011-03-11 13:11:12 +0000
+++ launcher/UnityApplications/launchermenu.cpp 2011-03-14 17:27:08 +0000
@@ -245,3 +245,17 @@
245{245{
246 m_launcherItem = launcherItem;246 m_launcherItem = launcherItem;
247}247}
248
249void
250LauncherContextualMenu::showEvent(QShowEvent* event)
251{
252 QMenu::showEvent(event);
253 visibleChanged(true);
254}
255
256void
257LauncherContextualMenu::hideEvent(QHideEvent* event)
258{
259 QMenu::hideEvent(event);
260 visibleChanged(false);
261}
248262
=== modified file 'launcher/UnityApplications/launchermenu.h'
--- launcher/UnityApplications/launchermenu.h 2011-03-03 15:18:08 +0000
+++ launcher/UnityApplications/launchermenu.h 2011-03-14 17:27:08 +0000
@@ -33,6 +33,7 @@
33 Q_PROPERTY(bool transparencyAvailable READ transparencyAvailable)33 Q_PROPERTY(bool transparencyAvailable READ transparencyAvailable)
34 Q_PROPERTY(bool folded READ folded WRITE setFolded NOTIFY foldedChanged)34 Q_PROPERTY(bool folded READ folded WRITE setFolded NOTIFY foldedChanged)
35 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)35 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
36 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
3637
37public:38public:
38 LauncherContextualMenu();39 LauncherContextualMenu();
@@ -52,13 +53,18 @@
52 Q_INVOKABLE void show(int x, int y);53 Q_INVOKABLE void show(int x, int y);
53 Q_INVOKABLE void hide();54 Q_INVOKABLE void hide();
54 Q_INVOKABLE void hideWithDelay(int delay);55 Q_INVOKABLE void hideWithDelay(int delay);
56
57protected:
55 void resizeEvent(QResizeEvent* event);58 void resizeEvent(QResizeEvent* event);
56 void leaveEvent(QEvent* event);59 void leaveEvent(QEvent* event);
57 void enterEvent(QEvent* event);60 void enterEvent(QEvent* event);
61 void showEvent(QShowEvent* event);
62 void hideEvent(QHideEvent* event);
5863
59Q_SIGNALS:64Q_SIGNALS:
60 void foldedChanged(bool);65 void foldedChanged(bool);
61 void titleChanged(QString);66 void titleChanged(QString);
67 void visibleChanged(bool);
6268
63protected:69protected:
64 void paintEvent(QPaintEvent* event);70 void paintEvent(QPaintEvent* event);

Subscribers

People subscribed via source and target branches