X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Flegacysystemtray.h;h=83ff201256c3ece58d1d2176b2f0e2af07f01fa6;hb=518cd2bc478ab3675a60ec46d3ef183cace0cae7;hp=47c5f11e85c96f6fd50c6fba21c2faeca337c0be;hpb=d452877910888c25d40590b5fff57eb8197ca9b0;p=quassel.git diff --git a/src/qtui/legacysystemtray.h b/src/qtui/legacysystemtray.h index 47c5f11e..83ff2012 100644 --- a/src/qtui/legacysystemtray.h +++ b/src/qtui/legacysystemtray.h @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-2010 by the Quassel Project * + * Copyright (C) 2005-2020 by the Quassel Project * * devel@quassel-irc.org * * * - * 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 * @@ -15,69 +15,49 @@ * 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 LEGACYSYSTEMTRAY_H_ -#define LEGACYSYSTEMTRAY_H_ +#pragma once #ifndef QT_NO_SYSTEMTRAYICON -#ifdef HAVE_KDE -# include -#else -# include -#endif +# include +# include -#include +# include "systemtray.h" -#include "systemtray.h" - -class LegacySystemTray : public SystemTray { - Q_OBJECT +class LegacySystemTray : public SystemTray +{ + Q_OBJECT public: - explicit LegacySystemTray(QWidget *parent); - virtual ~LegacySystemTray() {} - virtual void init(); + explicit LegacySystemTray(QWidget* parent); - virtual bool isVisible() const; - virtual inline bool isSystemTrayAvailable() const; - virtual Icon stateIcon() const; // overriden to care about blinkState + bool isSystemTrayAvailable() const override; public slots: - virtual void setState(State state); - virtual void setVisible(bool visible = true); - virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000); - -protected slots: - -protected: - virtual void setMode(Mode mode); + void showMessage(const QString& title, + const QString& message, + MessageIcon icon = Information, + int msTimeout = 10000, + uint notificationId = 0) override; + void closeMessage(uint notificationId) override; private slots: - void on_blinkTimeout(); - void on_activated(QSystemTrayIcon::ActivationReason); + void onModeChanged(Mode mode); + void onVisibilityChanged(bool isVisible); -private: - void syncLegacyIcon(); + void onActivated(QSystemTrayIcon::ActivationReason); + void onMessageClicked(); - QTimer _blinkTimer; - bool _blinkState; - bool _isVisible; + void updateIcon(); + void updateToolTip(); -#ifdef HAVE_KDE - KSystemTrayIcon *_trayIcon; -#else - QSystemTrayIcon *_trayIcon; -#endif +private: + uint _lastMessageId{0}; + QSystemTrayIcon* _trayIcon; }; -// inlines - -bool LegacySystemTray::isSystemTrayAvailable() const { return QSystemTrayIcon::isSystemTrayAvailable(); } - #endif /* QT_NO_SYSTEMTRAYICON */ - -#endif /* LEGACYSYSTEMTRAY_H_ */