Merge lp:~torkvemada/libdbusmenu-qt/libdbusmenu-qt into lp:libdbusmenu-qt

Proposed by Vsevolod Velichko on 2015-08-26
Status: Work in progress
Proposed branch: lp:~torkvemada/libdbusmenu-qt/libdbusmenu-qt
Merge into: lp:libdbusmenu-qt
Diff against target: 99 lines (+36/-2)
5 files modified
src/dbusmenu_p.cpp (+5/-0)
src/dbusmenu_p.h (+2/-0)
src/dbusmenuexporter.cpp (+4/-2)
tests/dbusmenuexportertest.cpp (+24/-0)
tests/dbusmenuexportertest.h (+1/-0)
To merge this branch: bzr merge lp:~torkvemada/libdbusmenu-qt/libdbusmenu-qt
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) 2015-08-26 Approve on 2016-02-17
Review via email: mp+269273@code.launchpad.net

Description of the change

Support for menu to be exported with multiple DBusMenuExporter's.
Example when it's needed: if one wants to export main menu (which is exported by default with appmenu-qt) as the Unity dock menu. Since Qt exports appmenu by default, the menu cannot be exported to dock without the patch.

To post a comment you must log in.
Albert Astals Cid (aacid) wrote :

Looks good to me, do you have an application that needs this to work?

review: Approve
Vsevolod Velichko (torkvemada) wrote :

Yes, we have an IM qutIM who exports its main menu to Unity dock, but it doesn't work since the time when Ubuntu started auto-exporting main menu for Qt applications.

Albert Astals Cid (aacid) wrote :

Is 0.2.0-0ubuntu9 new enough? What's the difference i should see when running it with and without this patch?

Vsevolod Velichko (torkvemada) wrote :

No, 0.2 is forgotten and buried. There's an pre-alfa version 0.4 affected, which is currently available only on github and is hard to build :)

Albert Astals Cid (aacid) wrote :

Tried building the git version, didn't succeeed.

Honestly without a way to try this actually improves things in real life (besides the test) I don't feel like I approve this merge request, problem is that libdbusmenu-qt is kind of unmaintained

Albert Astals Cid (aacid) wrote :

Putting it to Work In Progress until submitter can provide a better use case of why this is needed.

Unmerged revisions

271. By Vsevolod Velichko on 2015-08-26

test for multiple exporters

270. By Vsevolod Velichko on 2015-08-26

support multiple exporters for one menu

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dbusmenu_p.cpp'
2--- src/dbusmenu_p.cpp 2011-06-20 15:20:18 +0000
3+++ src/dbusmenu_p.cpp 2015-08-26 21:06:14 +0000
4@@ -91,4 +91,9 @@
5 delete this;
6 }
7
8+DBusMenuExporter* DBusMenu::exporter() const
9+{
10+ return m_exporter;
11+}
12+
13 #include "dbusmenu_p.moc"
14
15=== modified file 'src/dbusmenu_p.h'
16--- src/dbusmenu_p.h 2013-11-05 04:18:39 +0000
17+++ src/dbusmenu_p.h 2015-08-26 21:06:14 +0000
18@@ -41,6 +41,8 @@
19 DBusMenu(QMenu *menu, DBusMenuExporter *exporter, int parentId);
20 virtual ~DBusMenu();
21
22+ DBusMenuExporter* exporter() const;
23+
24 protected:
25 virtual bool eventFilter(QObject *obj, QEvent *event);
26
27
28=== modified file 'src/dbusmenuexporter.cpp'
29--- src/dbusmenuexporter.cpp 2012-10-24 14:43:10 +0000
30+++ src/dbusmenuexporter.cpp 2015-08-26 21:06:14 +0000
31@@ -55,10 +55,12 @@
32
33 void DBusMenuExporterPrivate::addMenu(QMenu *menu, int parentId)
34 {
35- if (menu->findChild<DBusMenu *>()) {
36+ Q_FOREACH(DBusMenu *m, menu->findChildren<DBusMenu *>()) {
37 // This can happen if a menu is removed from its parent and added back
38 // See KDE bug 254066
39- return;
40+ if(m->exporter() == q) {
41+ return;
42+ }
43 }
44 new DBusMenu(menu, q, parentId);
45 Q_FOREACH(QAction *action, menu->actions()) {
46
47=== modified file 'tests/dbusmenuexportertest.cpp'
48--- tests/dbusmenuexportertest.cpp 2012-01-23 14:02:42 +0000
49+++ tests/dbusmenuexportertest.cpp 2015-08-26 21:06:14 +0000
50@@ -42,6 +42,7 @@
51
52 static const char *TEST_SERVICE = "org.kde.dbusmenu-qt-test";
53 static const char *TEST_OBJECT_PATH = "/TestMenuBar";
54+static const char *TEST_OBJECT_PATH2 = "/TestMenuBar2";
55
56 Q_DECLARE_METATYPE(QList<int>)
57
58@@ -600,6 +601,29 @@
59 QCOMPARE(trackCount(subMenu), 1);
60 }
61
62+// Check that menu can be exported with two different exporters
63+void DBusMenuExporterTest::testMultipleExporters()
64+{
65+ QMenu mainMenu;
66+ QVERIFY(QDBusConnection::sessionBus().registerService(TEST_SERVICE));
67+ DBusMenuExporter *exporter1 = new DBusMenuExporter(TEST_OBJECT_PATH, &mainMenu);
68+ DBusMenuExporter *exporter2 = new DBusMenuExporter(TEST_OBJECT_PATH2, &mainMenu);
69+
70+ QMenu* subMenu = new QMenu("File");
71+ subMenu->addAction("a1");
72+ mainMenu.addAction(subMenu->menuAction());
73+
74+ QDBusInterface iface1(TEST_SERVICE, TEST_OBJECT_PATH);
75+ QVERIFY2(iface1.isValid(), qPrintable(iface1.lastError().message()));
76+
77+ QDBusInterface iface2(TEST_SERVICE, TEST_OBJECT_PATH2);
78+ QVERIFY2(iface2.isValid(), qPrintable(iface2.lastError().message()));
79+
80+ QCOMPARE(getChildren(&iface1, 0, QStringList()).count(), mainMenu.actions().count());
81+ QCOMPARE(getChildren(&iface2, 0, QStringList()).count(), mainMenu.actions().count());
82+
83+}
84+
85 // If desktop does not want icon in menus, check we do not export them
86 void DBusMenuExporterTest::testHonorDontShowIconsInMenusAttribute()
87 {
88
89=== modified file 'tests/dbusmenuexportertest.h'
90--- tests/dbusmenuexportertest.h 2012-01-18 15:24:13 +0000
91+++ tests/dbusmenuexportertest.h 2015-08-26 21:06:14 +0000
92@@ -49,6 +49,7 @@
93 void testGetGroupProperties();
94 void testActivateAction();
95 void testTrackActionsOnlyOnce();
96+ void testMultipleExporters();
97 void testHonorDontShowIconsInMenusAttribute();
98 void testDBusMenuObjectIsDeletedWhenExporterIsDeleted();
99 void testSeparatorCollapsing_data();

Subscribers

People subscribed via source and target branches