KStatusNotifierItem

dbusmenuexporter.h
1/* This file is part of the dbusmenu-qt library
2 SPDX-FileCopyrightText: 2009 Canonical
3 Author: Aurelien Gateau <aurelien.gateau@canonical.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#ifndef DBUSMENUEXPORTER_H
8#define DBUSMENUEXPORTER_H
9
10// Qt
11#include <QDBusConnection>
12#include <QObject>
13
14class QAction;
15class QMenu;
16
17class DBusMenuExporterPrivate;
18
19/**
20 * A DBusMenuExporter instance can serialize a menu over DBus
21 */
23{
25public:
26 /**
27 * Creates a DBusMenuExporter exporting menu at the dbus object path
28 * dbusObjectPath, using the given dbusConnection.
29 * The instance adds itself to the menu children.
30 */
31 DBusMenuExporter(const QString &dbusObjectPath, QMenu *menu, const QDBusConnection &dbusConnection = QDBusConnection::sessionBus());
32
33 ~DBusMenuExporter() override;
34
35 /**
36 * Asks the matching DBusMenuImporter to activate @p action. For menus it
37 * means popup them, for items it means triggering the associated action.
38 */
39 void activateAction(QAction *action);
40
41 /**
42 * The status of the menu. Can be one of "normal" or "notice". This can be
43 * used to notify the other side the menu should be made more visible.
44 * For example, appmenu uses it to tell Unity panel to show/hide the menubar
45 * when the Alt modifier is pressed/released.
46 */
47 void setStatus(const QString &status);
48
49 /**
50 * Returns the status of the menu.
51 * @ref setStatus
52 */
53 QString status() const;
54
55protected:
56 /**
57 * Must extract the icon name for action. This is the name which will
58 * be used to present the icon over DBus.
59 * Default implementation returns action->icon().name() when built on Qt
60 * >= 4.7 and a null string otherwise.
61 */
62 virtual QString iconNameForAction(QAction *action);
63
64private Q_SLOTS:
65 void doUpdateActions();
66 void doEmitLayoutUpdated();
67 void slotActionDestroyed(QObject *);
68
69private:
70 Q_DISABLE_COPY(DBusMenuExporter)
71 DBusMenuExporterPrivate *const d;
72
73 friend class DBusMenuExporterPrivate;
74 friend class DBusMenuExporterDBus;
75 friend class DBusMenu;
76};
77
78#endif /* DBUSMENUEXPORTER_H */
A DBusMenuExporter instance can serialize a menu over DBus.
void activateAction(QAction *action)
Asks the matching DBusMenuImporter to activate action.
void setStatus(const QString &status)
The status of the menu.
QString status() const
Returns the status of the menu.
virtual QString iconNameForAction(QAction *action)
Must extract the icon name for action.
DBusMenuExporter(const QString &dbusObjectPath, QMenu *menu, const QDBusConnection &dbusConnection=QDBusConnection::sessionBus())
Creates a DBusMenuExporter exporting menu at the dbus object path dbusObjectPath, using the given dbu...
QDBusConnection sessionBus()
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.