X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fstatusnotifieritem.h;h=297391956c6ca26b0a77705d02f4215b28a7918b;hp=3bed80fafc3eb6d39e6a6fd995d4f1f504e24302;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hpb=5ba28fb36a747bd9a2c05a58f0533d1e38c2a0de diff --git a/src/qtui/statusnotifieritem.h b/src/qtui/statusnotifieritem.h index 3bed80fa..29739195 100644 --- a/src/qtui/statusnotifieritem.h +++ b/src/qtui/statusnotifieritem.h @@ -1,14 +1,14 @@ /*************************************************************************** - * Copyright (C) 2005-2010 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This contains code from KStatusNotifierItem, part of the KDE libs * * Copyright (C) 2009 Marco Martin * * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) version 3. * + * This file is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License (LGPL) * + * as published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -18,71 +18,93 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef STATUSNOTIFIERITEM_H_ -#define STATUSNOTIFIERITEM_H_ +#pragma once #ifdef HAVE_DBUS -#include "notificationsclient.h" -#include "systemtray.h" -#include "statusnotifierwatcher.h" +# include +# include +# include +# include -#ifdef QT_NO_SYSTEMTRAYICON -# define StatusNotifierItemParent SystemTray -#else -# define StatusNotifierItemParent LegacySystemTray -# include "legacysystemtray.h" -#endif +# include "notificationsclient.h" +# include "statusnotifierwatcher.h" +# include "systemtray.h" + +# ifdef QT_NO_SYSTEMTRAYICON +# define StatusNotifierItemParent SystemTray +# else +# define StatusNotifierItemParent LegacySystemTray +# include "legacysystemtray.h" +# endif + +class QDBusServiceWatcher; class StatusNotifierItemDBus; -class StatusNotifierItem : public StatusNotifierItemParent { - Q_OBJECT +class StatusNotifierItem : public StatusNotifierItemParent +{ + Q_OBJECT public: - explicit StatusNotifierItem(QWidget *parent); - virtual ~StatusNotifierItem(); + explicit StatusNotifierItem(QWidget* parent); + + bool isSystemTrayAvailable() const override; public slots: - virtual void setState(State state); - virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0); - virtual void closeMessage(uint notificationId); + void showMessage(const QString& title, + const QString& message, + MessageIcon icon = Information, + int msTimeout = 10000, + uint notificationId = 0) override; + void closeMessage(uint notificationId) override; protected: - virtual void init(); - virtual void setMode(Mode mode); - - QString title() const; - QString iconName() const; - QString attentionIconName() const; - QString toolTipIconName() const; + QString title() const; + QString iconName() const; + QString attentionIconName() const; + QString toolTipIconName() const; + QString iconThemePath() const; + QString menuObjectPath() const; - virtual bool eventFilter(QObject *watched, QEvent *event); + 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 QPoint& pos); + 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 notificationClosed(uint id, uint reason); + void notificationInvoked(uint id, const QString& action); + + void refreshIcons(); + + void onModeChanged(Mode mode); + void onStateChanged(State state); + void onVisibilityChanged(bool isVisible); private: - void registerToDaemon(); + void registerToWatcher(); + + 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 _notificationsIdMap; ///< Maps our own notification ID to the D-Bus one - static const int _protocolVersion; - StatusNotifierItemDBus *_statusNotifierItemDBus; + QString _iconThemePath; + QString _menuObjectPath; - org::kde::StatusNotifierWatcher *_statusNotifierWatcher; - org::freedesktop::Notifications *_notificationsClient; - bool _notificationsClientSupportsMarkup; - quint32 _lastNotificationsDBusId; - QHash _notificationsIdMap; ///< Maps our own notification ID to the D-Bus one + QTemporaryDir _iconThemeDir; - friend class StatusNotifierItemDBus; + friend class StatusNotifierItemDBus; }; #endif /* HAVE_DBUS */ -#endif /* STATUSNOTIFIERITEM_H_ */