author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 11:15:19 +0300 | |
branch | RCL_3 |
changeset 11 | 25a739ee40f4 |
parent 7 | 3f74d0d4af4c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtGui module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QSYSTEMTRAYICON_P_H |
|
43 |
#define QSYSTEMTRAYICON_P_H |
|
44 |
||
45 |
// |
|
46 |
// W A R N I N G |
|
47 |
// ------------- |
|
48 |
// |
|
49 |
// This file is not part of the Qt API. It exists for the convenience |
|
50 |
// of a number of Qt sources files. This header file may change from |
|
51 |
// version to version without notice, or even be removed. |
|
52 |
// |
|
53 |
// We mean it. |
|
54 |
// |
|
55 |
||
56 |
#include "qsystemtrayicon.h" |
|
57 |
#include "private/qobject_p.h" |
|
58 |
||
59 |
#ifndef QT_NO_SYSTEMTRAYICON |
|
60 |
||
61 |
#include "QtGui/qmenu.h" |
|
62 |
#include "QtGui/qpixmap.h" |
|
63 |
#include "QtCore/qstring.h" |
|
64 |
#include "QtCore/qpointer.h" |
|
65 |
||
66 |
QT_BEGIN_NAMESPACE |
|
67 |
||
68 |
class QSystemTrayIconSys; |
|
69 |
class QToolButton; |
|
70 |
class QLabel; |
|
71 |
||
72 |
class QSystemTrayIconPrivate : public QObjectPrivate |
|
73 |
{ |
|
74 |
Q_DECLARE_PUBLIC(QSystemTrayIcon) |
|
75 |
||
76 |
public: |
|
77 |
QSystemTrayIconPrivate() : sys(0), visible(false) { } |
|
78 |
||
79 |
void install_sys(); |
|
80 |
void remove_sys(); |
|
81 |
void updateIcon_sys(); |
|
82 |
void updateToolTip_sys(); |
|
83 |
void updateMenu_sys(); |
|
84 |
QRect geometry_sys() const; |
|
85 |
void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs); |
|
86 |
static bool isSystemTrayAvailable_sys(); |
|
87 |
||
88 |
QPointer<QMenu> menu; |
|
89 |
QIcon icon; |
|
90 |
QString toolTip; |
|
91 |
QSystemTrayIconSys *sys; |
|
92 |
bool visible; |
|
93 |
}; |
|
94 |
||
95 |
class QBalloonTip : public QWidget |
|
96 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
97 |
Q_OBJECT |
0 | 98 |
public: |
99 |
static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title, |
|
100 |
const QString& msg, QSystemTrayIcon *trayIcon, |
|
101 |
const QPoint& pos, int timeout, bool showArrow = true); |
|
102 |
static void hideBalloon(); |
|
103 |
static bool isBalloonVisible(); |
|
104 |
||
105 |
private: |
|
106 |
QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, |
|
107 |
const QString& msg, QSystemTrayIcon *trayIcon); |
|
108 |
~QBalloonTip(); |
|
109 |
void balloon(const QPoint&, int, bool); |
|
110 |
||
111 |
protected: |
|
112 |
void paintEvent(QPaintEvent *); |
|
113 |
void resizeEvent(QResizeEvent *); |
|
114 |
void mousePressEvent(QMouseEvent *e); |
|
115 |
void timerEvent(QTimerEvent *e); |
|
116 |
||
117 |
private: |
|
118 |
QSystemTrayIcon *trayIcon; |
|
119 |
QPixmap pixmap; |
|
120 |
int timerId; |
|
121 |
}; |
|
122 |
||
123 |
#if defined(Q_WS_X11) |
|
124 |
QT_BEGIN_INCLUDE_NAMESPACE |
|
125 |
#include <QtCore/qcoreapplication.h> |
|
126 |
#include <X11/Xlib.h> |
|
127 |
#include <X11/Xatom.h> |
|
128 |
#include <X11/Xutil.h> |
|
129 |
QT_END_INCLUDE_NAMESPACE |
|
130 |
||
131 |
class QSystemTrayIconSys : public QWidget |
|
132 |
{ |
|
133 |
friend class QSystemTrayIconPrivate; |
|
134 |
||
135 |
public: |
|
136 |
QSystemTrayIconSys(QSystemTrayIcon *q); |
|
137 |
~QSystemTrayIconSys(); |
|
138 |
enum { |
|
139 |
SYSTEM_TRAY_REQUEST_DOCK = 0, |
|
140 |
SYSTEM_TRAY_BEGIN_MESSAGE = 1, |
|
141 |
SYSTEM_TRAY_CANCEL_MESSAGE =2 |
|
142 |
}; |
|
143 |
||
144 |
void addToTray(); |
|
145 |
void updateIcon(); |
|
146 |
XVisualInfo* getSysTrayVisualInfo(); |
|
147 |
||
148 |
// QObject::event is public but QWidget's ::event() re-implementation |
|
149 |
// is protected ;( |
|
150 |
inline bool deliverToolTipEvent(QEvent *e) |
|
151 |
{ return QWidget::event(e); } |
|
152 |
||
153 |
static Window sysTrayWindow; |
|
154 |
static QList<QSystemTrayIconSys *> trayIcons; |
|
155 |
static QCoreApplication::EventFilter oldEventFilter; |
|
156 |
static bool sysTrayTracker(void *message, long *result); |
|
157 |
static Window locateSystemTray(); |
|
158 |
static Atom sysTraySelection; |
|
159 |
static XVisualInfo sysTrayVisual; |
|
160 |
||
161 |
protected: |
|
162 |
void paintEvent(QPaintEvent *pe); |
|
163 |
void resizeEvent(QResizeEvent *re); |
|
164 |
bool x11Event(XEvent *event); |
|
165 |
void mousePressEvent(QMouseEvent *event); |
|
166 |
void mouseDoubleClickEvent(QMouseEvent *event); |
|
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
167 |
#ifndef QT_NO_WHEELEVENT |
0 | 168 |
void wheelEvent(QWheelEvent *event); |
7
3f74d0d4af4c
qt:70947f0f93d948bc89b3b43d00da758a51f1ef84
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
4
diff
changeset
|
169 |
#endif |
0 | 170 |
bool event(QEvent *e); |
171 |
||
172 |
private: |
|
173 |
QPixmap background; |
|
174 |
QSystemTrayIcon *q; |
|
175 |
Colormap colormap; |
|
176 |
}; |
|
177 |
#endif // Q_WS_X11 |
|
178 |
||
179 |
QT_END_NAMESPACE |
|
180 |
||
181 |
#endif // QT_NO_SYSTEMTRAYICON |
|
182 |
||
183 |
#endif // QSYSTEMTRAYICON_P_H |
|
184 |