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 DBUSMENUEXPORTER_H
22 #define DBUSMENUEXPORTER_H
25 #include <QtCore/QObject>
26 #include <QtDBus/QDBusConnection>
31 #include <dbusmenu_export.h>
33 class DBusMenuExporterPrivate;
36 * A DBusMenuExporter instance can serialize a menu over DBus
38 class DBUSMENU_EXPORT DBusMenuExporter : public QObject
43 * Creates a DBusMenuExporter exporting menu at the dbus object path
44 * dbusObjectPath, using the given dbusConnection.
45 * The instance adds itself to the menu children.
47 DBusMenuExporter(const QString &dbusObjectPath, QMenu *menu, const QDBusConnection &dbusConnection = QDBusConnection::sessionBus());
49 virtual ~DBusMenuExporter();
52 * Asks the matching DBusMenuImporter to activate @p action. For menus it
53 * means popup them, for items it means triggering the associated action.
55 void activateAction(QAction *action);
58 * The status of the menu. Can be one of "normal" or "notice". This can be
59 * used to notify the other side the menu should be made more visible.
60 * For example, appmenu uses it to tell Unity panel to show/hide the menubar
61 * when the Alt modifier is pressed/released.
63 void setStatus(const QString &status);
66 * Returns the status of the menu.
69 QString status() const;
73 * Must extract the icon name for action. This is the name which will
74 * be used to present the icon over DBus.
75 * Default implementation returns action->icon().name() when built on Qt
76 * >= 4.7 and a null string otherwise.
78 virtual QString iconNameForAction(QAction *action);
81 void doUpdateActions();
82 void doEmitLayoutUpdated();
83 void slotActionDestroyed(QObject*);
86 Q_DISABLE_COPY(DBusMenuExporter)
87 DBusMenuExporterPrivate *const d;
89 friend class DBusMenuExporterPrivate;
90 friend class DBusMenuExporterDBus;
91 friend class DBusMenu;
94 #endif /* DBUSMENUEXPORTER_H */