| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QDBUSMENUCONNECTION_H |
| 5 | #define QDBUSMENUCONNECTION_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include <QtCore/QString> |
| 19 | #include <QtDBus/QDBusConnection> |
| 20 | #include <QtDBus/QDBusVariant> |
| 21 | |
| 22 | #include <QtGui/qtgui-config.h> |
| 23 | #include <QtCore/private/qglobal_p.h> |
| 24 | Q_MOC_INCLUDE(<QtDBus/QDBusError>) |
| 25 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QDBusServiceWatcher; |
| 29 | #ifndef QT_NO_SYSTEMTRAYICON |
| 30 | class QDBusTrayIcon; |
| 31 | #endif // QT_NO_SYSTEMTRAYICON |
| 32 | |
| 33 | class QDBusMenuConnection : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | public: |
| 38 | QDBusMenuConnection(QObject *parent = nullptr, const QString &serviceName = QString()); |
| 39 | ~QDBusMenuConnection(); |
| 40 | QDBusConnection connection() const { return m_connection; } |
| 41 | QDBusServiceWatcher *dbusWatcher() const { return m_dbusWatcher; } |
| 42 | bool isWatcherRegistered() const { return m_watcherRegistered; } |
| 43 | #ifndef QT_NO_SYSTEMTRAYICON |
| 44 | bool registerTrayIconMenu(QDBusTrayIcon *item); |
| 45 | void unregisterTrayIconMenu(QDBusTrayIcon *item); |
| 46 | bool registerTrayIcon(QDBusTrayIcon *item); |
| 47 | bool registerTrayIconWithWatcher(QDBusTrayIcon *item); |
| 48 | void unregisterTrayIcon(QDBusTrayIcon *item); |
| 49 | #endif // QT_NO_SYSTEMTRAYICON |
| 50 | |
| 51 | Q_SIGNALS: |
| 52 | #ifndef QT_NO_SYSTEMTRAYICON |
| 53 | void trayIconRegistered(); |
| 54 | #endif // QT_NO_SYSTEMTRAYICON |
| 55 | |
| 56 | private Q_SLOTS: |
| 57 | void dbusError(const QDBusError &error); |
| 58 | |
| 59 | private: |
| 60 | QString m_serviceName; |
| 61 | QDBusConnection m_connection; |
| 62 | QDBusServiceWatcher *m_dbusWatcher; |
| 63 | bool m_watcherRegistered; |
| 64 | }; |
| 65 | |
| 66 | QT_END_NAMESPACE |
| 67 | |
| 68 | #endif // QDBUSMENUCONNECTION_H |
| 69 |
