1 /***************************************************************************
2 * Copyright (C) 2005-2010 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
29 class SystemTray : public QObject {
31 Q_ENUMS(State Mode MessageIcon ActivationReason)
46 // same as in QSystemTrayIcon
54 // same as in QSystemTrayIcon
55 enum ActivationReason {
63 explicit SystemTray(QWidget *parent);
64 virtual ~SystemTray();
67 inline State state() const;
68 inline bool isAlerted() const;
69 virtual inline bool isSystemTrayAvailable() const;
71 void setAlert(bool alerted);
72 virtual inline bool isVisible() const { return false; }
74 QWidget *associatedWidget() const;
77 virtual void setState(State);
78 virtual void setVisible(bool visible = true);
79 virtual void setToolTip(const QString &title, const QString &subtitle);
80 virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int msTimeout = 10000, uint notificationId = 0);
81 virtual void closeMessage(uint notificationId) { Q_UNUSED(notificationId) }
84 void activated(SystemTray::ActivationReason);
85 void iconChanged(const Icon &);
86 void animationEnabledChanged(bool);
87 void toolTipChanged(const QString &title, const QString &subtitle);
88 void messageClicked(uint notificationId);
89 void messageClosed(uint notificationId);
92 virtual void activate(SystemTray::ActivationReason = Trigger);
95 virtual void setMode(Mode mode);
96 inline Mode mode() const;
98 virtual Icon stateIcon() const;
99 Icon stateIcon(State state) const;
100 inline QString toolTipTitle() const;
101 inline QString toolTipSubTitle() const;
102 inline QMenu *trayMenu() const;
104 inline bool animationEnabled() const;
107 void minimizeRestore();
108 void trayMenuAboutToShow();
109 void enableAnimationChanged(const QVariant &);
115 QString _toolTipTitle, _toolTipSubTitle;
116 Icon _passiveIcon, _activeIcon, _needsAttentionIcon;
117 bool _animationEnabled;
120 QWidget *_associatedWidget;
121 Action *_minimizeRestoreAction;
126 bool SystemTray::isSystemTrayAvailable() const { return false; }
127 bool SystemTray::isAlerted() const { return state() == NeedsAttention; }
128 SystemTray::Mode SystemTray::mode() const { return _mode; }
129 SystemTray::State SystemTray::state() const { return _state; }
130 QMenu *SystemTray::trayMenu() const { return _trayMenu; }
131 QString SystemTray::toolTipTitle() const { return _toolTipTitle; }
132 QString SystemTray::toolTipSubTitle() const { return _toolTipSubTitle; }
133 bool SystemTray::animationEnabled() const { return _animationEnabled; }