Merge lp:~nick-dedekind/libdbusmenu-qt/qpaexporter into lp:libdbusmenu-qt

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp:~nick-dedekind/libdbusmenu-qt/qpaexporter
Merge into: lp:libdbusmenu-qt
Prerequisite: lp:~nick-dedekind/libdbusmenu-qt/Qt5-tests
Diff against target: 2985 lines (+2413/-149)
31 files modified
CMakeLists.txt (+12/-2)
Doxyfile.in (+1/-1)
debian/changelog (+7/-0)
src/CMakeLists.txt (+35/-28)
src/dbusmenuexporter.cpp (+5/-31)
src/dbusmenuexporterdbus_p.cpp (+4/-36)
src/dbusmenuexporterdbus_p.h (+10/-34)
src/dbusmenuexporterdbusinterface_p.cpp (+67/-0)
src/dbusmenuexporterdbusinterface_p.h (+80/-0)
src/dbusmenuexporterprivate_p.h (+1/-1)
src/dbusmenuimporter.cpp (+2/-2)
src/dbusmenuinterface.cpp (+63/-0)
src/dbusmenuinterface.h (+154/-0)
src/dbusmenuproperty.h (+78/-0)
src/dbusmenushortcut_p.cpp (+2/-0)
src/dbusmenutypes.cpp (+142/-1)
src/dbusmenutypes.h (+20/-5)
src/qpa/exportedplatformmenubar.cpp (+377/-0)
src/qpa/exportedplatformmenubar.h (+136/-0)
src/qpa/exportedplatformmenubar_p.cpp (+129/-0)
src/qpa/exportedplatformmenubar_p.h (+111/-0)
src/qpa/logging_p.h (+38/-0)
src/qpa/qpadbusmenuexporter_p.cpp (+357/-0)
src/qpa/qpadbusmenuexporter_p.h (+94/-0)
src/utils.cpp (+36/-1)
src/utils_p.h (+15/-5)
tests/CMakeLists.txt (+13/-0)
tests/dbusmenuexportertest.cpp (+2/-1)
tests/exportedplatformmenutest.cpp (+366/-0)
tests/exportedplatformmenutest.h (+55/-0)
tests/testutils.h (+1/-1)
To merge this branch: bzr merge lp:~nick-dedekind/libdbusmenu-qt/qpaexporter
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
DBus Menu Team Pending
Review via email: mp+253334@code.launchpad.net

This proposal supersedes a proposal from 2015-03-05.

Description of the change

Added exporter support for Qt platform menus.
Exported dbus interface for com.canonical.dbusmenu for use in unity8.

To post a comment you must log in.
276. By Nick Dedekind

reverted dbus xml

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

276. By Nick Dedekind

reverted dbus xml

275. By Nick Dedekind

fixed addMenu

274. By Nick Dedekind

added exported platformmenu test

273. By Nick Dedekind

merged with test branch

272. By Nick Dedekind

parent of exporter

271. By Nick Dedekind

logging & version bump

270. By Nick Dedekind

added dbusmenuinterface + reworked dbus properties

269. By Nick Dedekind

more qpa exporter

268. By Nick Dedekind

