modernize: Reformat ALL the source... again!
[quassel.git] / src / qtui / statusnotifieritem.h
index 9a805be..2973919 100644 (file)
 
 #ifdef HAVE_DBUS
 
-#include <QtGlobal>
+#    include <QDBusError>
+#    include <QHash>
+#    include <QString>
+#    include <QTemporaryDir>
 
-#if QT_VERSION >= 0x050000
-#  include <QTemporaryDir>
-#endif
+#    include "notificationsclient.h"
+#    include "statusnotifierwatcher.h"
+#    include "systemtray.h"
 
-#include "notificationsclient.h"
-#include "systemtray.h"
-#include "statusnotifierwatcher.h"
+#    ifdef QT_NO_SYSTEMTRAYICON
+#        define StatusNotifierItemParent SystemTray
+#    else
+#        define StatusNotifierItemParent LegacySystemTray
+#        include "legacysystemtray.h"
+#    endif
 
-#ifdef QT_NO_SYSTEMTRAYICON
-#  define StatusNotifierItemParent SystemTray
-#else
-#  define StatusNotifierItemParent LegacySystemTray
-#  include "legacysystemtray.h"
-#endif
+class QDBusServiceWatcher;
 
 class StatusNotifierItemDBus;
 
@@ -49,22 +50,19 @@ class StatusNotifierItem : public StatusNotifierItemParent
     Q_OBJECT
 
 public:
-    explicit StatusNotifierItem(QWidget *parent);
-    ~StatusNotifierItem() override;
+    explicit StatusNotifierItem(QWidget* parent);
 
     bool isSystemTrayAvailable() const override;
-    bool isVisible() const override;
 
 public slots:
-    void setState(State state) override;
-    void setVisible(bool visible) override;
-    void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0) override;
+    void showMessage(const QString& title,
+                     const QString& message,
+                     MessageIcon icon = Information,
+                     int msTimeout = 10000,
+                     uint notificationId = 0) override;
     void closeMessage(uint notificationId) override;
 
 protected:
-    void init() override;
-    void setMode(Mode mode) override;
-
     QString title() const;
     QString iconName() const;
     QString attentionIconName() const;
@@ -72,38 +70,39 @@ protected:
     QString iconThemePath() const;
     QString menuObjectPath() const;
 
-    bool eventFilter(QObject *watched, QEvent *event) override;
+    bool eventFilter(QObject* watched, QEvent* event) override;
 
 private slots:
-    void activated(const QPoint &pos);
-    void serviceChange(const QString &name, const QString &oldOwner, const QString &newOwner);
+    void activated(const QPointpos);
+    void serviceChange(const QString& name, const QString& oldOwner, const QString& newOwner);
     void checkForRegisteredHosts();
+    void onDBusError(const QDBusError& error);
 
     void notificationClosed(uint id, uint reason);
-    void notificationInvoked(uint id, const QString &action);
+    void notificationInvoked(uint id, const QStringaction);
 
     void refreshIcons();
 
-private:
-    void registerToDaemon();
+    void onModeChanged(Mode mode);
+    void onStateChanged(State state);
+    void onVisibilityChanged(bool isVisible);
 
-    static const int _protocolVersion;
-    static const QString _statusNotifierWatcherServiceName;
-    StatusNotifierItemDBus *_statusNotifierItemDBus{nullptr};
+private:
+    void registerToWatcher();
 
-    org::kde::StatusNotifierWatcher *_statusNotifierWatcher{nullptr};
-    org::freedesktop::Notifications *_notificationsClient{nullptr};
+    QDBusServiceWatcher* _serviceWatcher{nullptr};
+    StatusNotifierItemDBus* _statusNotifierItemDBus{nullptr};
+    org::kde::StatusNotifierWatcher* _statusNotifierWatcher{nullptr};
+    org::freedesktop::Notifications* _notificationsClient{nullptr};
     bool _notificationsClientSupportsMarkup{false};
     bool _notificationsClientSupportsActions{false};
     quint32 _lastNotificationsDBusId{0};
-    QHash<uint, uint> _notificationsIdMap; ///< Maps our own notification ID to the D-Bus one
+    QHash<uint, uint> _notificationsIdMap;  ///< Maps our own notification ID to the D-Bus one
 
     QString _iconThemePath;
     QString _menuObjectPath;
 
-#if QT_VERSION >= 0x050000
     QTemporaryDir _iconThemeDir;
-#endif
 
     friend class StatusNotifierItemDBus;
 };