qsystemtrayicon_x11.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qsystemtrayicon_x11.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static inline unsigned long locateSystemTray()-
6{-
7 return
never executed: return (unsigned long)QGuiApplication::platformNativeInterface()->nativeResourceForScreen(([]() -> QByteArray { enum { Size = sizeof("traywindow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "traywindow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()), QGuiApplication::primaryScreen());
(unsigned long)QGuiApplication::platformNativeInterface()->nativeResourceForScreen(([]() -> QByteArray { enum { Size = sizeof("traywindow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "traywindow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()), QGuiApplication::primaryScreen());
never executed: return (unsigned long)QGuiApplication::platformNativeInterface()->nativeResourceForScreen(([]() -> QByteArray { enum { Size = sizeof("traywindow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "traywindow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()), QGuiApplication::primaryScreen());
0
8}-
9-
10-
11-
12class QSystemTrayIconSys : public QWidget-
13{-
14 public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }-
15#pragma GCC diagnostic push-
16 static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);-
17#pragma GCC diagnostic pop-
18 struct QPrivateSignal {};-
19public:-
20 explicit QSystemTrayIconSys(QSystemTrayIcon *q);-
21-
22 inline void updateIcon() { update(); }
never executed: end of block
0
23 inline QSystemTrayIcon *systemTrayIcon() const { return
never executed: return q;
q;
never executed: return q;
}
0
24-
25 QRect globalGeometry() const;-
26-
27protected:-
28 virtual void mousePressEvent(QMouseEvent *ev) override;-
29 virtual void mouseDoubleClickEvent(QMouseEvent *ev) override;-
30 virtual bool event(QEvent *) override;-
31 virtual void paintEvent(QPaintEvent *) override;-
32 virtual void resizeEvent(QResizeEvent *) override;-
33 virtual void moveEvent(QMoveEvent *) override;-
34-
35private :-
36 void systemTrayWindowChanged(QScreen *screen);-
37-
38private:-
39 bool addToTray();-
40-
41 QSystemTrayIcon *q;-
42 QPixmap background;-
43};-
44-
45QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn)-
46 : QWidget(0, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint)-
47 , q(qIn)-
48{-
49 setObjectName(([]() -> QString { enum { Size = sizeof(u"" "QSystemTrayIconSys")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QSystemTrayIconSys" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()));
0
50 setToolTip(q->toolTip());-
51 setAttribute(Qt::WA_AlwaysShowToolTips, true);-
52 setAttribute(Qt::WA_QuitOnClose, false);-
53 const QSize size(22, 22);-
54 setGeometry(QRect(QPoint(0, 0), size));-
55 setMinimumSize(size);-
56 bool hasAlphaChannel = QXcbIntegrationFunctions::xEmbedSystemTrayVisualHasAlphaChannel();-
57 setAttribute(Qt::WA_TranslucentBackground, hasAlphaChannel);-
58 if (!hasAlphaChannel
!hasAlphaChannelDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
59 createWinId();-
60 QXcbWindowFunctions::setParentRelativeBackPixmap(windowHandle());-
61-
62-
63-
64-
65-
66-
67-
68 }
never executed: end of block
0
69-
70 addToTray();-
71}
never executed: end of block
0
72-
73bool QSystemTrayIconSys::addToTray()-
74{-
75 if (!locateSystemTray()
!locateSystemTray()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
76 return
never executed: return false;
false;
never executed: return false;
0
77-
78 createWinId();-
79 setMouseTracking(true);-
80-
81 if (!QXcbWindowFunctions::requestSystemTrayWindowDock(windowHandle())
!QXcbWindowFun...indowHandle())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
82 return
never executed: return false;
false;
never executed: return false;
0
83-
84 if (!background.isNull()
!background.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
85 background = QPixmap();
never executed: background = QPixmap();
0
86 show();-
87 return
never executed: return true;
true;
never executed: return true;
0
88}-
89-
90void QSystemTrayIconSys::systemTrayWindowChanged(QScreen *)-
91{-
92 if (locateSystemTray()
locateSystemTray()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
93 addToTray();-
94 }
never executed: end of block
else {
0
95 QBalloonTip::hideBalloon();-
96 hide();-
97 destroy();-
98 }
never executed: end of block
0
99}-
100-
101QRect QSystemTrayIconSys::globalGeometry() const-
102{-
103 return
never executed: return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle());
QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle());
never executed: return QXcbWindowFunctions::systemTrayWindowGlobalGeometry(windowHandle());
0
104}-
105-
106void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)-
107{-
108 QPoint globalPos = ev->globalPos();-
109-
110 if (ev->button() == Qt::RightButton
ev->button() =...t::RightButtonDescription
TRUEnever evaluated
FALSEnever evaluated
&& q->contextMenu()
q->contextMenu()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
111 q->contextMenu()->popup(globalPos);
never executed: q->contextMenu()->popup(globalPos);
0
112-
113-
114-
115-
116 if (QBalloonTip::isBalloonVisible()
QBalloonTip::i...lloonVisible()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
117 q->messageClicked();-
118 QBalloonTip::hideBalloon();-
119 }
never executed: end of block
0
120-
121 if (ev->button() == Qt::LeftButton
ev->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
122 q->activated(QSystemTrayIcon::Trigger);
never executed: q->activated(QSystemTrayIcon::Trigger);
0
123 else if (ev->button() == Qt::RightButton
ev->button() =...t::RightButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
124 q->activated(QSystemTrayIcon::Context);
never executed: q->activated(QSystemTrayIcon::Context);
0
125 else if (ev->button() == Qt::MidButton
ev->button() == Qt::MidButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
126 q->activated(QSystemTrayIcon::MiddleClick);
never executed: q->activated(QSystemTrayIcon::MiddleClick);
0
127}
never executed: end of block
0
128-
129void QSystemTrayIconSys::mouseDoubleClickEvent(QMouseEvent *ev)-
130{-
131 if (ev->button() == Qt::LeftButton
ev->button() == Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
132 q->activated(QSystemTrayIcon::DoubleClick);
never executed: q->activated(QSystemTrayIcon::DoubleClick);
0
133}
never executed: end of block
0
134-
135bool QSystemTrayIconSys::event(QEvent *e)-
136{-
137 switch (e->type()) {-
138 case
never executed: case QEvent::ToolTip:
QEvent::ToolTip:
never executed: case QEvent::ToolTip:
0
139 QApplication::sendEvent(q, e);-
140 break;
never executed: break;
0
141-
142 case
never executed: case QEvent::Wheel:
QEvent::Wheel:
never executed: case QEvent::Wheel:
0
143 return
never executed: return QApplication::sendEvent(q, e);
QApplication::sendEvent(q, e);
never executed: return QApplication::sendEvent(q, e);
0
144-
145 default
never executed: default:
:
never executed: default:
0
146 break;
never executed: break;
0
147 }-
148 return
never executed: return QWidget::event(e);
QWidget::event(e);
never executed: return QWidget::event(e);
0
149}-
150-
151void QSystemTrayIconSys::paintEvent(QPaintEvent *)-
152{-
153 const QRect rect(QPoint(0, 0), geometry().size());-
154 QPainter painter(this);-
155-
156-
157-
158 if (testAttribute(Qt::WA_TranslucentBackground)
testAttribute(...entBackground)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
159 painter.setCompositionMode(QPainter::CompositionMode_Source);-
160 painter.fillRect(rect, Qt::transparent);-
161 }
never executed: end of block
else {
0
162-
163-
164 if (background.isNull()
background.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
165 background = QGuiApplication::primaryScreen()->grabWindow(winId(),-
166 0, 0, rect.size().width(), rect.size().height());-
167 }
never executed: end of block
0
168-
169 painter.drawPixmap(QPoint(0, 0), background);-
170 }
never executed: end of block
0
171 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);-
172 q->icon().paint(&painter, rect);-
173}
never executed: end of block
0
174-
175void QSystemTrayIconSys::moveEvent(QMoveEvent *event)-
176{-
177 QWidget::moveEvent(event);-
178 if (QBalloonTip::isBalloonVisible()
QBalloonTip::i...lloonVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
179 QBalloonTip::updateBalloonPosition(globalGeometry().center());
never executed: QBalloonTip::updateBalloonPosition(globalGeometry().center());
0
180}
never executed: end of block
0
181-
182void QSystemTrayIconSys::resizeEvent(QResizeEvent *event)-
183{-
184 update();-
185 QWidget::resizeEvent(event);-
186 if (QBalloonTip::isBalloonVisible()
QBalloonTip::i...lloonVisible()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
187 QBalloonTip::updateBalloonPosition(globalGeometry().center());
never executed: QBalloonTip::updateBalloonPosition(globalGeometry().center());
0
188}
never executed: end of block
0
189-
190-
191QSystemTrayIconPrivate::QSystemTrayIconPrivate()-
192 : sys(0),-
193 qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon()),-
194 visible(false)-
195{-
196}
never executed: end of block
0
197-
198QSystemTrayIconPrivate::~QSystemTrayIconPrivate()-
199{-
200 delete qpa_sys;-
201}
never executed: end of block
0
202-
203void QSystemTrayIconPrivate::install_sys()-
204{-
205 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
206 install_sys_qpa();-
207 return;
never executed: return;
0
208 }-
209 QSystemTrayIcon * const q = q_func();-
210 if (!sys
!sysDescription
TRUEnever evaluated
FALSEnever evaluated
&& locateSystemTray()
locateSystemTray()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
211 sys = new QSystemTrayIconSys(q);-
212 QObject::connect(QGuiApplication::platformNativeInterface(), qFlagLocation("2""systemTrayWindowChanged(QScreen*)" "\0" __FILE__ ":" "279"),-
213 sys, qFlagLocation("1""systemTrayWindowChanged(QScreen*)" "\0" __FILE__ ":" "280"));-
214 }
never executed: end of block
0
215}
never executed: end of block
0
216-
217QRect QSystemTrayIconPrivate::geometry_sys() const-
218{-
219 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
220 return
never executed: return geometry_sys_qpa();
geometry_sys_qpa();
never executed: return geometry_sys_qpa();
0
221 if (!sys
!sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
222 return
never executed: return QRect();
QRect();
never executed: return QRect();
0
223 return
never executed: return sys->globalGeometry();
sys->globalGeometry();
never executed: return sys->globalGeometry();
0
224}-
225-
226void QSystemTrayIconPrivate::remove_sys()-
227{-
228 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
229 remove_sys_qpa();-
230 return;
never executed: return;
0
231 }-
232 if (!sys
!sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
233 return;
never executed: return;
0
234 QBalloonTip::hideBalloon();-
235 sys->hide();-
236 delete sys;-
237 sys = 0;-
238}
never executed: end of block
0
239-
240void QSystemTrayIconPrivate::updateIcon_sys()-
241{-
242 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
243 updateIcon_sys_qpa();-
244 return;
never executed: return;
0
245 }-
246 if (sys
sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
247 sys->updateIcon();
never executed: sys->updateIcon();
0
248}
never executed: end of block
0
249-
250void QSystemTrayIconPrivate::updateMenu_sys()-
251{-
252 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
253 updateMenu_sys_qpa();
never executed: updateMenu_sys_qpa();
0
254}
never executed: end of block
0
255-
256void QSystemTrayIconPrivate::updateToolTip_sys()-
257{-
258 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
259 updateToolTip_sys_qpa();-
260 return;
never executed: return;
0
261 }-
262 if (!sys
!sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
263 return;
never executed: return;
0
264-
265 sys->setToolTip(toolTip);-
266-
267}
never executed: end of block
0
268-
269bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()-
270{-
271 QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());-
272 if (sys
sysDescription
TRUEnever evaluated
FALSEnever evaluated
&& sys->isSystemTrayAvailable()
sys->isSystemTrayAvailable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
273 return
never executed: return true;
true;
never executed: return true;
0
274-
275-
276 const QString platform = QGuiApplication::platformName();-
277 if (platform.compare(QLatin1String("xcb"), Qt::CaseInsensitive) == 0
platform.compa...ensitive) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
278 return
never executed: return locateSystemTray();
locateSystemTray();
never executed: return locateSystemTray();
0
279 return
never executed: return false;
false;
never executed: return false;
0
280}-
281-
282bool QSystemTrayIconPrivate::supportsMessages_sys()-
283{-
284 QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());-
285 if (sys
sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
286 return
never executed: return sys->supportsMessages();
sys->supportsMessages();
never executed: return sys->supportsMessages();
0
287-
288-
289 return
never executed: return true;
true;
never executed: return true;
0
290}-
291-
292void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message,-
293 QSystemTrayIcon::MessageIcon icon, int msecs)-
294{-
295 if (qpa_sys
qpa_sysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
296 showMessage_sys_qpa(title, message, icon, msecs);-
297 return;
never executed: return;
0
298 }-
299 if (!sys
!sysDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
300 return;
never executed: return;
0
301 QBalloonTip::showBalloon(icon, title, message, sys->systemTrayIcon(),-
302 sys->globalGeometry().center(),-
303 msecs);-
304}
never executed: end of block
0
305-
306-
307-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9