app menu qpa exporter

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2015-03-18 11:19:06 +0000
+++ CMakeLists.txt 2015-03-18 11:19:06 +0000
@@ -34,12 +34,22 @@
34 endif()34 endif()
35endif()35endif()
3636
37find_package(PkgConfig)
37# Detect for which Qt version we're building38# Detect for which Qt version we're building
38if (USE_QT5)39if (USE_QT5)
40 find_package(Qt5Core REQUIRED)
39 find_package(Qt5Widgets REQUIRED)41 find_package(Qt5Widgets REQUIRED)
40 find_package(Qt5DBus REQUIRED)42 find_package(Qt5DBus REQUIRED)
41 include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})43 find_package(Qt5Gui REQUIRED)
42 find_package(Qt5Core REQUIRED)44 pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED)
45
46 include_directories(
47 ${Qt5Widgets_INCLUDE_DIRS}
48 ${Qt5DBus_INCLUDE_DIRS}
49 ${Qt5DBus_PRIVATE_INCLUDE_DIRS}
50 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
51 ${DBUS_CPP_INCLUDE_DIRS}
52 )
43 set(CMAKE_AUTOMOC ON)53 set(CMAKE_AUTOMOC ON)
44 set(CMAKE_AUTOMOC_RELAXED_MODE ON)54 set(CMAKE_AUTOMOC_RELAXED_MODE ON)
45 set(CMAKE_POSITION_INDEPENDENT_CODE ON)55 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4656
=== modified file 'Doxyfile.in'
--- Doxyfile.in 2011-03-24 15:04:52 +0000
+++ Doxyfile.in 2015-03-18 11:19:06 +0000
@@ -232,7 +232,7 @@
232SEARCH_INCLUDES = YES232SEARCH_INCLUDES = YES
233INCLUDE_PATH =233INCLUDE_PATH =
234INCLUDE_FILE_PATTERNS =234INCLUDE_FILE_PATTERNS =
235PREDEFINED =235PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS
236EXPAND_AS_DEFINED =236EXPAND_AS_DEFINED =
237SKIP_FUNCTION_MACROS = YES237SKIP_FUNCTION_MACROS = YES
238#---------------------------------------------------------------------------238#---------------------------------------------------------------------------
239239
=== modified file 'debian/changelog'
--- debian/changelog 2014-06-19 09:07:18 +0000
+++ debian/changelog 2015-03-18 11:19:06 +0000
@@ -1,3 +1,10 @@
1libdbusmenu-qt (0.9.4) UNRELEASED; urgency=medium
2
3 [ Nick Dedekind ]
4 * Added exported qpa platform menu & dbusmenu interface
5
6 -- Nick Dedekind <nick.dedekind@canonical.com> Thu, 05 Mar 2015 13:39:12 +0000
7
1libdbusmenu-qt (0.9.3+14.10.20140619-0ubuntu1) utopic; urgency=low8libdbusmenu-qt (0.9.3+14.10.20140619-0ubuntu1) utopic; urgency=low
29
3 [ Aurélien Gâteau ]10 [ Aurélien Gâteau ]
411
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-03-18 11:19:06 +0000
+++ src/CMakeLists.txt 2015-03-18 11:19:06 +0000
@@ -1,34 +1,20 @@
1include(CheckCXXSourceCompiles)1include(CheckCXXSourceCompiles)
22
3check_cxx_compiler_flag(-Wall __DBUSMENU_HAVE_W_ALL)
4if (__DBUSMENU_HAVE_W_ALL)
5 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
6endif (__DBUSMENU_HAVE_W_ALL)
7
8# Check some compiler flags3# Check some compiler flags
9check_cxx_compiler_flag(-fvisibility=hidden __DBUSMENU_HAVE_GCC_VISIBILITY)
10if (__DBUSMENU_HAVE_GCC_VISIBILITY AND NOT WIN32)
11 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
12endif (__DBUSMENU_HAVE_GCC_VISIBILITY AND NOT WIN32)
13
14check_cxx_compiler_flag(-Woverloaded-virtual __DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
15if (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
16 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
17endif (__DBUSMENU_HAVE_W_OVERLOADED_VIRTUAL)
18
19check_cxx_compiler_flag(-Wall __DBUSMENU_HAVE_W_ALL)4check_cxx_compiler_flag(-Wall __DBUSMENU_HAVE_W_ALL)
20if (__DBUSMENU_HAVE_W_ALL)5if (__DBUSMENU_HAVE_W_ALL)
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")6 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
22endif (__DBUSMENU_HAVE_W_ALL)7endif (__DBUSMENU_HAVE_W_ALL)
238
24check_cxx_compiler_flag(-std=c++11 __DBUSMENU_HAVE_CXX11)9# Find the dbusxml2cpp tool
25if (__DBUSMENU_HAVE_CXX11)10if(DEFINED ENV{DEB_BUILD_MULTIARCH})
26 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")11 set(QDBUSXML2CPP_EXECUTABLE "/usr/lib/$ENV{DEB_BUILD_MULTIARCH}/qt5/bin/qdbusxml2cpp")
27endif (__DBUSMENU_HAVE_CXX11)12else()
13 FIND_PROGRAM(QDBUSXML2CPP_EXECUTABLE qdbusxml2cpp)
14endif()
2815
29# Check whether QIcon::name() exists. It was added in late Qt 4.7 cycle, and is16# Check whether QIcon::name() exists. It was added in late Qt 4.7 cycle, and is
30# not present in betas.17# not present in betas.
31
32if (NOT USE_QT5)18if (NOT USE_QT5)
33 set(CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}")19 set(CMAKE_REQUIRED_INCLUDES "${QT_INCLUDE_DIR}")
34 set(CMAKE_REQUIRED_LIBRARIES "${QT_QTGUI_LIBRARIES};${QT_QTCORE_LIBRARIES}")20 set(CMAKE_REQUIRED_LIBRARIES "${QT_QTGUI_LIBRARIES};${QT_QTCORE_LIBRARIES}")
@@ -49,34 +35,55 @@
49endif()35endif()
50configure_file(dbusmenu_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_config.h @ONLY)36configure_file(dbusmenu_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_config.h @ONLY)
5137
38include_directories(
39 ${CMAKE_SOURCE_DIR}/src
40 ${CMAKE_BINARY_DIR}/src
41 )
42
52set(dbusmenu_qt_SRCS43set(dbusmenu_qt_SRCS
53 dbusmenu_p.cpp44 dbusmenu_p.cpp
54 dbusmenuexporter.cpp45 dbusmenuexporter.cpp
55 dbusmenuexporterdbus_p.cpp46 dbusmenuexporterdbus_p.cpp
47 dbusmenuexporterdbusinterface_p.cpp
56 dbusmenuimporter.cpp48 dbusmenuimporter.cpp
57 dbusmenutypes_p.cpp49 dbusmenuinterface.cpp
50 dbusmenutypes.cpp
58 dbusmenushortcut_p.cpp51 dbusmenushortcut_p.cpp
59 utils.cpp52 utils.cpp
60 )53 dbusmenuproperty.h
6154 ${CMAKE_BINARY_DIR}/src/dbusmenuinterface_p.cpp
62include_directories(
63 ${CMAKE_SOURCE_DIR}/src
64 ${CMAKE_BINARY_DIR}/src
65 )55 )
6656
67if (NOT USE_QT5)57if (NOT USE_QT5)
68 qt4_automoc(${dbusmenu_qt_SRCS})58 qt4_automoc(${dbusmenu_qt_SRCS})
69 qt4_add_dbus_adaptor(dbusmenu_qt_SRCS59 qt4_add_dbus_adaptor(dbusmenu_qt_SRCS
70 ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml60 ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
71 ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus61 ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbusinterface_p.h DBusMenuExporterDBusInterface
72 )62 )
73else()63else()
64 set(dbusmenu_qt_SRCS
65 ${dbusmenu_qt_SRCS}
66 qpa/exportedplatformmenubar.cpp
67 qpa/exportedplatformmenubar_p.cpp
68 qpa/qpadbusmenuexporter_p.cpp
69 )
70
74 qt5_add_dbus_adaptor(dbusmenu_qt_SRCS71 qt5_add_dbus_adaptor(dbusmenu_qt_SRCS
75 ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml72 ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
76 ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbus_p.h DBusMenuExporterDBus73 ${CMAKE_CURRENT_SOURCE_DIR}/dbusmenuexporterdbusinterface_p.h DBusMenuExporterDBusInterface
77 )74 )
78endif()75endif()
7976
77if(${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/dbusmenuinterface.h)
78 execute_process(COMMAND ${QDBUSXML2CPP_EXECUTABLE}
79 -c DbusMenuInterfacePrivate
80 -p ${CMAKE_CURRENT_BINARY_DIR}/dbusmenuinterface_p
81 -i "${CMAKE_SOURCE_DIR}/src/dbusmenutypes.h"
82 ${CMAKE_CURRENT_SOURCE_DIR}/com.canonical.dbusmenu.xml
83 com.canonical.dbusmenu
84 )
85endif()
86
80configure_file(dbusmenu_version.h.in87configure_file(dbusmenu_version.h.in
81 ${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_version.h88 ${CMAKE_CURRENT_BINARY_DIR}/dbusmenu_version.h
82 )89 )
8390
=== modified file 'src/dbusmenuexporter.cpp'
--- src/dbusmenuexporter.cpp 2012-10-24 14:43:10 +0000
+++ src/dbusmenuexporter.cpp 2015-03-18 11:19:06 +0000
@@ -35,7 +35,7 @@
35#include "dbusmenu_p.h"35#include "dbusmenu_p.h"
36#include "dbusmenuexporterdbus_p.h"36#include "dbusmenuexporterdbus_p.h"
37#include "dbusmenuexporterprivate_p.h"37#include "dbusmenuexporterprivate_p.h"
38#include "dbusmenutypes_p.h"38#include "dbusmenutypes.h"
39#include "dbusmenushortcut_p.h"39#include "dbusmenushortcut_p.h"
40#include "debug_p.h"40#include "debug_p.h"
41#include "utils_p.h"41#include "utils_p.h"
@@ -94,7 +94,7 @@
94 QAction *action = button->defaultAction();94 QAction *action = button->defaultAction();
95 DMRETURN_VALUE_IF_FAIL(action, map);95 DMRETURN_VALUE_IF_FAIL(action, map);
9696
97 map.insert("label", swapMnemonicChar(action->text(), '&', '_'));97 map.insert("label", Utils::swapMnemonicChar(action->text(), '&', '_'));
98 insertIconProperty(&map, action);98 insertIconProperty(&map, action);
99 if (!action->isVisible()) {99 if (!action->isVisible()) {
100 map.insert("visible", false);100 map.insert("visible", false);
@@ -115,7 +115,7 @@
115QVariantMap DBusMenuExporterPrivate::propertiesForStandardAction(QAction *action) const115QVariantMap DBusMenuExporterPrivate::propertiesForStandardAction(QAction *action) const
116{116{
117 QVariantMap map;117 QVariantMap map;
118 map.insert("label", swapMnemonicChar(action->text(), '&', '_'));118 map.insert("label", Utils::swapMnemonicChar(action->text(), '&', '_'));
119 if (!action->isEnabled()) {119 if (!action->isEnabled()) {
120 map.insert("enabled", false);120 map.insert("enabled", false);
121 }121 }
@@ -338,7 +338,7 @@
338 d->m_emittedLayoutUpdatedOnce = false;338 d->m_emittedLayoutUpdatedOnce = false;
339 d->m_itemUpdatedTimer = new QTimer(this);339 d->m_itemUpdatedTimer = new QTimer(this);
340 d->m_layoutUpdatedTimer = new QTimer(this);340 d->m_layoutUpdatedTimer = new QTimer(this);
341 d->m_dbusObject = new DBusMenuExporterDBus(this);341 d->m_dbusObject = new DBusMenuExporterDBus(objectPath, this);
342342
343 d->addMenu(d->m_rootMenu, 0);343 d->addMenu(d->m_rootMenu, 0);
344344
@@ -379,33 +379,7 @@
379 QVariantMap updatedProperties;379 QVariantMap updatedProperties;
380 QStringList removedProperties;380 QStringList removedProperties;
381381
382 // Find updated and removed properties382 Utils::parsePropertyChanges(oldProperties, newProperties, updatedProperties, removedProperties);
383 QVariantMap::ConstIterator newEnd = newProperties.constEnd();
384
385 QVariantMap::ConstIterator
386 oldIt = oldProperties.constBegin(),
387 oldEnd = oldProperties.constEnd();
388 for(; oldIt != oldEnd; ++oldIt) {
389 QString key = oldIt.key();
390 QVariantMap::ConstIterator newIt = newProperties.constFind(key);
391 if (newIt != newEnd) {
392 if (newIt.value() != oldIt.value()) {
393 updatedProperties.insert(key, newIt.value());
394 }
395 } else {
396 removedProperties << key;
397 }
398 }
399
400 // Find new properties (treat them as updated properties)
401 QVariantMap::ConstIterator newIt = newProperties.constBegin();
402 for (; newIt != newEnd; ++newIt) {
403 QString key = newIt.key();
404 oldIt = oldProperties.constFind(key);
405 if (oldIt == oldEnd) {
406 updatedProperties.insert(key, newIt.value());
407 }
408 }
409383
410 // Update our data (oldProperties is a reference)384 // Update our data (oldProperties is a reference)
411 oldProperties = newProperties;385 oldProperties = newProperties;
412386
=== modified file 'src/dbusmenuexporterdbus_p.cpp'
--- src/dbusmenuexporterdbus_p.cpp 2011-08-29 14:51:01 +0000
+++ src/dbusmenuexporterdbus_p.cpp 2015-03-18 11:19:06 +0000
@@ -21,26 +21,19 @@
21#include "dbusmenuexporterdbus_p.h"21#include "dbusmenuexporterdbus_p.h"
2222
23// Qt23// Qt
24#include <QDBusMessage>24#include <QEvent>
25#include <QMenu>25#include <QMenu>
26#include <QVariant>26#include <QVariant>
2727
28// Local28// Local
29#include "dbusmenuadaptor.h"
30#include "dbusmenuexporterprivate_p.h"29#include "dbusmenuexporterprivate_p.h"
31#include "dbusmenushortcut_p.h"30#include "dbusmenushortcut_p.h"
32#include "debug_p.h"31#include "debug_p.h"
3332
34static const char *DBUSMENU_INTERFACE = "com.canonical.dbusmenu";33DBusMenuExporterDBus::DBusMenuExporterDBus(const QString& objectPath, DBusMenuExporter *exporter)
35static const char *FDO_PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties";34 : DBusMenuExporterDBusInterface(objectPath, exporter)
3635 , m_exporter(exporter)
37DBusMenuExporterDBus::DBusMenuExporterDBus(DBusMenuExporter *exporter)
38: QObject(exporter)
39, m_exporter(exporter)
40, m_status("normal")
41{36{
42 DBusMenuTypes_register();
43 new DbusmenuAdaptor(this);
44}37}
4538
46uint DBusMenuExporterDBus::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item)39uint DBusMenuExporterDBus::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item)
@@ -157,30 +150,5 @@
157 return filter.mChanged;150 return filter.mChanged;
158}151}
159152
160void DBusMenuExporterDBus::setStatus(const QString& status)
161{
162 if (m_status == status) {
163 return;
164 }
165 m_status = status;
166
167 QVariantMap map;
168 map.insert("Status", QVariant(status));
169
170 QDBusMessage msg = QDBusMessage::createSignal(m_exporter->d->m_objectPath, FDO_PROPERTIES_INTERFACE, "PropertiesChanged");
171 QVariantList args = QVariantList()
172 << DBUSMENU_INTERFACE
173 << map
174 << QStringList() // New properties: none
175 ;
176 msg.setArguments(args);
177 QDBusConnection::sessionBus().send(msg);
178}
179
180QString DBusMenuExporterDBus::status() const
181{
182 return m_status;
183}
184
185153
186#include "dbusmenuexporterdbus_p.moc"154#include "dbusmenuexporterdbus_p.moc"
187155
=== modified file 'src/dbusmenuexporterdbus_p.h'
--- src/dbusmenuexporterdbus_p.h 2011-08-29 14:51:01 +0000
+++ src/dbusmenuexporterdbus_p.h 2015-03-18 11:19:06 +0000
@@ -22,50 +22,26 @@
22#define DBUSMENUEXPORTERDBUS_P_H22#define DBUSMENUEXPORTERDBUS_P_H
2323
24// Local24// Local
25#include <dbusmenutypes_p.h>25#include "dbusmenuexporterdbusinterface_p.h"
26
27// Qt
28#include <QtCore/QObject>
29#include <QtCore/QVariant>
30#include <QtDBus/QDBusAbstractAdaptor>
31#include <QtDBus/QDBusVariant>
3226
33class DBusMenuExporter;27class DBusMenuExporter;
3428
35/**29class DBusMenuExporterDBus : public DBusMenuExporterDBusInterface
36 * Internal class implementing the DBus side of DBusMenuExporter
37 * This avoid exposing the implementation of the DBusMenu spec to the outside
38 * world.
39 */
40class DBusMenuExporterDBus : public QObject
41{30{
42 Q_OBJECT31 Q_OBJECT
43 Q_CLASSINFO("D-Bus Interface", "com.canonical.dbusmenu")32 Q_CLASSINFO("D-Bus Interface", "com.canonical.dbusmenu")
44 Q_PROPERTY(uint Version READ Version)
45 Q_PROPERTY(QString Status READ status)
46public:33public:
47 DBusMenuExporterDBus(DBusMenuExporter *m_exporter);34 DBusMenuExporterDBus(const QString& objectPath, DBusMenuExporter *m_exporter);
4835
49 uint Version() const { return 2; }36public: // overrides
5037 void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp) override;
51 QString status() const;38 QDBusVariant GetProperty(int id, const QString &property) override;
52 void setStatus(const QString &status);39 uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item) override;
5340 DBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames) override;
54public Q_SLOTS:41 bool AboutToShow(int id) override;
55 Q_NOREPLY void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp);
56 QDBusVariant GetProperty(int id, const QString &property);
57 uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item);
58 DBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames);
59 bool AboutToShow(int id);
60
61Q_SIGNALS:
62 void ItemsPropertiesUpdated(DBusMenuItemList, DBusMenuItemKeysList);
63 void LayoutUpdated(uint revision, int parentId);
64 void ItemActivationRequested(int id, uint timeStamp);
6542
66private:43private:
67 DBusMenuExporter *m_exporter;44 DBusMenuExporter *m_exporter;
68 QString m_status;
6945
70 friend class DBusMenuExporter;46 friend class DBusMenuExporter;
71 friend class DBusMenuExporterPrivate;47 friend class DBusMenuExporterPrivate;
7248
=== added file 'src/dbusmenuexporterdbusinterface_p.cpp'
--- src/dbusmenuexporterdbusinterface_p.cpp 1970-01-01 00:00:00 +0000
+++ src/dbusmenuexporterdbusinterface_p.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,67 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "dbusmenuexporterdbusinterface_p.h"
23#include "dbusmenuadaptor.h"
24
25// Qt
26#include <QDBusMessage>
27#include <QEvent>
28
29static const char *DBUSMENU_INTERFACE = "com.canonical.dbusmenu";
30static const char *FDO_PROPERTIES_INTERFACE = "org.freedesktop.DBus.Properties";
31
32DBusMenuExporterDBusInterface::DBusMenuExporterDBusInterface(const QString& objectPath, QObject *parent)
33 : QObject(parent)
34 , m_objectPath(objectPath)
35 , m_status("normal")
36{
37 DBusMenuTypes_register();
38
39 new DbusmenuAdaptor(this);
40 QDBusConnection::sessionBus().registerObject(objectPath, this, QDBusConnection::ExportAllContents);
41}
42
43QString DBusMenuExporterDBusInterface::status() const
44{
45 return m_status;
46}
47
48void DBusMenuExporterDBusInterface::setStatus(const QString& status)
49{
50 if (m_status == status) {
51 return;
52 }
53 m_status = status;
54
55 QVariantMap map;
56 map.insert("Status", QVariant(status));
57
58 QDBusMessage msg = QDBusMessage::createSignal(m_objectPath, FDO_PROPERTIES_INTERFACE, "PropertiesChanged");
59 QVariantList args = QVariantList()
60 << DBUSMENU_INTERFACE
61 << map
62 << QStringList() // New properties: none
63 ;
64 msg.setArguments(args);
65 QDBusConnection::sessionBus().send(msg);
66}
67
068
=== added file 'src/dbusmenuexporterdbusinterface_p.h'
--- src/dbusmenuexporterdbusinterface_p.h 1970-01-01 00:00:00 +0000
+++ src/dbusmenuexporterdbusinterface_p.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,80 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef DBUSMENUEXPORTERDBUSINTERFACE_P_H
22#define DBUSMENUEXPORTERDBUSINTERFACE_P_H
23
24// Local
25#include <dbusmenutypes.h>
26
27// Qt
28#include <QtCore/QObject>
29#include <QtCore/QVariant>
30#include <QtDBus/QDBusAbstractAdaptor>
31#include <QtDBus/QDBusVariant>
32
33/**
34 * Internal class implementing the DBus side of DBusMenuExporter
35 * This avoid exposing the implementation of the DBusMenu spec to the outside
36 * world.
37 */
38class DBusMenuExporterDBusInterface : public QObject
39{
40 Q_OBJECT
41 Q_CLASSINFO("D-Bus Interface", "com.canonical.dbusmenu")
42 Q_PROPERTY(uint Version READ Version)
43 Q_PROPERTY(QString Status READ status)
44public:
45 DBusMenuExporterDBusInterface(const QString& objectPath, QObject* parent = nullptr);
46 uint Version() const { return 2; }
47
48 /**
49 * The status of the menu. Can be one of "normal" or "notice". This can be
50 * used to notify the other side the menu should be made more visible.
51 * For example, appmenu uses it to tell Unity panel to show/hide the menubar
52 * when the Alt modifier is pressed/released.
53 */
54 QString status() const;
55
56 /**
57 * Returns the status of the menu.
58 * @ref setStatus
59 */
60 void setStatus(const QString &status);
61
62public Q_SLOTS:
63 virtual Q_NOREPLY void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp) = 0;
64 virtual QDBusVariant GetProperty(int id, const QString &property) = 0;
65 virtual uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item) = 0;
66 virtual DBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames) = 0;
67 virtual bool AboutToShow(int id) = 0;
68
69Q_SIGNALS:
70 void ItemsPropertiesUpdated(DBusMenuItemList, DBusMenuItemKeysList);
71 void LayoutUpdated(uint revision, int parentId);
72 void ItemActivationRequested(int id, uint timeStamp);
73
74private:
75 QString m_objectPath;
76 QString m_status;
77};
78
79
80#endif // DBUSMENUEXPORTERDBUSINTERFACE_P_H
081
=== modified file 'src/dbusmenuexporterprivate_p.h'
--- src/dbusmenuexporterprivate_p.h 2012-03-29 14:23:32 +0000
+++ src/dbusmenuexporterprivate_p.h 2015-03-18 11:19:06 +0000
@@ -23,7 +23,7 @@
2323
24// Local24// Local
25#include "dbusmenuexporter.h"25#include "dbusmenuexporter.h"
26#include "dbusmenutypes_p.h"26#include "dbusmenutypes.h"
2727
28// Qt28// Qt
29#include <QtCore/QHash>29#include <QtCore/QHash>
3030
=== modified file 'src/dbusmenuimporter.cpp'
--- src/dbusmenuimporter.cpp 2014-03-05 09:53:39 +0000
+++ src/dbusmenuimporter.cpp 2015-03-18 11:19:06 +0000
@@ -36,7 +36,7 @@
36#include <QWidgetAction>36#include <QWidgetAction>
3737
38// Local38// Local
39#include "dbusmenutypes_p.h"39#include "dbusmenutypes.h"
40#include "dbusmenushortcut_p.h"40#include "dbusmenushortcut_p.h"
41#include "debug_p.h"41#include "debug_p.h"
42#include "utils_p.h"42#include "utils_p.h"
@@ -199,7 +199,7 @@
199199
200 void updateActionLabel(QAction *action, const QVariant &value)200 void updateActionLabel(QAction *action, const QVariant &value)
201 {201 {
202 QString text = swapMnemonicChar(value.toString(), '_', '&');202 QString text = Utils::swapMnemonicChar(value.toString(), '_', '&');
203 action->setText(text);203 action->setText(text);
204 }204 }
205205
206206
=== added file 'src/dbusmenuinterface.cpp'
--- src/dbusmenuinterface.cpp 1970-01-01 00:00:00 +0000
+++ src/dbusmenuinterface.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,63 @@
1#include "dbusmenuinterface.h"
2#include "dbusmenuinterface_p.h"
3
4DBusMenuInterface::DBusMenuInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
5 : d(new DbusMenuInterfacePrivate(service, path, connection, this))
6{
7 DBusMenuTypes_register();
8}
9
10uint DBusMenuInterface::version() const
11{
12 return d->version();
13}
14
15QString DBusMenuInterface::status() const
16{
17 return d->status();
18}
19
20bool DBusMenuInterface::isValid() const
21{
22 return d->isValid();
23}
24
25QString DBusMenuInterface::service() const
26{
27 return d->service();
28}
29
30QString DBusMenuInterface::path() const
31{
32 return d->path();
33}
34
35QDBusPendingReply<bool> DBusMenuInterface::AboutToShow(int id)
36{
37 return d->AboutToShow(id);
38}
39
40QDBusPendingReply<> DBusMenuInterface::Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp)
41{
42 return d->Event(id, eventId, data, timestamp);
43}
44
45QDBusPendingReply<DBusMenuItemList> DBusMenuInterface::GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames)
46{
47 return d->GetGroupProperties(ids, propertyNames);
48}
49
50QDBusPendingReply<QDBusVariant> DBusMenuInterface::GetProperty(int id, const QString &name)
51{
52 return d->GetProperty(id, name);
53}
54
55QDBusPendingReply<uint, DBusMenuLayoutItem> DBusMenuInterface::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames)
56{
57 return d->GetLayout(parentId, recursionDepth, propertyNames);
58}
59
60QDBusReply<uint> DBusMenuInterface::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &layout)
61{
62 return d->GetLayout(parentId, recursionDepth, propertyNames, layout);
63}
064
=== added file 'src/dbusmenuinterface.h'
--- src/dbusmenuinterface.h 1970-01-01 00:00:00 +0000
+++ src/dbusmenuinterface.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,154 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef DBUSMENUINTERFACE_H
22#define DBUSMENUINTERFACE_H
23
24// Local
25#include <dbusmenutypes.h>
26class DbusMenuInterfacePrivate;
27
28// Qt
29#include <QtCore/QObject>
30#include <QtDBus/QtDBus>
31
32/**
33 * Internal class implementing the DBus side of DBusMenuExporter
34 * This avoid exposing the implementation of the DBusMenu spec to the outside
35 * world.
36 */
37class DBUSMENU_EXPORT DBusMenuInterface : public QObject
38{
39 Q_OBJECT
40
41 /**
42 * Version of the menu interface.
43 */
44 Q_PROPERTY(uint Version READ version)
45
46 /**
47 * Status of the menu.
48 */
49 Q_PROPERTY(QString Status READ status)
50public:
51 /**
52 * Creates a DBusMenuInterface on specified service, path & connection
53 */
54 DBusMenuInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject* parent = nullptr);
55
56 /**
57 * Returns the version of the menu interface.
58 */
59 uint version() const;
60
61 /**
62 * The status of the menu. Can be one of "normal" or "notice". This can be
63 * used to notify the other side the menu should be made more visible.
64 * For example, appmenu uses it to tell Unity panel to show/hide the menubar
65 * when the Alt modifier is pressed/released.
66 */
67 QString status() const;
68
69 /**
70 * Returns true if this is a valid reference to a remote object.
71 * It returns false if there was an error during the creation of the interface
72 */
73 bool isValid() const;
74
75 /**
76 * Returns the name of the service this interface is associated with.
77 */
78 QString service() const;
79
80 /**
81 * Returns the object path that this interface is associated with.
82 */
83 QString path() const;
84
85public Q_SLOTS:
86 /**
87 * This is called to notify the application that it is about
88 * to show the menu under the specified item.
89 */
90 QDBusPendingReply<bool> AboutToShow(int id);
91
92 /**
93 * This is called by the applet to notify the application an event happened on a
94 * menu item.
95 */
96 QDBusPendingReply<> Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp);
97
98 /**
99 * Returns the list of items which are children of @p parentId.
100 */
101 QDBusPendingReply<DBusMenuItemList> GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames);
102
103 /**
104 * Get a signal property on a single item. This is not useful if you're
105 * going to implement this interface, it should only be used if you're
106 * debugging via a commandline tool.
107 */
108 QDBusPendingReply<QDBusVariant> GetProperty(int id, const QString &name);
109
110 /**
111 * Provides the layout and propertiers that are attached to the entries
112 * that are in the layout. It only gives the items that are children
113 * of the item that is specified in @p parentId. It will return all of the
114 * properties or specific ones depending of the value in @p propertyNames.
115 */
116 QDBusPendingReply<uint, DBusMenuLayoutItem> GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames);
117
118 /**
119 * Provides the layout and propertiers that are attached to the entries
120 * that are in the layout. It only gives the items that are children
121 * of the item that is specified in @p parentId. It will return all of the
122 * properties or specific ones depending of the value @p propertyNames.
123 */
124 QDBusReply<uint> GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &layout);
125
126Q_SIGNALS: // SIGNALS
127 /**
128 * The server is requesting that all clients displaying this
129 * menu open it to the user. This would be for things like
130 * hotkeys that when the user presses them the menu should
131 * open and display itself to the user.
132 */
133 void ItemActivationRequested(int id, uint timestamp);
134
135 /**
136 * Triggered when there are lots of property updates across many items
137 * so they all get grouped into a single dbus message. The format is
138 * the ID of the item with a hashtable of names and values for those
139 * properties.
140 */
141 void ItemsPropertiesUpdated(DBusMenuItemList updatedProps, DBusMenuItemKeysList removedProps);
142
143 /**
144 * Triggered by the application to notify display of a layout update, up to
145 * revision
146 */
147 void LayoutUpdated(uint revision, int parent);
148
149private:
150 DbusMenuInterfacePrivate* d;
151};
152
153
154#endif // DBUSMENUINTERFACE_H
0155
=== added file 'src/dbusmenuproperty.h'
--- src/dbusmenuproperty.h 1970-01-01 00:00:00 +0000
+++ src/dbusmenuproperty.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,78 @@
1#ifndef DBUSMENUPROPERTY_H
2#define DBUSMENUPROPERTY_H
3
4#ifndef DOXYGEN_SHOULD_SKIP_THIS
5
6// Qt
7#include <QtCore/QVariantMap>
8
9// Local
10#include <dbusmenu_export.h>
11
12class QKeySequence;
13class QByteArray;
14class QString;
15
16//// DBusMenuProperty
17/**
18 * Structure which contains the names of the common properties
19 * for a menu item.
20 */
21struct DBUSMENU_EXPORT DBusMenuProperty
22{
23 static const char* Type;
24 static const char* Label;
25 static const char* Enabled;
26 static const char* Visible;
27 static const char* IconName;
28 static const char* IconData;
29 static const char* Shortcut;
30 static const char* ToggleType;
31 static const char* ToggleState;
32 static const char* ChildrenDisplay;
33};
34
35//// DBusMenuProperties
36/**
37 * A map of properties for the dbus with easy accessors for
38 * the common properties
39 */
40struct DBUSMENU_EXPORT DBusMenuProperties: public QVariantMap
41{
42 QString type() const;
43 void setType(const QString&);
44
45 QString label() const;
46 void setLabel(const QString&);
47
48 bool enabled() const;
49 void setEnabled(bool);
50
51 bool visible() const;
52 void setVisible(bool);
53
54 QString iconName() const;
55 void setIconName(const QString&);
56
57 QByteArray iconData() const;
58 void setIconData(const QByteArray&);
59
60 QKeySequence shortcut() const;
61 void setShortcut(const QKeySequence&);
62
63 QString toggleType() const;
64 void setToggleType(const QString&);
65
66 int toggleState() const;
67 void setToggleState(int);
68
69 bool childrenDisplay() const;
70 void setChildrenDisplay(bool);
71
72 DBusMenuProperties& operator=(const QVariantMap& rhs);
73};
74
75#endif /* DOXYGEN_SHOULD_SKIP_THIS */
76
77
78#endif // DBUSMENUPROPERTY_H
079
=== modified file 'src/dbusmenushortcut_p.cpp'
--- src/dbusmenushortcut_p.cpp 2011-04-12 09:12:18 +0000
+++ src/dbusmenushortcut_p.cpp 2015-03-18 11:19:06 +0000
@@ -44,6 +44,8 @@
44 // cf https://bugs.launchpad.net/libdbusmenu-qt/+bug/71256544 // cf https://bugs.launchpad.net/libdbusmenu-qt/+bug/712565
45 {"+", "plus"},45 {"+", "plus"},
46 {"-", "minus"},46 {"-", "minus"},
47 {"+", "KP_Add"},
48 {"-", "KP_Subtract"},
47 {0, 0}49 {0, 0}
48 };50 };
4951
5052
=== renamed file 'src/dbusmenutypes_p.cpp' => 'src/dbusmenutypes.cpp'
--- src/dbusmenutypes_p.cpp 2011-02-23 13:23:56 +0000
+++ src/dbusmenutypes.cpp 2015-03-18 11:19:06 +0000
@@ -18,7 +18,7 @@
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.19 Boston, MA 02110-1301, USA.
20*/20*/
21#include "dbusmenutypes_p.h"21#include "dbusmenutypes.h"
2222
23// Local23// Local
24#include <dbusmenushortcut_p.h>24#include <dbusmenushortcut_p.h>
@@ -27,6 +27,18 @@
27// Qt27// Qt
28#include <QDBusArgument>28#include <QDBusArgument>
29#include <QDBusMetaType>29#include <QDBusMetaType>
30#include <QKeySequence>
31
32const char* DBusMenuProperty::Type = "type";
33const char* DBusMenuProperty::Label = "label";
34const char* DBusMenuProperty::Enabled = "enabled";
35const char* DBusMenuProperty::Visible = "visible";
36const char* DBusMenuProperty::IconName = "icon-name";
37const char* DBusMenuProperty::IconData = "icon-data";
38const char* DBusMenuProperty::Shortcut = "shortcut";
39const char* DBusMenuProperty::ToggleType = "toggle-type";
40const char* DBusMenuProperty::ToggleState = "toggle-state";
41const char* DBusMenuProperty::ChildrenDisplay = "children-display";
3042
31//// DBusMenuItem43//// DBusMenuItem
32QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuItem &obj)44QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuItem &obj)
@@ -95,6 +107,16 @@
95 return argument;107 return argument;
96}108}
97109
110bool operator==(const DBusMenuLayoutItem& lhs, const DBusMenuLayoutItem& rhs)
111{
112 return lhs.id == rhs.id && lhs.properties == rhs.properties && lhs.children == rhs.children;
113}
114
115bool operator!=(const DBusMenuLayoutItem& lhs, const DBusMenuLayoutItem& rhs)
116{
117 return !(lhs == rhs);
118}
119
98void DBusMenuTypes_register()120void DBusMenuTypes_register()
99{121{
100 static bool registered = false;122 static bool registered = false;
@@ -110,3 +132,122 @@
110 qDBusRegisterMetaType<DBusMenuShortcut>();132 qDBusRegisterMetaType<DBusMenuShortcut>();
111 registered = true;133 registered = true;
112}134}
135
136QString DBusMenuProperties::type() const
137{
138 return value(DBusMenuProperty::Type, "standard").toString();
139}
140
141void DBusMenuProperties::setType(const QString &type)
142{
143 insert(DBusMenuProperty::Type, type);
144}
145
146QString DBusMenuProperties::label() const
147{
148 return value(DBusMenuProperty::Label, "").toString();
149}
150
151void DBusMenuProperties::setLabel(const QString &label)
152{
153 insert(DBusMenuProperty::Label, label);
154}
155
156bool DBusMenuProperties::enabled() const
157{
158 return value(DBusMenuProperty::Enabled, true).toBool();
159}
160
161void DBusMenuProperties::setEnabled(bool enabled)
162{
163 insert(DBusMenuProperty::Enabled, enabled);
164}
165
166bool DBusMenuProperties::visible() const
167{
168 return value(DBusMenuProperty::Visible, true).toBool();
169}
170
171void DBusMenuProperties::setVisible(bool enabled)
172{
173 insert(DBusMenuProperty::Visible, enabled);
174}
175
176QString DBusMenuProperties::iconName() const
177{
178 return value(DBusMenuProperty::IconName, "").toString();
179}
180
181void DBusMenuProperties::setIconName(const QString &iconName)
182{
183 insert(DBusMenuProperty::IconName, iconName);
184}
185
186QByteArray DBusMenuProperties::iconData() const
187{
188 return value(DBusMenuProperty::IconData, QVariant()).toByteArray();
189}
190
191void DBusMenuProperties::setIconData(const QByteArray &iconData)
192{
193 insert(DBusMenuProperty::IconData, iconData);
194}
195
196QKeySequence DBusMenuProperties::shortcut() const
197{
198 QKeySequence seq;
199
200 QVariant var = value(DBusMenuProperty::Shortcut, QVariant());
201
202 if (var.userType() == qMetaTypeId<QDBusArgument>()) {
203 QDBusArgument arg = var.value<QDBusArgument>();
204
205 DBusMenuShortcut shortcut;
206 arg >> shortcut;
207
208 return shortcut.toKeySequence();
209 }
210 return seq;
211}
212
213void DBusMenuProperties::setShortcut(const QKeySequence &keySequence)
214{
215 insert(DBusMenuProperty::Shortcut, keySequence);
216}
217
218QString DBusMenuProperties::toggleType() const
219{
220 return value(DBusMenuProperty::ToggleType, "").toString();
221}
222
223void DBusMenuProperties::setToggleType(const QString &toggleType)
224{
225 insert(DBusMenuProperty::ToggleType, toggleType);
226}
227
228int DBusMenuProperties::toggleState() const
229{
230 return value(DBusMenuProperty::ToggleState, -1).toInt();
231}
232
233void DBusMenuProperties::setToggleState(int toggleType)
234{
235 insert(DBusMenuProperty::ToggleState, toggleType);
236}
237
238bool DBusMenuProperties::childrenDisplay() const
239{
240 return value(DBusMenuProperty::ChildrenDisplay, false).toBool();
241}
242
243void DBusMenuProperties::setChildrenDisplay(bool childrenDisplay)
244{
245 insert(DBusMenuProperty::ChildrenDisplay, childrenDisplay);
246
247}
248
249DBusMenuProperties &DBusMenuProperties::operator=(const QVariantMap &rhs)
250{
251 QVariantMap::operator=(rhs);
252 return *this;
253}
113254
=== renamed file 'src/dbusmenutypes_p.h' => 'src/dbusmenutypes.h'
--- src/dbusmenutypes_p.h 2011-02-23 13:23:56 +0000
+++ src/dbusmenutypes.h 2015-03-18 11:19:06 +0000
@@ -18,8 +18,8 @@
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.19 Boston, MA 02110-1301, USA.
20*/20*/
21#ifndef DBUSMENUTYPES_P_H21#ifndef DBUSMENUTYPES_H
22#define DBUSMENUTYPES_P_H22#define DBUSMENUTYPES_H
2323
24// Qt24// Qt
25#include <QtCore/QList>25#include <QtCore/QList>
@@ -28,6 +28,7 @@
2828
29// Local29// Local
30#include <dbusmenu_export.h>30#include <dbusmenu_export.h>
31#include <dbusmenuproperty.h>
3132
32class QDBusArgument;33class QDBusArgument;
3334
@@ -37,8 +38,11 @@
37 */38 */
38struct DBUSMENU_EXPORT DBusMenuItem39struct DBUSMENU_EXPORT DBusMenuItem
39{40{
41 /// Id of the menu item
40 int id;42 int id;
41 QVariantMap properties;43
44 /// Properties for the menu item
45 DBusMenuProperties properties;
42};46};
4347
44Q_DECLARE_METATYPE(DBusMenuItem)48Q_DECLARE_METATYPE(DBusMenuItem)
@@ -57,7 +61,10 @@
57 */61 */
58struct DBUSMENU_EXPORT DBusMenuItemKeys62struct DBUSMENU_EXPORT DBusMenuItemKeys
59{63{
64 /// Id of the menu item
60 int id;65 int id;
66
67 /// Properties for the menu item
61 QStringList properties;68 QStringList properties;
62};69};
6370
@@ -75,11 +82,15 @@
75 * Represents an item with its children. GetLayout() returns a82 * Represents an item with its children. GetLayout() returns a
76 * DBusMenuLayoutItemList.83 * DBusMenuLayoutItemList.
77 */84 */
78struct DBusMenuLayoutItem;
79struct DBUSMENU_EXPORT DBusMenuLayoutItem85struct DBUSMENU_EXPORT DBusMenuLayoutItem
80{86{
87 /// Id of the menu item
81 int id;88 int id;
82 QVariantMap properties;89
90 /// Id of the menu item
91 DBusMenuProperties properties;
92
93 /// Children of the menu item
83 QList<DBusMenuLayoutItem> children;94 QList<DBusMenuLayoutItem> children;
84};95};
8596
@@ -88,9 +99,13 @@
88DBUSMENU_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuLayoutItem &);99DBUSMENU_EXPORT QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuLayoutItem &);
89DBUSMENU_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuLayoutItem &);100DBUSMENU_EXPORT const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuLayoutItem &);
90101
102DBUSMENU_EXPORT bool operator==(const DBusMenuLayoutItem& lhs, const DBusMenuLayoutItem& rhs);
103DBUSMENU_EXPORT bool operator!=(const DBusMenuLayoutItem& lhs, const DBusMenuLayoutItem& rhs);
104
91typedef QList<DBusMenuLayoutItem> DBusMenuLayoutItemList;105typedef QList<DBusMenuLayoutItem> DBusMenuLayoutItemList;
92106
93Q_DECLARE_METATYPE(DBusMenuLayoutItemList)107Q_DECLARE_METATYPE(DBusMenuLayoutItemList)
94108
95void DBusMenuTypes_register();109void DBusMenuTypes_register();
110
96#endif /* DBUSMENUTYPES_P_H */111#endif /* DBUSMENUTYPES_P_H */
97112
=== added directory 'src/qpa'
=== added file 'src/qpa/exportedplatformmenubar.cpp'
--- src/qpa/exportedplatformmenubar.cpp 1970-01-01 00:00:00 +0000
+++ src/qpa/exportedplatformmenubar.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,377 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22// Local
23#include "exportedplatformmenubar.h"
24#include "exportedplatformmenubar_p.h"
25#include "qpadbusmenuexporter_p.h"
26#include "logging_p.h"
27
28// Qt
29#include <QWindow>
30#include <QWidget>
31
32#define MENU_ID(x) (qobject_cast<ExportedPlatformMenu*>(x) ? qobject_cast<ExportedPlatformMenu*>(x)->id() : -1)
33#define MENU_ITEM_ID(x) (qobject_cast<ExportedPlatformMenuItem*>(x) ? qobject_cast<ExportedPlatformMenuItem*>(x)->id() : -1)
34
35ExportedPlatformMenuBar::ExportedPlatformMenuBar(const QString& exportPath)
36 : d(new ExportedPlatformMenuBarPrivate)
37{
38 LOG;
39
40 d->m_objectPath = exportPath;
41 new QPADBusMenuExporter(exportPath, this);
42}
43
44ExportedPlatformMenuBar::~ExportedPlatformMenuBar()
45{
46 LOG;
47}
48
49QString ExportedPlatformMenuBar::exportedPath() const
50{
51 return d->m_objectPath;
52}
53
54void
55ExportedPlatformMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *before)
56{
57 LOG << MENU_ID(menu) << " before:" << before;
58
59 if (!before) {
60 d->m_menus.push_back(menu);
61 } else {
62 for (auto iter = d->m_menus.begin(); iter != d->m_menus.end(); ++iter) {
63 if (*iter == before) {
64 d->m_menus.insert(iter, menu);
65 break;
66 }
67 }
68 }
69
70 Q_EMIT menuInserted(menu);
71}
72
73void
74ExportedPlatformMenuBar::removeMenu(QPlatformMenu *menu)
75{
76 LOG << menu;
77
78 for (auto iter = d->m_menus.begin(); iter != d->m_menus.end(); ++iter) {
79 if (*iter == menu) {
80 iter = d->m_menus.erase(iter);
81 }
82 }
83
84 Q_EMIT menuRemoved(menu);
85}
86
87void
88ExportedPlatformMenuBar::syncMenu(QPlatformMenu *menu)
89{
90 LOG_VAR(menu);
91 QMetaObject::invokeMethod(menu, "propertyUpdated");
92}
93
94void
95ExportedPlatformMenuBar::handleReparent(QWindow *newParentWindow)
96{
97 LOG_VAR(newParentWindow);
98}
99
100QPlatformMenu *
101ExportedPlatformMenuBar::menuForTag(quintptr tag) const
102{
103 for (auto iter = d->m_menus.begin(); iter != d->m_menus.end(); ++iter) {
104 if ((*iter)->tag() == tag) {
105 return *iter;
106 }
107 }
108 return nullptr;
109}
110
111QPlatformMenu *
112ExportedPlatformMenuBar::menuAt(int position) const
113{
114 if (position < 0 || position >= d->m_menus.count()) return nullptr;
115 return d->m_menus.at(position);
116}
117
118uint ExportedPlatformMenuBar::menuCount()
119{
120 return d->m_menus.count();
121}
122
123//////////////////////////////////////////////////////////////
124
125ExportedPlatformMenu::ExportedPlatformMenu()
126 : QPlatformMenu()
127 , d(new ExportedPlatformMenuPrivate)
128{
129 LOG << id();
130}
131
132ExportedPlatformMenu::~ExportedPlatformMenu()
133{
134 LOG << id();
135}
136
137void ExportedPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
138{
139 LOG << MENU_ITEM_ID(menuItem) << " before:" << before << " on: " << id();
140
141 if (!before) {
142 d->m_menuItems.push_back(menuItem);
143 } else {
144 for (auto iter = d->m_menuItems.begin(); iter != d->m_menuItems.end(); ++iter) {
145 if (*iter == before) {
146 d->m_menuItems.insert(iter, menuItem);
147 break;
148 }
149 }
150 }
151
152 Q_EMIT menuItemInserted(menuItem);
153}
154
155void ExportedPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
156{
157 LOG_VAR(menuItem) << " on: " << id();
158
159 QMutableListIterator<QPlatformMenuItem*> iter(d->m_menuItems);
160 while (iter.hasNext()) {
161 if (iter.next() == menuItem) {
162 iter.remove();
163 }
164 }
165
166 Q_EMIT menuItemRemoved(menuItem);
167}
168
169void ExportedPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
170{
171 LOG_VAR(menuItem) << " from: " << id();
172 QMetaObject::invokeMethod(menuItem, "propertyUpdated");
173}
174
175void ExportedPlatformMenu::syncSeparatorsCollapsible(bool enable)
176{
177 LOG_VAR(enable) << " on: " << id();
178 Q_EMIT propertyUpdated();
179}
180
181void ExportedPlatformMenu::setTag(quintptr tag)
182{
183 LOG_VAR(tag) << " on: " << id();
184 d->m_tag = tag;
185}
186
187quintptr ExportedPlatformMenu::tag() const
188{
189 return d->m_tag;
190}
191
192void ExportedPlatformMenu::setText(const QString &text)
193{
194 LOG_VAR(text) << " on: " << id();
195 ExportedPlatformMenuPrivate::set_text(this, text);
196 Q_EMIT propertyUpdated();
197}
198
199void ExportedPlatformMenu::setIcon(const QIcon &icon)
200{
201 LOG_VAR(icon) << " on: " << id();
202 ExportedPlatformMenuPrivate::set_icon(this, icon);
203 Q_EMIT propertyUpdated();
204}
205
206void ExportedPlatformMenu::setEnabled(bool isEnabled)
207{
208 LOG_VAR(isEnabled) << " on: " << id();
209 ExportedPlatformMenuPrivate::set_enabled(this, isEnabled);
210 Q_EMIT propertyUpdated();
211}
212
213void ExportedPlatformMenu::setVisible(bool isVisible)
214{
215 LOG_VAR(isVisible) << " on: " << id();
216 ExportedPlatformMenuPrivate::set_visible(this, isVisible);
217 Q_EMIT propertyUpdated();
218}
219
220void ExportedPlatformMenu::setMinimumWidth(int width)
221{
222 LOG_VAR(width) << " on: " << id();
223 Q_EMIT propertyUpdated();
224}
225
226void ExportedPlatformMenu::setFont(const QFont &font)
227{
228 LOG_VAR(font) << " on: " << id();
229 Q_EMIT propertyUpdated();
230}
231
232QPlatformMenuItem *ExportedPlatformMenu::menuItemAt(int position) const
233{
234 if (position < 0 || position >= d->m_menuItems.count()) return nullptr;
235 return d->m_menuItems.at(position);
236}
237
238QPlatformMenuItem *ExportedPlatformMenu::menuItemForTag(quintptr tag) const
239{
240 for (auto iter = d->m_menuItems.begin(); iter != d->m_menuItems.end(); ++iter) {
241 if ((*iter)->tag() == tag) {
242 return *iter;
243 }
244 }
245 return nullptr;
246}
247
248uint ExportedPlatformMenu::menuItemCount()
249{
250 return d->m_menuItems.count();
251}
252
253QPlatformMenuItem *ExportedPlatformMenu::createMenuItem() const
254{
255 return new ExportedPlatformMenuItem();
256}
257
258int ExportedPlatformMenu::id() const
259{
260 return d->m_id;
261}
262
263//////////////////////////////////////////////////////////////
264
265ExportedPlatformMenuItem::ExportedPlatformMenuItem()
266 : d(new ExportedPlatformMenuItemPrivate)
267{
268 LOG << id();
269}
270
271ExportedPlatformMenuItem::~ExportedPlatformMenuItem()
272{
273 LOG << id();
274}
275
276void ExportedPlatformMenuItem::setTag(quintptr tag)
277{
278 LOG_VAR(tag) << " on: " << id();
279 d->m_tag = tag;
280}
281
282quintptr ExportedPlatformMenuItem::tag() const
283{
284 return d->m_tag;
285}
286
287void ExportedPlatformMenuItem::setText(const QString &text)
288{
289 LOG_VAR(text) << " on: " << id();
290 ExportedPlatformMenuItemPrivate::set_text(this, text);
291 Q_EMIT propertyUpdated();
292}
293
294void ExportedPlatformMenuItem::setIcon(const QIcon &icon)
295{
296 LOG_VAR(icon) << " on: " << id();
297 ExportedPlatformMenuItemPrivate::set_icon(this, icon);
298 Q_EMIT propertyUpdated();
299}
300
301void ExportedPlatformMenuItem::setMenu(QPlatformMenu *menu)
302{
303 LOG << MENU_ID(menu) << " on: " << id();
304 d->m_menu = menu;
305 Q_EMIT propertyUpdated();
306}
307
308void ExportedPlatformMenuItem::setVisible(bool isVisible)
309{
310 LOG_VAR(isVisible) << " on: " << id();
311 ExportedPlatformMenuItemPrivate::set_visible(this, isVisible);
312 Q_EMIT propertyUpdated();
313}
314
315void ExportedPlatformMenuItem::setIsSeparator(bool isSeparator)
316{
317 LOG_VAR(isSeparator) << " on: " << id();
318 ExportedPlatformMenuItemPrivate::set_separator(this, isSeparator);
319 Q_EMIT propertyUpdated();
320}
321
322void ExportedPlatformMenuItem::setFont(const QFont &font)
323{
324 LOG_VAR(font) << " on: " << id();
325 Q_EMIT propertyUpdated();
326}
327
328void ExportedPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
329{
330 LOG_VAR(role) << " on: " << id();
331 Q_EMIT propertyUpdated();
332}
333
334void ExportedPlatformMenuItem::setCheckable(bool checkable)
335{
336 LOG_VAR(checkable) << " on: " << id();
337 ExportedPlatformMenuItemPrivate::set_checkable(this, checkable);
338 Q_EMIT propertyUpdated();
339}
340
341void ExportedPlatformMenuItem::setChecked(bool isChecked)
342{
343 LOG_VAR(isChecked) << " on: " << id();
344 ExportedPlatformMenuItemPrivate::set_checked(this, isChecked);
345 Q_EMIT propertyUpdated();
346}
347
348void ExportedPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
349{
350 LOG_VAR(shortcut) << " on: " << id();
351 ExportedPlatformMenuItemPrivate::set_shortcut(this, shortcut);
352 Q_EMIT propertyUpdated();
353}
354
355void ExportedPlatformMenuItem::setEnabled(bool enabled)
356{
357 LOG_VAR(enabled) << " on: " << id();
358 ExportedPlatformMenuItemPrivate::set_enabled(this, enabled);
359 Q_EMIT propertyUpdated();
360}
361
362void ExportedPlatformMenuItem::setIconSize(int size)
363{
364 LOG_VAR(size) << " on: " << id();
365 ExportedPlatformMenuItemPrivate::set_iconSize(this, size);
366 Q_EMIT propertyUpdated();
367}
368
369int ExportedPlatformMenuItem::id() const
370{
371 return d->m_id;
372}
373
374QPlatformMenu *ExportedPlatformMenuItem::menu() const
375{
376 return d->m_menu;
377}
0378
=== added file 'src/qpa/exportedplatformmenubar.h'
--- src/qpa/exportedplatformmenubar.h 1970-01-01 00:00:00 +0000
+++ src/qpa/exportedplatformmenubar.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,136 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef EXPORTEDPLATFORMMENUBAR_H
22#define EXPORTEDPLATFORMMENUBAR_H
23
24#include <qpa/qplatformmenu.h>
25class ExportedPlatformMenuBarPrivate;
26class ExportedPlatformMenuPrivate;
27class ExportedPlatformMenuItemPrivate;
28class ExportedPlatformMenu;
29class ExportedPlatformMenuItem;
30
31// Local
32#include <dbusmenu_export.h>
33
34class DBUSMENU_EXPORT ExportedPlatformMenuBar : public QPlatformMenuBar
35{
36 Q_OBJECT
37public:
38 ExportedPlatformMenuBar(const QString& exportPath);
39 ~ExportedPlatformMenuBar();
40
41 QString exportedPath() const;
42
43 virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu* before) override;
44 virtual void removeMenu(QPlatformMenu *menu) override;
45 virtual void syncMenu(QPlatformMenu *menuItem) override;
46 virtual void handleReparent(QWindow *newParentWindow) override;
47 virtual QPlatformMenu *menuForTag(quintptr tag) const override;
48
49 QPlatformMenu *menuAt(int position) const;
50 uint menuCount();
51
52Q_SIGNALS:
53 void menuInserted(QPlatformMenu *menu);
54 void menuRemoved(QPlatformMenu *menu);
55
56private:
57 ExportedPlatformMenuBarPrivate *const d;
58 friend class ExportedPlatformMenuBarPrivate;
59};
60
61class DBUSMENU_EXPORT ExportedPlatformMenu : public QPlatformMenu
62{
63 Q_OBJECT
64public:
65 ExportedPlatformMenu();
66 ~ExportedPlatformMenu();
67
68 virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) override;
69 virtual void removeMenuItem(QPlatformMenuItem *menuItem) override;
70 virtual void syncMenuItem(QPlatformMenuItem *menuItem) override;
71 virtual void syncSeparatorsCollapsible(bool enable) override;
72
73 virtual void setTag(quintptr tag) override;
74 virtual quintptr tag() const override;
75
76 virtual void setText(const QString &text) override;
77 virtual void setIcon(const QIcon &icon) override;
78 virtual void setEnabled(bool isEnabled) override;
79 virtual void setVisible(bool isVisible) override;
80 virtual void setMinimumWidth(int width) override;
81 virtual void setFont(const QFont &font) override;
82
83 virtual QPlatformMenuItem *menuItemAt(int position) const override;
84 virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
85 uint menuItemCount();
86
87 virtual QPlatformMenuItem *createMenuItem() const override;
88
89 int id() const;
90
91Q_SIGNALS:
92 void menuItemInserted(QPlatformMenuItem *menuItem);
93 void menuItemRemoved(QPlatformMenuItem *menuItem);
94
95 void propertyUpdated();
96
97private:
98 ExportedPlatformMenuPrivate *const d;
99 friend class ExportedPlatformMenuPrivate;
100};
101
102
103class DBUSMENU_EXPORT ExportedPlatformMenuItem : public QPlatformMenuItem
104{
105 Q_OBJECT
106public:
107 ExportedPlatformMenuItem();
108 ~ExportedPlatformMenuItem();
109
110 virtual void setTag(quintptr tag) override;
111 virtual quintptr tag() const override;
112
113 virtual void setText(const QString &text) override;
114 virtual void setIcon(const QIcon &icon) override;
115 virtual void setMenu(QPlatformMenu *menu) override;
116 virtual void setVisible(bool isVisible) override;
117 virtual void setIsSeparator(bool isSeparator) override;
118 virtual void setFont(const QFont &font) override;
119 virtual void setRole(MenuRole role) override;
120 virtual void setCheckable(bool checkable) override;
121 virtual void setChecked(bool isChecked) override;
122 virtual void setShortcut(const QKeySequence& shortcut) override;
123 virtual void setEnabled(bool enabled) override;
124 virtual void setIconSize(int size) override;
125
126 int id() const;
127 QPlatformMenu* menu() const;
128
129Q_SIGNALS:
130 void propertyUpdated();
131
132private:
133 ExportedPlatformMenuItemPrivate *const d;
134 friend class ExportedPlatformMenuItemPrivate;
135};
136#endif // EXPORTEDPLATFORMMENUBAR_H
0137
=== added file 'src/qpa/exportedplatformmenubar_p.cpp'
--- src/qpa/exportedplatformmenubar_p.cpp 1970-01-01 00:00:00 +0000
+++ src/qpa/exportedplatformmenubar_p.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,129 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22// Local
23#include "exportedplatformmenubar_p.h"
24#include "dbusmenushortcut_p.h"
25#include "debug_p.h"
26#include "utils_p.h"
27
28// Qt
29#include <QBuffer>
30
31int nextMenuId = 1;
32
33void insertIconProperty(QVariantMap *map, const QIcon& icon)
34{
35 // provide the icon name for per-theme lookups
36 const QString iconName = icon.name();
37 if (!iconName.isEmpty()) {
38 map->insert(DBusMenuProperty::IconName, iconName);
39 }
40
41 if (!icon.isNull()) {
42 QBuffer buffer;
43 icon.pixmap(16).save(&buffer, "PNG");
44 map->insert(DBusMenuProperty::IconData, buffer.data());
45 }
46}
47
48ExportedPlatformMenuBarPrivate::ExportedPlatformMenuBarPrivate()
49{
50}
51
52//////////////////////////////////////////////////////
53
54ExportedPlatformMenuPrivate::ExportedPlatformMenuPrivate()
55 : m_tag(0)
56 , m_id(nextMenuId++)
57{
58
59}
60
61QVariantMap ExportedPlatformMenuPrivate::propertiesForMenu(const ExportedPlatformMenu *menu)
62{
63 QVariantMap map;
64 map.insert(DBusMenuProperty::ChildrenDisplay, "submenu");
65 map.insert(DBusMenuProperty::Label, Utils::swapMnemonicChar(ExportedPlatformMenuPrivate::get_text(menu), '&', '_'));
66 if (!ExportedPlatformMenuPrivate::get_enabled(menu)) {
67 map.insert(DBusMenuProperty::Enabled, false);
68 }
69 if (!ExportedPlatformMenuPrivate::get_visible(menu)) {
70 map.insert(DBusMenuProperty::Visible, false);
71 }
72 insertIconProperty(&map, ExportedPlatformMenuPrivate::get_icon(menu));
73 return map;
74}
75
76//////////////////////////////////////////////////////
77
78ExportedPlatformMenuItemPrivate::ExportedPlatformMenuItemPrivate()
79 : m_id(nextMenuId++)
80 , m_menu(nullptr)
81{
82}
83
84QVariantMap ExportedPlatformMenuItemPrivate::propertiesForMenuItem(const ExportedPlatformMenuItem *menuItem)
85{
86 DMRETURN_VALUE_IF_FAIL(menuItem, QVariantMap());
87
88 if (ExportedPlatformMenuItemPrivate::get_separator(menuItem)) {
89 return propertiesForSeparatorMenuItem(menuItem);
90 } else {
91 return propertiesForStandardMenuItem(menuItem);
92 }
93}
94
95QVariantMap ExportedPlatformMenuItemPrivate::propertiesForSeparatorMenuItem(const ExportedPlatformMenuItem *menuItem)
96{
97 QVariantMap map;
98 map.insert(DBusMenuProperty::Type, "separator");
99 if (!ExportedPlatformMenuItemPrivate::get_visible(menuItem)) {
100 map.insert(DBusMenuProperty::Visible, false);
101 }
102 return map;
103}
104
105QVariantMap ExportedPlatformMenuItemPrivate::propertiesForStandardMenuItem(const ExportedPlatformMenuItem *menuItem)
106{
107 QVariantMap map;
108 map.insert(DBusMenuProperty::Label, Utils::swapMnemonicChar(ExportedPlatformMenuItemPrivate::get_text(menuItem), '&', '_'));
109 if (!ExportedPlatformMenuItemPrivate::get_enabled(menuItem)) {
110 map.insert(DBusMenuProperty::Enabled, false);
111 }
112 if (!ExportedPlatformMenuItemPrivate::get_visible(menuItem)) {
113 map.insert(DBusMenuProperty::Visible, false);
114 }
115 if (ExportedPlatformMenuItemPrivate::get_checkable(menuItem)) {
116 map.insert(DBusMenuProperty::ToggleType, "checkmark");
117 map.insert(DBusMenuProperty::ToggleState, ExportedPlatformMenuItemPrivate::get_checked(menuItem) ? 1 : 0);
118 }
119 if (menuItem->menu()) {
120 map.insert(DBusMenuProperty::ChildrenDisplay, "submenu");
121 }
122 insertIconProperty(&map, ExportedPlatformMenuItemPrivate::get_icon(menuItem));
123 QKeySequence keySequence = get_shortcut(menuItem);
124 if (!keySequence.isEmpty()) {
125 DBusMenuShortcut shortcut = DBusMenuShortcut::fromKeySequence(keySequence);
126 map.insert(DBusMenuProperty::Shortcut, QVariant::fromValue(shortcut));
127 }
128 return map;
129}
0130
=== added file 'src/qpa/exportedplatformmenubar_p.h'
--- src/qpa/exportedplatformmenubar_p.h 1970-01-01 00:00:00 +0000
+++ src/qpa/exportedplatformmenubar_p.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,111 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef EXPORTEDPLATFORMMENUBAR_P_H
22#define EXPORTEDPLATFORMMENUBAR_P_H
23
24// Qt
25#include <QtCore/QObject>
26#include <QtDBus/QDBusConnection>
27#include <qpa/qplatformmenu.h>
28
29// Local
30#include "dbusmenuexporterdbusinterface_p.h"
31#include "exportedplatformmenubar.h"
32
33class QAction;
34class QMenu;
35
36class ExportedPlatformMenuBar;
37class ExportedPlatformMenu;
38class ExportedPlatformMenuItem;
39class QPADBusMenuExporter;
40
41/**
42 * A QPADBusMenuExporter instance can serialize a qua menu over DBus
43 */
44class ExportedPlatformMenuBarPrivate
45{
46public:
47 ExportedPlatformMenuBarPrivate();
48
49 QString m_objectPath;
50 QList<QPlatformMenu*> m_menus;
51};
52
53class ExportedPlatformMenuPrivate
54{
55public:
56 ExportedPlatformMenuPrivate();
57
58 static QVariantMap propertiesForMenu(const ExportedPlatformMenu *menu);
59
60#define STATIC_PROPERTY(name, type, defaultValue) \
61 type m_##name = defaultValue; \
62 static type get_##name(const ExportedPlatformMenu *menu) { return menu->d->m_##name; } \
63 static void set_##name(ExportedPlatformMenu *menu, const type& value) { menu->d->m_##name = value; }
64
65 STATIC_PROPERTY(text, QString, QString())
66 STATIC_PROPERTY(visible, bool, true)
67 STATIC_PROPERTY(enabled, bool, true)
68 STATIC_PROPERTY(icon, QIcon, QIcon())
69#undef STATIC_PROPERTY
70
71 ExportedPlatformMenu* m_menu;
72 QList<QPlatformMenu*> m_menus;
73 QList<QPlatformMenuItem*> m_menuItems;
74 quintptr m_tag;
75 int m_id;
76};
77
78class ExportedPlatformMenuItemPrivate
79{
80public:
81 ExportedPlatformMenuItemPrivate();
82
83 static QVariantMap propertiesForMenuItem(const ExportedPlatformMenuItem *menuItem);
84 static QVariantMap propertiesForSeparatorMenuItem(const ExportedPlatformMenuItem *menuItem);
85 static QVariantMap propertiesForStandardMenuItem(const ExportedPlatformMenuItem *menuItem);
86
87#define STATIC_PROPERTY(name, type, defaultValue) \
88 type m_##name = defaultValue; \
89 static type get_##name(const ExportedPlatformMenuItem *menuItem) { return menuItem->d->m_##name; } \
90 static void set_##name(ExportedPlatformMenuItem *menuItem, const type& value) { menuItem->d->m_##name = value; }
91
92 STATIC_PROPERTY(separator, bool, false)
93 STATIC_PROPERTY(visible, bool, true)
94 STATIC_PROPERTY(text, QString, QString())
95 STATIC_PROPERTY(enabled, bool, true)
96 STATIC_PROPERTY(checkable, bool, false)
97 STATIC_PROPERTY(checked, bool, false)
98 STATIC_PROPERTY(shortcut, QKeySequence, QKeySequence())
99 STATIC_PROPERTY(icon, QIcon, QIcon())
100 STATIC_PROPERTY(iconSize, int, 16)
101#undef STATIC_PROPERTY
102
103 ExportedPlatformMenuItem* m_menuItem;
104 quintptr m_tag;
105 int m_id;
106 QPlatformMenu* m_menu;
107};
108
109extern int nextMenuId;
110
111#endif // EXPORTEDPLATFORMMENUBAR_P_H
0112
=== added file 'src/qpa/logging_p.h'
--- src/qpa/logging_p.h 1970-01-01 00:00:00 +0000
+++ src/qpa/logging_p.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,38 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef LOGGING_H
22#define LOGGING_H
23
24#include <QDebug>
25
26//#define ENABLE_DEBUG_LOGGING
27
28#ifdef ENABLE_DEBUG_LOGGING
29#define LOG qDebug() << __PRETTY_FUNCTION__
30#define LOG_VAR(x) qDebug() << __PRETTY_FUNCTION__<< #x ":" << x
31#else
32#define LOG QNoDebug()
33#define LOG_VAR(x) QNoDebug() << __PRETTY_FUNCTION__<< #x ":" << x
34#endif
35
36#define WARN qWarning() << __PRETTY_FUNCTION__
37
38#endif // LOGGING_H
039
=== added file 'src/qpa/qpadbusmenuexporter_p.cpp'
--- src/qpa/qpadbusmenuexporter_p.cpp 1970-01-01 00:00:00 +0000
+++ src/qpa/qpadbusmenuexporter_p.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,357 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22// Local
23#include "qpadbusmenuexporter_p.h"
24#include "exportedplatformmenubar.h"
25#include "exportedplatformmenubar_p.h"
26#include "utils_p.h"
27#include "logging_p.h"
28
29// Qt
30#include <QTimer>
31
32QPADBusMenuExporter::QPADBusMenuExporter(const QString &objectPath, ExportedPlatformMenuBar* menuBar)
33 : DBusMenuExporterDBusInterface(objectPath, menuBar)
34 , m_menuBar(menuBar)
35 , m_revision(1)
36 , m_emittedLayoutUpdatedOnce(false)
37{
38 LOG << "created exporter menu @ " << objectPath;
39
40 m_propertyTimer = new QTimer(this);
41 m_propertyTimer->setInterval(0);
42 m_propertyTimer->setSingleShot(true);
43 connect(m_propertyTimer, &QTimer::timeout, this, &QPADBusMenuExporter::doMenuPropertyUpdate);
44
45 m_layoutTimer = new QTimer(this);
46 m_layoutTimer->setInterval(0);
47 m_layoutTimer->setSingleShot(true);
48 connect(m_layoutTimer, &QTimer::timeout, this, &QPADBusMenuExporter::doMenuLayoutUpdate);
49
50 for (uint i = 0; i < m_menuBar->menuCount(); i++) {
51 auto exportedMenu = qobject_cast<ExportedPlatformMenu*>(m_menuBar->menuAt(i));
52 addMenu(exportedMenu, 0);
53 }
54
55 connect(menuBar, &ExportedPlatformMenuBar::menuInserted, this, [this](QPlatformMenu* menu) {
56 addMenu(qobject_cast<ExportedPlatformMenu*>(menu), 0);
57 });
58 connect(menuBar, &ExportedPlatformMenuBar::menuRemoved, this, [this](QPlatformMenu* menu) {
59 removeMenu(qobject_cast<ExportedPlatformMenu*>(menu), 0);
60 });
61}
62
63QPADBusMenuExporter::~QPADBusMenuExporter()
64{
65}
66
67void QPADBusMenuExporter::Event(int id, const QString &eventType, const QDBusVariant &data, uint timestamp)
68{
69 Q_UNUSED(data);
70 Q_UNUSED(timestamp);
71 LOG << " id:" << id << ", eventType:" << eventType;
72
73 ExportedPlatformMenuItem* menuItem = m_menuItemForId.value(id, nullptr);
74 if (menuItem) {
75 if (eventType == "clicked") {
76 QMetaObject::invokeMethod(menuItem, "activated");
77 } else if (eventType == "hovered") {
78 QMetaObject::invokeMethod(menuItem, "hovered");
79 }
80 }
81}
82
83QDBusVariant QPADBusMenuExporter::GetProperty(int id, const QString &property)
84{
85 if (!m_propertiesForId.contains(id)) return QDBusVariant();
86 return QDBusVariant(m_propertiesForId.value(id).value(property));
87}
88
89void QPADBusMenuExporter::fillLayout(DBusMenuLayoutItem *item, int id, int depth, const QStringList &propertyNames)
90{
91 item->id = id;
92 item->properties = getProperties(id, propertyNames);
93
94 if (depth != 0) {
95 if (id == 0) {
96 for (uint i = 0; i < m_menuBar->menuCount(); i++) {
97 auto exportedMenu = qobject_cast<ExportedPlatformMenu*>(m_menuBar->menuAt(i));
98 if (exportedMenu) {
99 DBusMenuLayoutItem child;
100 fillLayout(&child, exportedMenu->id(), depth - 1, propertyNames);
101 item->children << child;
102 }
103 }
104 } else {
105 // menu with children.
106 ExportedPlatformMenu* menu = m_menuForId.value(id, nullptr);
107 if (menu) {
108 for (uint i = 0; i < menu->menuItemCount(); i++) {
109 auto exportedMenuItem = qobject_cast<ExportedPlatformMenuItem*>(menu->menuItemAt(i));
110
111 DBusMenuLayoutItem child;
112 fillLayout(&child, exportedMenuItem->id(), depth-1, propertyNames);
113 item->children << child;
114 }
115 } else {
116 // child menu items which has an attached menu
117 ExportedPlatformMenuItem* menuItem = m_menuItemForId.value(id, nullptr);
118 if (menuItem) {
119 auto menu = qobject_cast<ExportedPlatformMenu*>(menuItem->menu());
120 if (menu) {
121 for (uint i = 0; i < menu->menuItemCount(); i++) {
122 auto exportedMenuItem = qobject_cast<ExportedPlatformMenuItem*>(menu->menuItemAt(i));
123
124 DBusMenuLayoutItem child;
125 fillLayout(&child, exportedMenuItem->id(), depth-1, propertyNames);
126 item->children << child;
127 }
128 }
129 }
130 }
131 }
132 }
133}
134
135uint QPADBusMenuExporter::GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item)
136{
137 doMenuPropertyUpdate();
138
139 fillLayout(&item, parentId, recursionDepth, propertyNames);
140 return m_revision;
141}
142
143DBusMenuItemList QPADBusMenuExporter::GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames)
144{
145 DBusMenuItemList list;
146 Q_FOREACH(int id, ids) {
147 DBusMenuItem item;
148 item.id = id;
149 item.properties = getProperties(item.id, propertyNames);
150 list << item;
151 }
152 return list;
153}
154
155bool QPADBusMenuExporter::AboutToShow(int id)
156{
157 return false;
158}
159
160void QPADBusMenuExporter::menuPropertyUpdated(int id)
161{
162 if (m_propertyUpdates.contains(id)) return;
163
164 m_propertyUpdates << id;
165 if (!m_propertyTimer->isActive()) m_propertyTimer->start();
166}
167
168void QPADBusMenuExporter::menuLayoutUpdated(int id)
169{
170 if (m_layoutUpdates.contains(id)) return;
171
172 m_layoutUpdates << id;
173 if (!m_layoutTimer->isActive()) m_layoutTimer->start();
174}
175
176inline void logPropertyUpdates(const DBusMenuItemList& updates, const DBusMenuItemKeysList& removals)
177{
178 Q_FOREACH(const DBusMenuItem& update, updates) {
179 qDebug() << "property updates for " << update.id << endl
180 << " " << update.properties;
181 }
182 Q_FOREACH(const DBusMenuItemKeys& remove, removals) {
183 qDebug() << "property updates for " << remove.id << endl
184 << " " << remove.properties;
185 }
186}
187
188void QPADBusMenuExporter::doMenuPropertyUpdate()
189{
190 if (m_propertyUpdates.isEmpty()) {
191 return;
192 }
193 DBusMenuItemList updatedList;
194 DBusMenuItemKeysList removedList;
195
196 Q_FOREACH(int id, m_propertyUpdates) {
197 QVariantMap newProperties;
198 ExportedPlatformMenuItem* menuItem = m_menuItemForId.value(id, nullptr);
199 // no longer exists?
200 if (menuItem) {
201 newProperties = ExportedPlatformMenuItemPrivate::propertiesForMenuItem(menuItem);
202 } else {
203 ExportedPlatformMenu* menu = m_menuForId.value(id, nullptr);
204 if (menu) {
205 newProperties = ExportedPlatformMenuPrivate::propertiesForMenu(menu);
206 }
207 }
208
209 QVariantMap& oldProperties = m_propertiesForId[id];
210 QVariantMap updatedProperties;
211 QStringList removedProperties;
212
213 Utils::parsePropertyChanges(oldProperties, newProperties, updatedProperties, removedProperties);
214
215 // Update our data (oldProperties is a reference)
216 oldProperties = newProperties;
217
218 if (!updatedProperties.isEmpty()) {
219 DBusMenuItem item;
220 item.id = id;
221 item.properties = updatedProperties;
222 updatedList << item;
223 }
224 if (!removedProperties.isEmpty()) {
225 DBusMenuItemKeys itemKeys;
226 itemKeys.id = id;
227 itemKeys.properties = removedProperties;
228 removedList << itemKeys;
229 }
230 }
231 m_propertyUpdates.clear();
232
233 if (!m_emittedLayoutUpdatedOnce) {
234 // No need to tell the world about action changes: nobody knows the
235 // menu layout so nobody knows about the actions.
236 // Note: We still need to reach this method because we want our properties to be
237 // updated, even if we don't announce changes.
238 return;
239 }
240 if (!updatedList.isEmpty() || !removedList.isEmpty()) {
241#ifdef ENABLE_DEBUG_LOGGING
242 logPropertyUpdates(updatedList, removedList);
243#endif
244
245 Q_EMIT ItemsPropertiesUpdated(updatedList, removedList);
246 }
247}
248
249void QPADBusMenuExporter::doMenuLayoutUpdate()
250{
251 // Tell the world about the update
252 if (m_emittedLayoutUpdatedOnce) {
253 Q_FOREACH(int id, m_layoutUpdates) {
254 Q_EMIT LayoutUpdated(++m_revision, id);
255 }
256 } else {
257 // First time we emit LayoutUpdated, no need to emit several layout
258 // updates, signals the whole layout (id==0) has been updated
259 Q_EMIT LayoutUpdated(++m_revision, 0);
260 m_emittedLayoutUpdatedOnce = true;
261 }
262 m_layoutUpdates.clear();
263}
264
265void QPADBusMenuExporter::addMenu(ExportedPlatformMenu *menu, int parentId)
266{
267 if (!menu) return;
268 if (m_menuForId.contains(menu->id())) return;
269
270 for (uint i = 0; i < menu->menuItemCount(); i++) {
271 auto exportedMenuItem = qobject_cast<ExportedPlatformMenuItem*>(menu->menuItemAt(i));
272 addMenuItem(exportedMenuItem, menu->id());
273 }
274
275 m_menuForId[menu->id()] = menu;
276 m_propertiesForId[menu->id()] = ExportedPlatformMenuPrivate::propertiesForMenu(menu);
277 connect(menu, &ExportedPlatformMenu::propertyUpdated, this, [&, menu]() {
278 menuPropertyUpdated(menu->id());
279 });
280 connect(menu, &ExportedPlatformMenu::menuItemInserted, this, [&, menu](QPlatformMenuItem* menuItem) {
281 addMenuItem(qobject_cast<ExportedPlatformMenuItem*>(menuItem), menu->id());
282 });
283 connect(menu, &ExportedPlatformMenu::menuItemRemoved, this, [&, menu](QPlatformMenuItem* menuItem) {
284 removeMenuItem(qobject_cast<ExportedPlatformMenuItem*>(menuItem), menu->id());
285 });
286
287 menuLayoutUpdated(parentId);
288}
289
290void QPADBusMenuExporter::addMenuItem(ExportedPlatformMenuItem *menuItem, int parentId)
291{
292 if (!menuItem) return;
293 if (m_menuItemForId.contains(menuItem->id())) return;
294
295 m_menuItemForId[menuItem->id()] = menuItem;
296 m_propertiesForId[menuItem->id()] = ExportedPlatformMenuItemPrivate::propertiesForMenuItem(menuItem);
297
298 connect(menuItem, &ExportedPlatformMenuItem::propertyUpdated, this, [&, menuItem]() {
299 menuPropertyUpdated(menuItem->id());
300 });
301
302 auto menu = qobject_cast<ExportedPlatformMenu*>(menuItem->menu());
303 if (menu) {
304 addMenu(menu, parentId);
305 }
306 menuLayoutUpdated(parentId);
307}
308
309void QPADBusMenuExporter::removeMenu(ExportedPlatformMenu *menu, int parentId)
310{
311 if (!menu) return;
312
313 for (uint i = 0; i < menu->menuItemCount(); i++) {
314 auto exportedMenuItem = qobject_cast<ExportedPlatformMenuItem*>(menu->menuItemAt(i));
315 removeMenuItem(exportedMenuItem, parentId);
316 }
317 disconnect(menu, 0, this, 0);
318}
319
320void QPADBusMenuExporter::removeMenuItem(ExportedPlatformMenuItem *menuItem, int parentId)
321{
322 if (!menuItem) return;
323
324 auto menu = qobject_cast<ExportedPlatformMenu*>(menuItem->menu());
325 if (menu) {
326 removeMenu(menu, menuItem->id());
327 }
328
329 m_menuItemForId.remove(menuItem->id());
330 m_propertiesForId.remove(menuItem->id());
331 disconnect(menuItem, 0, this, 0);
332
333 menuLayoutUpdated(parentId);
334}
335
336QVariantMap QPADBusMenuExporter::getProperties(int id, const QStringList &names) const
337{
338 if (id == 0) {
339 QVariantMap map;
340 map.insert(DBusMenuProperty::ChildrenDisplay, "submenu");
341 return map;
342 }
343 QVariantMap all = m_propertiesForId.value(id);
344 if (names.isEmpty()) {
345 return all;
346 } else {
347 QVariantMap map;
348 Q_FOREACH(const QString &name, names) {
349 QVariant value = all.value(name);
350 if (value.isValid()) {
351 map.insert(name, value);
352 }
353 }
354 return map;
355 }
356}
357
0358
=== added file 'src/qpa/qpadbusmenuexporter_p.h'
--- src/qpa/qpadbusmenuexporter_p.h 1970-01-01 00:00:00 +0000
+++ src/qpa/qpadbusmenuexporter_p.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,94 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Nick Dedekind <nick.dedekind@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef QPADBUSMENUEXPORTER_H
22#define QPADBUSMENUEXPORTER_H
23
24// Qt
25#include <QtCore/QObject>
26#include <QtDBus/QDBusConnection>
27#include <qpa/qplatformmenu.h>
28
29// Local
30#include "dbusmenuexporterdbusinterface_p.h"
31
32class QAction;
33class QMenu;
34
35class ExportedPlatformMenuBar;
36class ExportedPlatformMenu;
37class ExportedPlatformMenuItem;
38
39/**
40 * A QPADBusMenuExporter instance can serialize a qua menu over DBus
41 */
42class QPADBusMenuExporter : public DBusMenuExporterDBusInterface
43{
44 Q_OBJECT
45 Q_CLASSINFO("D-Bus Interface", "com.canonical.dbusmenu")
46public:
47 QPADBusMenuExporter(const QString& path, ExportedPlatformMenuBar* menuBar);
48 virtual ~QPADBusMenuExporter();
49
50 // overrides
51 void Event(int id, const QString &eventId, const QDBusVariant &data, uint timestamp) override;
52 QDBusVariant GetProperty(int id, const QString &property) override;
53 uint GetLayout(int parentId, int recursionDepth, const QStringList &propertyNames, DBusMenuLayoutItem &item) override;
54 DBusMenuItemList GetGroupProperties(const QList<int> &ids, const QStringList &propertyNames) override;
55 bool AboutToShow(int id) override;
56
57private Q_SLOTS:
58 void menuPropertyUpdated(int id);
59 void menuLayoutUpdated(int id);
60
61private Q_SLOTS:
62 void doMenuPropertyUpdate();
63 void doMenuLayoutUpdate();
64
65private:
66 Q_DISABLE_COPY(QPADBusMenuExporter)
67
68 void addMenu(ExportedPlatformMenu* menu, int parentId);
69 void addMenuItem(ExportedPlatformMenuItem* menu, int parentId);
70
71 void removeMenu(ExportedPlatformMenu* menu, int parentId);
72 void removeMenuItem(ExportedPlatformMenuItem* menuItem, int parentId);
73
74 void fillLayout(DBusMenuLayoutItem *item, int id, int depth, const QStringList &propertyNames);
75 QVariantMap getProperties(int id, const QStringList &names) const;
76
77 ExportedPlatformMenuBar* m_menuBar;
78 QTimer* m_propertyTimer;
79 QTimer* m_layoutTimer;
80
81 QList<int> m_propertyUpdates;
82 QList<int> m_layoutUpdates;
83 uint m_revision;
84 bool m_emittedLayoutUpdatedOnce;
85
86 QHash<int, ExportedPlatformMenuItem*> m_menuItemForId;
87 QHash<int, ExportedPlatformMenu*> m_menuForId;
88 QHash<int, QVariantMap> m_propertiesForId;
89
90 friend class ExportedPlatformMenu;
91 friend class ExportedPlatformMenuItem;
92};
93
94#endif /* QPADBUSMENUEXPORTER_H */
095
=== modified file 'src/utils.cpp'
--- src/utils.cpp 2010-09-20 08:55:12 +0000
+++ src/utils.cpp 2015-03-18 11:19:06 +0000
@@ -23,7 +23,7 @@
23// Qt23// Qt
24#include <QString>24#include <QString>
2525
26QString swapMnemonicChar(const QString &in, const char src, const char dst)26QString Utils::swapMnemonicChar(const QString &in, const char src, const char dst)
27{27{
28 QString out;28 QString out;
29 bool mnemonicFound = false;29 bool mnemonicFound = false;
@@ -62,3 +62,38 @@
6262
63 return out;63 return out;
64}64}
65
66
67void Utils::parsePropertyChanges(const QVariantMap &oldProperties,
68 const QVariantMap &newProperties,
69 QVariantMap &updatedProperties,
70 QStringList &removedProperties)
71{
72 // Find updated and removed properties
73 QVariantMap::ConstIterator newEnd = newProperties.constEnd();
74
75 QVariantMap::ConstIterator
76 oldIt = oldProperties.constBegin(),
77 oldEnd = oldProperties.constEnd();
78 for(; oldIt != oldEnd; ++oldIt) {
79 QString key = oldIt.key();
80 QVariantMap::ConstIterator newIt = newProperties.constFind(key);
81 if (newIt != newEnd) {
82 if (newIt.value() != oldIt.value()) {
83 updatedProperties.insert(key, newIt.value());
84 }
85 } else {
86 removedProperties << key;
87 }
88 }
89
90 // Find new properties (treat them as updated properties)
91 QVariantMap::ConstIterator newIt = newProperties.constBegin();
92 for (; newIt != newEnd; ++newIt) {
93 QString key = newIt.key();
94 oldIt = oldProperties.constFind(key);
95 if (oldIt == oldEnd) {
96 updatedProperties.insert(key, newIt.value());
97 }
98 }
99}
65100
=== modified file 'src/utils_p.h'
--- src/utils_p.h 2010-09-20 08:55:12 +0000
+++ src/utils_p.h 2015-03-18 11:19:06 +0000
@@ -22,10 +22,20 @@
22#define UTILS_P_H22#define UTILS_P_H
2323
24class QString;24class QString;
2525class QStringList;
26/**26#include <QVariant>
27 * Swap mnemonic char: Qt uses '&', while dbusmenu uses '_'27
28 */28namespace Utils {
29QString swapMnemonicChar(const QString &in, const char src, const char dst);29
30 /**
31 * Swap mnemonic char: Qt uses '&', while dbusmenu uses '_'
32 */
33 QString swapMnemonicChar(const QString &in, const char src, const char dst);
34
35 void parsePropertyChanges(const QVariantMap& oldProperties,
36 const QVariantMap& newProperties,
37 QVariantMap& updatedProperties,
38 QStringList& removedProperties);
39}
3040
31#endif /* UTILS_P_H */41#endif /* UTILS_P_H */
3242
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2015-03-18 11:19:06 +0000
+++ tests/CMakeLists.txt 2015-03-18 11:19:06 +0000
@@ -120,5 +120,18 @@
120 ${test_LIBRARIES}120 ${test_LIBRARIES}
121 )121 )
122122
123
124# exportedplatformmenutest
125if (USE_QT5)
126 add_test_executable(exportedplatformmenutest
127 exportedplatformmenutest.cpp
128 testutils.cpp
129 )
130
131 target_link_libraries(exportedplatformmenutest
132 ${test_LIBRARIES}
133 )
134endif()
135
123# Keep this at the end136# Keep this at the end
124create_check_target()137create_check_target()
125138
=== modified file 'tests/dbusmenuexportertest.cpp'
--- tests/dbusmenuexportertest.cpp 2015-03-18 11:19:06 +0000
+++ tests/dbusmenuexportertest.cpp 2015-03-18 11:19:06 +0000
@@ -31,7 +31,7 @@
3131
32// DBusMenuQt32// DBusMenuQt
33#include <dbusmenuexporter.h>33#include <dbusmenuexporter.h>
34#include <dbusmenutypes_p.h>34#include <dbusmenutypes.h>
35#include <dbusmenushortcut_p.h>35#include <dbusmenushortcut_p.h>
36#include <debug_p.h>36#include <debug_p.h>
3737
@@ -114,6 +114,7 @@
114 if (enabled) {114 if (enabled) {
115 QVERIFY(!item.properties.contains("enabled"));115 QVERIFY(!item.properties.contains("enabled"));
116 } else {116 } else {
117 QVERIFY(item.properties.contains("enabled"));
117 QCOMPARE(item.properties.value("enabled").toBool(), false);118 QCOMPARE(item.properties.value("enabled").toBool(), false);
118 }119 }
119 if (iconName.isEmpty()) {120 if (iconName.isEmpty()) {
120121
=== added file 'tests/exportedplatformmenutest.cpp'
--- tests/exportedplatformmenutest.cpp 1970-01-01 00:00:00 +0000
+++ tests/exportedplatformmenutest.cpp 2015-03-18 11:19:06 +0000
@@ -0,0 +1,366 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21// Self
22#include "exportedplatformmenutest.h"
23
24// Qt
25#include <QDBusConnection>
26#include <QDBusInterface>
27#include <QDBusReply>
28#include <QtTest>
29
30// DBusMenuQt
31#include <qpa/exportedplatformmenubar.h>
32#include <dbusmenutypes.h>
33#include <dbusmenushortcut_p.h>
34#include <debug_p.h>
35
36// Local
37#include "testutils.h"
38
39QTEST_MAIN(ExportedPlatformMenuTest)
40
41static const char *TEST_SERVICE = "org.kde.dbusmenu-qt-test";
42static const char *TEST_OBJECT_PATH = "/TestMenuBar";
43
44Q_DECLARE_METATYPE(QList<int>)
45
46static DBusMenuLayoutItemList getChildren(QDBusAbstractInterface* iface, int parentId, const QStringList &propertyNames)
47{
48 QDBusPendingReply<uint, DBusMenuLayoutItem> reply = iface->call("GetLayout", parentId, /*recursionDepth=*/ 1, propertyNames);
49 reply.waitForFinished();
50 if (!reply.isValid()) {
51 qFatal("%s", qPrintable(reply.error().message()));
52 return DBusMenuLayoutItemList();
53 }
54
55 DBusMenuLayoutItem rootItem = reply.argumentAt<1>();
56 return rootItem.children;
57}
58
59void ExportedPlatformMenuTest::init()
60{
61 QVERIFY(QDBusConnection::sessionBus().registerService(TEST_SERVICE));
62 QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
63}
64
65void ExportedPlatformMenuTest::cleanup()
66{
67 QVERIFY(QDBusConnection::sessionBus().unregisterService(TEST_SERVICE));
68}
69
70void ExportedPlatformMenuTest::testGetSomeMenuProperties_data()
71{
72 QTest::addColumn<QString>("label");
73 QTest::addColumn<QString>("iconName");
74 QTest::addColumn<bool>("enabled");
75
76 QTest::newRow("label only") << "label" << QString() << true;
77 QTest::newRow("disabled, label only") << "label" << QString() << false;
78 QTest::newRow("icon name") << "label" << "edit-undo" << true;
79}
80
81void ExportedPlatformMenuTest::testGetSomeMenuProperties()
82{
83 QFETCH(QString, label);
84 QFETCH(QString, iconName);
85 QFETCH(bool, enabled);
86
87 // Create an exporter for a menu with one action, defined by the test data
88 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
89 ExportedPlatformMenu menu;
90 menu.setText(label);
91 if (!iconName.isEmpty()) {
92 QIcon icon = QIcon::fromTheme(iconName);
93 QVERIFY(!icon.isNull());
94 menu.setIcon(icon);
95 }
96 menu.setEnabled(enabled);
97 menuBar.insertMenu(&menu, nullptr);
98
99 // Check out exporter is on DBus
100 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
101 QVERIFY2(iface.isValid(), qPrintable(iface.lastError().message()));
102
103 // Get exported menu info
104 QStringList propertyNames = QStringList() << "type" << "enabled" << "label" << "icon-name";
105 DBusMenuLayoutItemList list = getChildren(&iface, /*parentId=*/0, propertyNames);
106 QVERIFY(!list.isEmpty());
107 DBusMenuLayoutItem item = list.first();
108
109 QVERIFY(item.id != 0);
110 QVERIFY(item.children.isEmpty());
111 QVERIFY(!item.properties.contains("type"));
112 QCOMPARE(item.properties.value("label").toString(), label);
113 if (enabled) {
114 QVERIFY(!item.properties.contains("enabled"));
115 } else {
116 QVERIFY(item.properties.contains("enabled"));
117 QCOMPARE(item.properties.value("enabled").toBool(), false);
118 }
119 if (iconName.isEmpty()) {
120 QVERIFY(!item.properties.contains("icon-name"));
121 } else {
122 QCOMPARE(item.properties.value("icon-name").toString(), iconName);
123 }
124}
125
126void ExportedPlatformMenuTest::testGetSomeMenuItemProperties_data()
127{
128 QTest::addColumn<QString>("label");
129 QTest::addColumn<QString>("iconName");
130 QTest::addColumn<bool>("enabled");
131
132 QTest::newRow("label only") << "label" << QString() << true;
133 QTest::newRow("disabled, label only") << "label" << QString() << false;
134 QTest::newRow("icon name") << "label" << "edit-undo" << true;
135}
136
137void ExportedPlatformMenuTest::testGetSomeMenuItemProperties()
138{
139 QFETCH(QString, label);
140 QFETCH(QString, iconName);
141 QFETCH(bool, enabled);
142
143 // Create an exporter for a menu with one action, defined by the test data
144 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
145 ExportedPlatformMenu menu;
146 menuBar.insertMenu(&menu, nullptr);
147
148 ExportedPlatformMenuItem menuItem1;
149 menuItem1.setText(label);
150 if (!iconName.isEmpty()) {
151 QIcon icon = QIcon::fromTheme(iconName);
152 QVERIFY(!icon.isNull());
153 menuItem1.setIcon(icon);
154 }
155 menuItem1.setEnabled(enabled);
156 menu.insertMenuItem(&menuItem1, nullptr);
157
158 // Check out exporter is on DBus
159 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
160 QVERIFY2(iface.isValid(), qPrintable(iface.lastError().message()));
161
162 // Get exported menu info
163 QStringList propertyNames = QStringList() << "type" << "enabled" << "label" << "icon-name";
164 DBusMenuLayoutItemList list = getChildren(&iface, /*parentId=*/0, propertyNames);
165 QVERIFY(!list.isEmpty());
166
167 // Now get the mennu children (menu items)
168 list = getChildren(&iface, list.first().id, QStringList());
169 QVERIFY(!list.isEmpty());
170 DBusMenuLayoutItem item = list.first();
171
172 QVERIFY(item.id != 0);
173 QVERIFY(item.children.isEmpty());
174 QVERIFY(!item.properties.contains("type"));
175 QCOMPARE(item.properties.value("label").toString(), label);
176 if (enabled) {
177 QVERIFY(!item.properties.contains("enabled"));
178 } else {
179 QVERIFY(item.properties.contains("enabled"));
180 QCOMPARE(item.properties.value("enabled").toBool(), false);
181 }
182 if (iconName.isEmpty()) {
183 QVERIFY(!item.properties.contains("icon-name"));
184 } else {
185 QCOMPARE(item.properties.value("icon-name").toString(), iconName);
186 }
187}
188
189void ExportedPlatformMenuTest::testGetAllProperties()
190{
191 // set of properties which must be returned because their values are not
192 // the default values
193 const QSet<QString> a1Properties = QSet<QString>()
194 << "label"
195 ;
196
197 const QSet<QString> separatorProperties = QSet<QString>()
198 << "type";
199
200 const QSet<QString> a2Properties = QSet<QString>()
201 << "label"
202 << "enabled"
203 << "icon-name"
204 << "icon-data" // Icon data is always provided if the icon is valid.
205 << "visible";
206
207 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
208 ExportedPlatformMenu menu;
209 menuBar.insertMenu(&menu, nullptr);
210
211 ExportedPlatformMenuItem menuItem1;
212 menuItem1.setText("m1");
213 menu.insertMenuItem(&menuItem1, nullptr);
214
215 ExportedPlatformMenuItem separator;
216 separator.setIsSeparator(true);
217 menu.insertMenuItem(&separator, nullptr);
218
219 ExportedPlatformMenuItem menuItem2;
220 menuItem2.setText("m2");
221 menuItem2.setEnabled(false);
222 menuItem2.setVisible(false);
223 QIcon icon = QIcon::fromTheme("edit-undo");
224 QVERIFY(!icon.isNull());
225 menuItem2.setIcon(icon);
226 menu.insertMenuItem(&menuItem2, nullptr);
227
228 // Export them
229 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
230 QVERIFY2(iface.isValid(), qPrintable(iface.lastError().message()));
231
232 // Get menu children
233 DBusMenuLayoutItemList list = getChildren(&iface, menu.id(), QStringList());
234 QCOMPARE(list.count(), 3);
235
236 // Check we get the right properties
237 DBusMenuLayoutItem item = list.takeFirst();
238 QCOMPARE(QSet<QString>::fromList(item.properties.keys()), a1Properties);
239
240 item = list.takeFirst();
241 QCOMPARE(QSet<QString>::fromList(item.properties.keys()), separatorProperties);
242
243 item = list.takeFirst();
244 QCOMPARE(QSet<QString>::fromList(item.properties.keys()), a2Properties);
245}
246
247void ExportedPlatformMenuTest::testGetNonExistentProperty()
248{
249 const char* NON_EXISTENT_KEY = "i-do-not-exist";
250
251 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
252 ExportedPlatformMenu menu;
253 menuBar.insertMenu(&menu, nullptr);
254
255 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
256 DBusMenuLayoutItemList list = getChildren(&iface, 0, QStringList() << NON_EXISTENT_KEY);
257 QCOMPARE(list.count(), 1);
258
259 DBusMenuLayoutItem item = list.takeFirst();
260 QVERIFY(!item.properties.contains(NON_EXISTENT_KEY));
261}
262
263void ExportedPlatformMenuTest::testClickedEvent()
264{
265 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
266 ExportedPlatformMenu menu;
267 menuBar.insertMenu(&menu, nullptr);
268
269 ExportedPlatformMenuItem menuItem1;
270 menuItem1.setText("m1");
271 menu.insertMenuItem(&menuItem1, nullptr);
272
273 QSignalSpy spy(&menuItem1, SIGNAL(activated()));
274
275 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
276 DBusMenuLayoutItemList list = getChildren(&iface, menu.id(), QStringList());
277 QCOMPARE(list.count(), 1);
278 int id = list.first().id;
279
280 QVariant empty = QVariant::fromValue(QDBusVariant(QString()));
281 uint timestamp = QDateTime::currentDateTime().toTime_t();
282 iface.call("Event", id, "clicked", empty, timestamp);
283 QTest::qWait(100);
284
285 QCOMPARE(spy.count(), 1);
286}
287
288void ExportedPlatformMenuTest::testSubMenu()
289{
290 // Root
291 // -- submenu
292 // ---- childmenu
293 // ----- hildmenu
294
295 // Create our test menu
296 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
297 ExportedPlatformMenu menu;
298 menuBar.insertMenu(&menu, nullptr);
299
300 ExportedPlatformMenu subMenu;
301 ExportedPlatformMenuItem subMenuItem;
302 subMenuItem.setMenu(&subMenu);
303 menu.insertMenuItem(&subMenuItem, nullptr);
304
305 ExportedPlatformMenuItem childMenu1;
306 ExportedPlatformMenuItem childMenu2;
307 subMenu.insertMenuItem(&childMenu1, nullptr);
308 subMenu.insertMenuItem(&childMenu2, nullptr);
309
310 // Check the structure
311 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
312 DBusMenuLayoutItemList list = getChildren(&iface, 0, QStringList());
313 QCOMPARE(list.count(), 1);
314
315 list = getChildren(&iface, list.first().id, QStringList());
316 QCOMPARE(list.count(), 1);
317
318 list = getChildren(&iface, list.first().id, QStringList());
319 QCOMPARE(list.count(), 2);
320}
321
322void ExportedPlatformMenuTest::testDynamicSubMenu()
323{
324 // Root
325 // -- childmenu
326 // -- childmenu
327
328 // Track LayoutUpdated() signal: we don't want this signal to be emitted
329 // too often because it causes refreshes
330 QDBusInterface iface(TEST_SERVICE, TEST_OBJECT_PATH);
331 ManualSignalSpy layoutUpdatedSpy;
332 QDBusConnection::sessionBus().connect(TEST_SERVICE, TEST_OBJECT_PATH, "com.canonical.dbusmenu", "LayoutUpdated", "ui", &layoutUpdatedSpy, SLOT(receiveCall(uint, int)));
333
334 // Create our test menu
335 ExportedPlatformMenuBar menuBar(TEST_OBJECT_PATH);
336 ExportedPlatformMenu menu;
337 menuBar.insertMenu(&menu, nullptr);
338
339 // LayoutUpdated should be emitted once because inputMenu is filled
340 QTest::qWait(100);
341 QCOMPARE(layoutUpdatedSpy.count(), 1);
342 QCOMPARE(layoutUpdatedSpy.takeFirst().at(1).toInt(), 0);
343
344 ExportedPlatformMenu subMenu;
345 ExportedPlatformMenuItem subMenuItem1;
346 subMenuItem1.setMenu(&subMenu);
347 ExportedPlatformMenuItem subMenuItem2;
348 subMenuItem2.setMenu(&subMenu);
349 menu.insertMenuItem(&subMenuItem1, nullptr);
350 menu.insertMenuItem(&subMenuItem2, nullptr);
351
352 QTest::qWait(100);
353 // LayoutUpdated should be emitted once more with the parent menus id
354 // because menu item was inserted.
355 QCOMPARE(layoutUpdatedSpy.count(), 1);
356 QCOMPARE(layoutUpdatedSpy.takeFirst().at(1).toInt(), menu.id());
357
358 DBusMenuLayoutItemList list = getChildren(&iface, 0, QStringList());
359 QCOMPARE(list.count(), 1);
360
361 list = getChildren(&iface, list.first().id, QStringList());
362 QCOMPARE(list.count(), 2);
363}
364
365
366#include "exportedplatformmenutest.moc"
0367
=== added file 'tests/exportedplatformmenutest.h'
--- tests/exportedplatformmenutest.h 1970-01-01 00:00:00 +0000
+++ tests/exportedplatformmenutest.h 2015-03-18 11:19:06 +0000
@@ -0,0 +1,55 @@
1/* This file is part of the dbusmenu-qt library
2 Copyright 2015 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License (LGPL) as published by the Free Software Foundation;
8 either version 2 of the License, or (at your option) any later
9 version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef EXPORTEDPLATFORMMENUTEST_H
22#define EXPORTEDPLATFORMMENUTEST_H
23
24#define QT_GUI_LIB
25#include <QtGui>
26
27// Qt
28#include <QObject>
29
30// Local
31
32class ExportedPlatformMenuTest : public QObject
33{
34Q_OBJECT
35private Q_SLOTS:
36 // properties
37 void testGetSomeMenuProperties();
38 void testGetSomeMenuProperties_data();
39 void testGetSomeMenuItemProperties();
40 void testGetSomeMenuItemProperties_data();
41 void testGetAllProperties();
42 void testGetNonExistentProperty();
43
44 // events
45 void testClickedEvent();
46
47 // heirachy
48 void testSubMenu();
49 void testDynamicSubMenu();
50
51 void init();
52 void cleanup();
53};
54
55#endif /* EXPORTEDPLATFORMMENUTEST_H */
056
=== modified file 'tests/testutils.h'
--- tests/testutils.h 2011-08-29 14:51:01 +0000
+++ tests/testutils.h 2015-03-18 11:19:06 +0000
@@ -23,7 +23,7 @@
2323
24// Local24// Local
25#include <debug_p.h>25#include <debug_p.h>
26#include <dbusmenutypes_p.h>26#include <dbusmenutypes.h>
2727
28// Qt28// Qt
29#include <QObject>29#include <QObject>

Subscribers

People subscribed via source and target branches

to all changes: