X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsystemtray.h;h=b2b0afba7bc3e957faddb05b480242bbeb3ea7fc;hp=d98bf46eb96387cc50017f38387cbad4000f9b90;hb=e7d1bc1fa02e1233f140e4b04d99ab8f4685bce5;hpb=e543fd403c4315d8569ea09d868b6fface37b207 diff --git a/src/qtui/systemtray.h b/src/qtui/systemtray.h index d98bf46e..b2b0afba 100644 --- a/src/qtui/systemtray.h +++ b/src/qtui/systemtray.h @@ -1,98 +1,125 @@ /*************************************************************************** -* Copyright (C) 2005-09 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 program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* 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. * -***************************************************************************/ + * Copyright (C) 2005-2010 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 program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * 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. * + ***************************************************************************/ #ifndef SYSTEMTRAY_H_ #define SYSTEMTRAY_H_ -#ifdef HAVE_KDE -# include -#else -# include -#endif - -#include - #include "icon.h" +class QMenu; + class SystemTray : public QObject { Q_OBJECT public: enum State { - Inactive, - Active + Passive, + Active, + NeedsAttention + }; + + enum Mode { + Invalid, + Legacy, + StatusNotifier + }; + + // same as in QSystemTrayIcon + enum MessageIcon { + NoIcon, + Information, + Warning, + Critical + }; + + // same as in QSystemTrayIcon + enum ActivationReason { + Unknown, + Context, + DoubleClick, + Trigger, + MiddleClick }; SystemTray(QObject *parent = 0); - ~SystemTray(); + virtual ~SystemTray(); + virtual void init() {} - inline bool isSystemTrayAvailable() const; + inline State state() const; inline bool isAlerted() const; + virtual inline bool isSystemTrayAvailable() const; + void setAlert(bool alerted); inline void setInhibitActivation(); + inline bool isActivationInhibited() const; public slots: - void setState(State); - void setAlert(bool alert = true); - void setIconVisible(bool visible = true); - void setToolTip(const QString &tip); - void showMessage(const QString &title, const QString &message, - QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int millisecondsTimeoutHint = 10000); + virtual void setState(State); + virtual void setVisible(bool visible = true); + virtual void setToolTip(const QString &title, const QString &subtitle); + virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000); signals: - void activated(QSystemTrayIcon::ActivationReason); + void activated(SystemTray::ActivationReason); void iconChanged(const Icon &); + void toolTipChanged(const QString &title, const QString &subtitle); void messageClicked(); protected: - bool eventFilter(QObject *obj, QEvent *event); + virtual void setMode(Mode mode); + inline Mode mode() const; -private slots: - void nextPhase(); - void on_activated(QSystemTrayIcon::ActivationReason); + virtual Icon stateIcon() const; + Icon stateIcon(State state) const; + inline QString toolTipTitle() const; + inline QString toolTipSubTitle() const; + inline QMenu *trayMenu() const; + void setTrayMenu(QMenu *); -private: - void loadAnimations(); + virtual bool eventFilter(QObject *obj, QEvent *event); -#ifdef HAVE_KDE - KSystemTrayIcon *_trayIcon; -#else - QSystemTrayIcon *_trayIcon; -#endif +private slots: - QMenu *_trayMenu; +private: + Mode _mode; State _state; - bool _alert; + bool _inhibitActivation; - int _idxOffStart, _idxOffEnd, _idxOnStart, _idxOnEnd, _idxAlertStart; - int _currentIdx; - QTimer _animationTimer; + QString _toolTipTitle, _toolTipSubTitle; + Icon _passiveIcon, _activeIcon, _needsAttentionIcon; - QList _phases; + QMenu *_trayMenu; }; // inlines -bool SystemTray::isSystemTrayAvailable() const { return QSystemTrayIcon::isSystemTrayAvailable(); } -bool SystemTray::isAlerted() const { return _alert; } +bool SystemTray::isSystemTrayAvailable() const { return false; } +bool SystemTray::isAlerted() const { return state() == NeedsAttention; } void SystemTray::setInhibitActivation() { _inhibitActivation = true; } +bool SystemTray::isActivationInhibited() const { return _inhibitActivation; } +SystemTray::Mode SystemTray::mode() const { return _mode; } +SystemTray::State SystemTray::state() const { return _state; } +QMenu *SystemTray::trayMenu() const { return _trayMenu; } +QString SystemTray::toolTipTitle() const { return _toolTipTitle; } +QString SystemTray::toolTipSubTitle() const { return _toolTipSubTitle; } + #endif