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 after every aboutToShow of the root menu.
98 * This signal is deprecated and only kept to keep compatibility with
99 * dbusmenu-qt 0.3.x. New code should use updateMenu() and menuUpdated()
103 void menuReadyToBeShown();
106 * Emitted when the exporter was asked to activate an action
108 void actionActivationRequested(QAction *);
112 * Must create a menu, may be customized to fit host appearance.
113 * Default implementation creates a simple QMenu.
115 virtual QMenu *createMenu(QWidget *parent);
118 * Must convert a name into an icon.
119 * Default implementation returns a null icon.
121 virtual QIcon iconForName(const QString &);
124 void sendClickedEvent(int);
125 void slotMenuAboutToShow();
126 void slotMenuAboutToHide();
127 void slotAboutToShowDBusCallFinished(QDBusPendingCallWatcher *);
128 void slotItemActivationRequested(int id, uint timestamp);
129 void processPendingLayoutUpdates();
130 void slotLayoutUpdated(uint revision, int parentId);
131 void slotGetLayoutFinished(QDBusPendingCallWatcher *);
134 Q_DISABLE_COPY(DBusMenuImporter)
135 DBusMenuImporterPrivate *const d;
136 friend class DBusMenuImporterPrivate;
138 // Use Q_PRIVATE_SLOT to avoid exposing DBusMenuItemList
139 Q_PRIVATE_SLOT(d, void slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList))
142 #endif /* DBUSMENUIMPORTER_H */