Fixing backlog timestamps when merging from sqlite.
[quassel.git] / src / qtui / systemtray.h
1 /***************************************************************************
2 *   Copyright (C) 2005-09 by the Quassel Project                          *
3 *   devel@quassel-irc.org                                                 *
4 *                                                                         *
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.                                           *
9 *                                                                         *
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.                          *
14 *                                                                         *
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 ***************************************************************************/
20
21 #ifndef SYSTEMTRAY_H_
22 #define SYSTEMTRAY_H_
23
24 #include <QSystemTrayIcon>
25 #include <QTimer>
26
27 #include "icon.h"
28
29 class SystemTray : public QObject {
30   Q_OBJECT
31
32 public:
33   enum State {
34     Inactive,
35     Active
36   };
37
38   SystemTray(QObject *parent = 0);
39   ~SystemTray();
40
41   inline bool isSystemTrayAvailable() const;
42   Icon icon() const;
43   QString toolTip() const;
44
45 public slots:
46   void setState(State);
47   void setAlert(bool alert = true);
48   void setIconVisible(bool visible = true);
49   void setToolTip(const QString &tip);
50   void showMessage(const QString &title, const QString &message,
51                    QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int millisecondsTimeoutHint = 10000);
52
53
54 signals:
55   void activated(QSystemTrayIcon::ActivationReason);
56   void iconChanged(const Icon &);
57   void messageClicked();
58
59 private slots:
60   void nextPhase();
61
62 private:
63   void loadAnimations();
64
65   QSystemTrayIcon *_trayIcon;
66   QMenu *_trayMenu;
67   State _state;
68   bool _alert;
69
70   int _idxOffStart, _idxOffEnd, _idxOnStart, _idxOnEnd, _idxAlertStart;
71   int _currentIdx;
72   QTimer _animationTimer;
73
74   QList<QPixmap> _phases;
75 };
76
77 // inlines
78
79 bool SystemTray::isSystemTrayAvailable() const { return QSystemTrayIcon::isSystemTrayAvailable(); }
80
81 #endif