9#include <QtCore/qloggingcategory.h>
10#include <QtGui/qpa/qplatformtheme.h>
11#include <QtGui/private/qguiapplication_p.h>
13#include "widgets/qwidgetplatform_p.h"
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
112
113
114
115
116
117
118
119
120
121
122
123
124
127
128
129
130
131
132
134Q_STATIC_LOGGING_CATEGORY(qtLabsPlatformTray,
"qt.labs.platform.tray")
136QQuickLabsPlatformSystemTrayIcon::QQuickLabsPlatformSystemTrayIcon(QObject *parent)
141 m_iconLoader(
nullptr),
144 m_handle = QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon();
146 m_handle = QWidgetPlatform::createSystemTrayIcon(
this);
147 qCDebug(qtLabsPlatformTray) <<
"SystemTrayIcon ->" << m_handle;
150 connect(m_handle, &QPlatformSystemTrayIcon::activated,
this, &QQuickLabsPlatformSystemTrayIcon::activated);
151 connect(m_handle, &QPlatformSystemTrayIcon::messageClicked,
this, &QQuickLabsPlatformSystemTrayIcon::messageClicked);
158 m_menu->setSystemTrayIcon(
nullptr);
161 m_iconLoader =
nullptr;
172
173
174
175
176
179 return m_handle && m_handle->isSystemTrayAvailable();
183
184
185
186
187
188
189
192 return m_handle && m_handle->supportsMessages();
196
197
198
199
200
201
209 if (m_visible == visible)
212 if (m_handle && m_complete) {
220 emit visibleChanged();
224
225
226
227
235 if (m_tooltip == tooltip)
238 if (m_handle && m_complete)
239 m_handle->updateToolTip(tooltip);
242 emit tooltipChanged();
246
247
248
249
261 m_menu->setSystemTrayIcon(
nullptr);
264 menu->setSystemTrayIcon(
this);
266 if (m_handle && m_complete) {
267 if (menu && menu->create())
268 m_handle->updateMenu(menu->handle());
270 m_handle->updateMenu(
nullptr);
278
279
280
281
282
285 return m_handle ? m_handle->geometry() : QRect();
289
290
291
292
293
294
295
296
297
298
299
300
301
302
321
322
323
324
331
332
333
334
341
342
343
344
345
346
347
348
349
350
351
355 m_handle->showMessage(title, msg, QIcon(), icon, msecs);
364 if (m_menu && m_menu->create())
365 m_handle->updateMenu(m_menu->handle());
366 m_handle->updateToolTip(m_tooltip);
394 static int slot = staticMetaObject.indexOfSlot(
"updateIcon()");
395 m_iconLoader =
new QQuickLabsPlatformIconLoader(slot, that);
403 if (!m_handle || !m_iconLoader)
406 const QRect oldGeometry = m_handle->geometry();
408 m_handle->updateIcon(m_iconLoader->toQIcon());
410 if (oldGeometry != m_handle->geometry())
411 emit geometryChanged();
416#include "moc_qquicklabsplatformsystemtrayicon_p.cpp"