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 ***************************************************************************/
32 class SystemTray : public QObject {
34 Q_ENUMS(State Mode MessageIcon ActivationReason)
49 // same as in QSystemTrayIcon
57 // same as in QSystemTrayIcon
58 enum ActivationReason {
66 explicit SystemTray(QWidget *parent);
67 virtual ~SystemTray();
68 virtual void init() {}
70 inline State state() const;
71 inline bool isAlerted() const;
72 virtual inline bool isSystemTrayAvailable() const;
74 void setAlert(bool alerted);
75 inline void setInhibitActivation();
76 inline virtual bool isVisible() const { return false; }
77 inline bool isActivationInhibited() const;
79 QWidget *associatedWidget() const;
82 virtual void setState(State);
83 virtual void setVisible(bool visible = true);
84 virtual void setToolTip(const QString &title, const QString &subtitle);
85 virtual void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000);
86 void toggleMainWidget();
87 void hideMainWidget();
90 void activated(SystemTray::ActivationReason);
91 void iconChanged(const Icon &);
92 void toolTipChanged(const QString &title, const QString &subtitle);
93 void messageClicked();
96 virtual void activate(SystemTray::ActivationReason = Trigger);
98 void minimizeRestore(bool restore);
101 virtual void setMode(Mode mode);
102 inline Mode mode() const;
104 virtual Icon stateIcon() const;
105 Icon stateIcon(State state) const;
106 inline QString toolTipTitle() const;
107 inline QString toolTipSubTitle() const;
108 inline QMenu *trayMenu() const;
109 void setTrayMenu(QMenu *);
111 virtual bool eventFilter(QObject *obj, QEvent *event);
116 bool checkVisibility(bool performToggle = true);
121 bool _inhibitActivation;
123 QString _toolTipTitle, _toolTipSubTitle;
124 Icon _passiveIcon, _activeIcon, _needsAttentionIcon;
127 QWidget *_associatedWidget;
137 bool SystemTray::isSystemTrayAvailable() const { return false; }
138 bool SystemTray::isAlerted() const { return state() == NeedsAttention; }
139 void SystemTray::setInhibitActivation() { _inhibitActivation = true; }
140 bool SystemTray::isActivationInhibited() const { return _inhibitActivation; }
141 SystemTray::Mode SystemTray::mode() const { return _mode; }
142 SystemTray::State SystemTray::state() const { return _state; }
143 QMenu *SystemTray::trayMenu() const { return _trayMenu; }
144 QString SystemTray::toolTipTitle() const { return _toolTipTitle; }
145 QString SystemTray::toolTipSubTitle() const { return _toolTipSubTitle; }