From 1dbc0e3c88ba271ba35bc3f82e7864c4f35e1236 Mon Sep 17 00:00:00 2001 From: Fabien Proriol Date: Sun, 25 May 2025 12:13:31 +0200 Subject: Initial Commit --- src/lib/xdgstatusnotifierwatcher.h | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/lib/xdgstatusnotifierwatcher.h (limited to 'src/lib/xdgstatusnotifierwatcher.h') diff --git a/src/lib/xdgstatusnotifierwatcher.h b/src/lib/xdgstatusnotifierwatcher.h new file mode 100644 index 0000000..8e2275c --- /dev/null +++ b/src/lib/xdgstatusnotifierwatcher.h @@ -0,0 +1,48 @@ +#ifndef XDGSTATUSNOTIFIERWATCHER_H +#define XDGSTATUSNOTIFIERWATCHER_H + +#include + +class QDBusServiceWatcher; +#define XDG_STATUS_NOTIFIER_WATCHER_PROTOCOL_VERSION 1 + +namespace xdg { + + class StatusNotifierWatcher: public QObject + { + Q_OBJECT + + Q_PROPERTY(QStringList RegisteredStatusNotifierItems READ RegisteredStatusNotifierItems NOTIFY RegisteredStatusNotifierItemsChanged) + Q_PROPERTY(bool IsStatusNotifierHostRegistered READ IsStatusNotifierHostRegistered NOTIFY IsStatusNotifierHostRegisteredChanged) + Q_PROPERTY(int ProtocolVersion READ ProtocolVersion CONSTANT) + + public: + StatusNotifierWatcher(QObject *parent = nullptr); + virtual ~StatusNotifierWatcher(); + + void RegisterStatusNotifierItem(const QString &service); + void RegisterStatusNotifierHost(const QString &service); + + QStringList RegisteredStatusNotifierItems() const; + bool IsStatusNotifierHostRegistered() const; + int ProtocolVersion() const; + + signals: + void StatusNotifierItemRegistered(QString id); + void StatusNotifierItemUnregistered(QString id); + void StatusNotifierHostRegistered(); + void StatusNotifierHostUnregistered(); + void RegisteredStatusNotifierItemsChanged(); + void IsStatusNotifierHostRegisteredChanged(); + + private: + QStringList m_hosts; + QStringList m_items; + QDBusServiceWatcher *m_serviceWatcher = nullptr; + + private slots: + void _serviceUnregistered(const QString &name); + }; +}; + +#endif // XDGSTATUSNOTIFIERWATCHER_H -- cgit v1.2.3