Debian Codegraph @

src/dbusmenuimporter.h

raw symbols SCIP
1 /* This file is part of the dbusmenu-qt library
2 Copyright 2009 Canonical
3 Author: Aurelien Gateau <[email protected]>
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 DBUSMENUIMPORTER_H
22 #define DBUSMENUIMPORTER_H
23
24 // Qt
25 #include <QtCore/QObject>
26
27 // Local
28 #include <dbusmenu_export.h>
29
30 class QAction;
31 class QDBusAbstractInterface;
32 class QDBusPendingCallWatcher;
33 class QDBusVariant;
34 class QIcon;
35 class QMenu;
36
37 class DBusMenuImporterPrivate;
38
39 /**
40 * Determine whether internal method calls should allow the Qt event loop
41 * to execute or not
42 */
43 enum DBusMenuImporterType {
44 ASYNCHRONOUS,
45 SYNCHRONOUS
46 };
47
48 /**
49 * A DBusMenuImporter instance can recreate a menu serialized over DBus by
50 * DBusMenuExporter
51 */
52 class DBUSMENU_EXPORT DBusMenuImporter : public QObject
53 {
54 Q_OBJECT
55 public:
56 /**
57 * Creates a DBusMenuImporter listening over DBus on service, path
58 */
59 DBusMenuImporter(const QString &service, const QString &path, QObject *parent = 0);
60
61 /**
62 * Creates a DBusMenuImporter listening over DBus on service, path, with either async
63 * or sync DBus calls
64 */
65 DBusMenuImporter(const QString &service, const QString &path, DBusMenuImporterType type, QObject *parent = 0);
66
67 virtual ~DBusMenuImporter();
68
69 /**
70 * The menu created from listening to the DBusMenuExporter over DBus
71 */
72 QMenu *menu() const;
73
74 public Q_SLOTS:
75 /**
76 * Simulates a QMenu::aboutToShow() signal on the menu returned by menu(),
77 * ensuring it is up to date in case the menu is populated on the fly. It
78 * is not mandatory to call this method, showing the menu with
79 * QMenu::popup() or QMenu::exec() will generates an aboutToShow() signal,
80 * but calling it before ensures the size-hint of the menu is correct when
81 * it is time to show it, avoiding wrong positioning.
82 *
83 * menuUpdated() will be emitted when the menu is ready.
84 *
85 * Not that the aboutToShow() signal is only sent to the root menu, not to
86 * any submenu.
87 */
88 void updateMenu();
89
90 Q_SIGNALS:
91 /**
92 * Emitted after a call to updateMenu().
93 * @see updateMenu()
94 */
95 void menuUpdated();
96
97 /**
98 * Emitted after every aboutToShow of the root menu.
99 * This signal is deprecated and only kept to keep compatibility with
100 * dbusmenu-qt 0.3.x. New code should use updateMenu() and menuUpdated()
101 *
102 * @deprecated
103 */
104 void menuReadyToBeShown();
105
106 /**
107 * Emitted when the exporter was asked to activate an action
108 */
109 void actionActivationRequested(QAction *);
110
111 protected:
112 /**
113 * Must create a menu, may be customized to fit host appearance.
114 * Default implementation creates a simple QMenu.
115 */
116 virtual QMenu *createMenu(QWidget *parent);
117
118 /**
119 * Must convert a name into an icon.
120 * Default implementation returns a null icon.
121 */
122 virtual QIcon iconForName(const QString &);
123
124 private Q_SLOTS:
125 void sendClickedEvent(int);
126 void slotMenuAboutToShow();
127 void slotMenuAboutToHide();
128 void slotAboutToShowDBusCallFinished(QDBusPendingCallWatcher *);
129 void slotItemActivationRequested(int id, uint timestamp);
130 void processPendingLayoutUpdates();
131 void slotLayoutUpdated(uint revision, int parentId);
132 void slotGetLayoutFinished(QDBusPendingCallWatcher *);
133
134 private:
135 Q_DISABLE_COPY(DBusMenuImporter)
136 DBusMenuImporterPrivate *const d;
137 friend class DBusMenuImporterPrivate;
138
139 // Use Q_PRIVATE_SLOT to avoid exposing DBusMenuItemList
140 Q_PRIVATE_SLOT(d, void slotItemsPropertiesUpdated(const DBusMenuItemList &updatedList, const DBusMenuItemKeysList &removedList))
141 };
142
143 #endif /* DBUSMENUIMPORTER_H */