1 /* This file is part of the dbusmenu-qt library
2 Copyright 2009 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
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
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.
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.
21 #ifndef DBUSMENUIMPORTER_H
22 #define DBUSMENUIMPORTER_H
25 #include <QtCore/QObject>
26 #include <QtDBus/QDBusAbstractInterface>
27 #include <QtDBus/QDBusPendingCallWatcher>
28 #include <QtDBus/QDBusVariant>
34 #include <dbusmenu_export.h>
36 class DBusMenuImporterPrivate;
39 * Determine whether internal method calls should allow the Qt event loop
42 enum DBusMenuImporterType {
48 * A DBusMenuImporter instance can recreate a menu serialized over DBus by
51 class DBUSMENU_EXPORT DBusMenuImporter : public QObject
56 * Creates a DBusMenuImporter listening over DBus on service, path
58 DBusMenuImporter(const QString &service, const QString &path, QObject *parent = 0);
61 * Creates a DBusMenuImporter listening over DBus on service, path, with either async
64 DBusMenuImporter(const QString &service, const QString &path, DBusMenuImporterType type, QObject *parent = 0);
66 virtual ~DBusMenuImporter();
69 * The menu created from listening to the DBusMenuExporter over DBus
75 * Simulates a QMenu::aboutToShow() signal on the menu returned by menu(),
76 * ensuring it is up to date in case the menu is populated on the fly. It
77 * is not mandatory to call this method, showing the menu with
78 * QMenu::popup() or QMenu::exec() will generates an aboutToShow() signal,
79 * but calling it before ensures the size-hint of the menu is correct when
80 * it is time to show it, avoiding wrong positioning.
82 * menuUpdated() will be emitted when the menu is ready.
84 * Not that the aboutToShow() signal is only sent to the root menu, not to
91 * Emitted after a call to updateMenu().
97 * Emitted when the exporter was asked to activate an action
99 void actionActivationRequested(QAction *);
103 * Must create a menu, may be customized to fit host appearance.
104 * Default implementation creates a simple QMenu.
106 virtual QMenu *createMenu(QWidget *parent);
109 * Must convert a name into an icon.
110 * Default implementation returns a null icon.
112 virtual QIcon iconForName(const QString &);
115 void sendClickedEvent(int);
116 void slotMenuAboutToShow();
117 void slotMenuAboutToHide();
118 void slotAboutToShowDBusCallFinished(QDBusPendingCallWatcher *);
119 void slotItemActivationRequested(int id, uint timestamp);
120 void processPendingLayoutUpdates();
121 void slotLayoutUpdated(uint revision, int parentId);
122 void slotGetLayoutFinished(QDBusPendingCallWatcher *);
125 Q_DISABLE_COPY(DBusMenuImporter)
126 DBusMenuImporterPrivate *const d;
127 friend class DBusMenuImporterPrivate;
129 // Use Q_PRIVATE_SLOT to avoid exposing DBusMenuItemList
130 Q_PRIVATE_SLOT(d, void slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList))
133 #endif /* DBUSMENUIMPORTER_H */