Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/util/qsystemtrayicon.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | QSystemTrayIcon::QSystemTrayIcon(QObject *parent) | - | ||||||||||||
7 | : QObject(*new QSystemTrayIconPrivate(), parent) | - | ||||||||||||
8 | { | - | ||||||||||||
9 | } never executed: end of block | 0 | ||||||||||||
10 | QSystemTrayIcon::QSystemTrayIcon(const QIcon &icon, QObject *parent) | - | ||||||||||||
11 | : QObject(*new QSystemTrayIconPrivate(), parent) | - | ||||||||||||
12 | { | - | ||||||||||||
13 | setIcon(icon); | - | ||||||||||||
14 | } never executed: end of block | 0 | ||||||||||||
15 | - | |||||||||||||
16 | - | |||||||||||||
17 | - | |||||||||||||
18 | - | |||||||||||||
19 | QSystemTrayIcon::~QSystemTrayIcon() | - | ||||||||||||
20 | { | - | ||||||||||||
21 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
22 | d->remove_sys(); | - | ||||||||||||
23 | } never executed: end of block | 0 | ||||||||||||
24 | void QSystemTrayIcon::setContextMenu(QMenu *menu) | - | ||||||||||||
25 | { | - | ||||||||||||
26 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
27 | d->menu = menu; | - | ||||||||||||
28 | d->updateMenu_sys(); | - | ||||||||||||
29 | } never executed: end of block | 0 | ||||||||||||
30 | - | |||||||||||||
31 | - | |||||||||||||
32 | - | |||||||||||||
33 | - | |||||||||||||
34 | QMenu* QSystemTrayIcon::contextMenu() const | - | ||||||||||||
35 | { | - | ||||||||||||
36 | const QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
37 | return never executed: d->menu;return d->menu; never executed: return d->menu; | 0 | ||||||||||||
38 | } | - | ||||||||||||
39 | void QSystemTrayIcon::setIcon(const QIcon &icon) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
42 | d->icon = icon; | - | ||||||||||||
43 | d->updateIcon_sys(); | - | ||||||||||||
44 | } never executed: end of block | 0 | ||||||||||||
45 | - | |||||||||||||
46 | QIcon QSystemTrayIcon::icon() const | - | ||||||||||||
47 | { | - | ||||||||||||
48 | const QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
49 | return never executed: d->icon;return d->icon; never executed: return d->icon; | 0 | ||||||||||||
50 | } | - | ||||||||||||
51 | void QSystemTrayIcon::setToolTip(const QString &tooltip) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
54 | d->toolTip = tooltip; | - | ||||||||||||
55 | d->updateToolTip_sys(); | - | ||||||||||||
56 | } never executed: end of block | 0 | ||||||||||||
57 | - | |||||||||||||
58 | QString QSystemTrayIcon::toolTip() const | - | ||||||||||||
59 | { | - | ||||||||||||
60 | const QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
61 | return never executed: d->toolTip;return d->toolTip; never executed: return d->toolTip; | 0 | ||||||||||||
62 | } | - | ||||||||||||
63 | QRect QSystemTrayIcon::geometry() const | - | ||||||||||||
64 | { | - | ||||||||||||
65 | const QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
66 | if (!d->visible
| 0 | ||||||||||||
67 | return never executed: QRect();return QRect(); never executed: return QRect(); | 0 | ||||||||||||
68 | return never executed: d->geometry_sys();return d->geometry_sys(); never executed: return d->geometry_sys(); | 0 | ||||||||||||
69 | } | - | ||||||||||||
70 | void QSystemTrayIcon::setVisible(bool visible) | - | ||||||||||||
71 | { | - | ||||||||||||
72 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
73 | if (visible == d->visible
| 0 | ||||||||||||
74 | return; never executed: return; | 0 | ||||||||||||
75 | if (d->icon.isNull()
| 0 | ||||||||||||
76 | QMessageLogger(__FILE__, 268, __PRETTY_FUNCTION__).warning("QSystemTrayIcon::setVisible: No Icon set"); never executed: QMessageLogger(__FILE__, 268, __PRETTY_FUNCTION__).warning("QSystemTrayIcon::setVisible: No Icon set"); | 0 | ||||||||||||
77 | d->visible = visible; | - | ||||||||||||
78 | if (d->visible
| 0 | ||||||||||||
79 | d->install_sys(); never executed: d->install_sys(); | 0 | ||||||||||||
80 | else | - | ||||||||||||
81 | d->remove_sys(); never executed: d->remove_sys(); | 0 | ||||||||||||
82 | } | - | ||||||||||||
83 | - | |||||||||||||
84 | bool QSystemTrayIcon::isVisible() const | - | ||||||||||||
85 | { | - | ||||||||||||
86 | const QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
87 | return never executed: d->visible;return d->visible; never executed: return d->visible; | 0 | ||||||||||||
88 | } | - | ||||||||||||
89 | - | |||||||||||||
90 | - | |||||||||||||
91 | - | |||||||||||||
92 | - | |||||||||||||
93 | bool QSystemTrayIcon::event(QEvent *e) | - | ||||||||||||
94 | { | - | ||||||||||||
95 | return never executed: QObject::event(e);return QObject::event(e); never executed: return QObject::event(e); | 0 | ||||||||||||
96 | } | - | ||||||||||||
97 | bool QSystemTrayIcon::isSystemTrayAvailable() | - | ||||||||||||
98 | { | - | ||||||||||||
99 | return never executed: QSystemTrayIconPrivate::isSystemTrayAvailable_sys();return QSystemTrayIconPrivate::isSystemTrayAvailable_sys(); never executed: return QSystemTrayIconPrivate::isSystemTrayAvailable_sys(); | 0 | ||||||||||||
100 | } | - | ||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | - | |||||||||||||
105 | - | |||||||||||||
106 | - | |||||||||||||
107 | bool QSystemTrayIcon::supportsMessages() | - | ||||||||||||
108 | { | - | ||||||||||||
109 | return never executed: QSystemTrayIconPrivate::supportsMessages_sys();return QSystemTrayIconPrivate::supportsMessages_sys(); never executed: return QSystemTrayIconPrivate::supportsMessages_sys(); | 0 | ||||||||||||
110 | } | - | ||||||||||||
111 | void QSystemTrayIcon::showMessage(const QString& title, const QString& msg, | - | ||||||||||||
112 | QSystemTrayIcon::MessageIcon icon, int msecs) | - | ||||||||||||
113 | { | - | ||||||||||||
114 | QSystemTrayIconPrivate * const d = d_func(); | - | ||||||||||||
115 | if (d->visible
| 0 | ||||||||||||
116 | d->showMessage_sys(title, msg, icon, msecs); never executed: d->showMessage_sys(title, msg, icon, msecs); | 0 | ||||||||||||
117 | } never executed: end of block | 0 | ||||||||||||
118 | - | |||||||||||||
119 | void QSystemTrayIconPrivate::_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason) | - | ||||||||||||
120 | { | - | ||||||||||||
121 | QSystemTrayIcon * const q = q_func(); | - | ||||||||||||
122 | q->activated(static_cast<QSystemTrayIcon::ActivationReason>(reason)); | - | ||||||||||||
123 | } never executed: end of block | 0 | ||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | static QBalloonTip *theSolitaryBalloonTip = 0; | - | ||||||||||||
127 | - | |||||||||||||
128 | void QBalloonTip::showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title, | - | ||||||||||||
129 | const QString& message, QSystemTrayIcon *trayIcon, | - | ||||||||||||
130 | const QPoint& pos, int timeout, bool showArrow) | - | ||||||||||||
131 | { | - | ||||||||||||
132 | hideBalloon(); | - | ||||||||||||
133 | if (message.isEmpty()
| 0 | ||||||||||||
134 | return; never executed: return; | 0 | ||||||||||||
135 | - | |||||||||||||
136 | theSolitaryBalloonTip = new QBalloonTip(icon, title, message, trayIcon); | - | ||||||||||||
137 | if (timeout < 0
| 0 | ||||||||||||
138 | timeout = 10000; never executed: timeout = 10000; | 0 | ||||||||||||
139 | theSolitaryBalloonTip->balloon(pos, timeout, showArrow); | - | ||||||||||||
140 | } never executed: end of block | 0 | ||||||||||||
141 | - | |||||||||||||
142 | void QBalloonTip::hideBalloon() | - | ||||||||||||
143 | { | - | ||||||||||||
144 | if (!theSolitaryBalloonTip
| 0 | ||||||||||||
145 | return; never executed: return; | 0 | ||||||||||||
146 | theSolitaryBalloonTip->hide(); | - | ||||||||||||
147 | delete theSolitaryBalloonTip; | - | ||||||||||||
148 | theSolitaryBalloonTip = 0; | - | ||||||||||||
149 | } never executed: end of block | 0 | ||||||||||||
150 | - | |||||||||||||
151 | void QBalloonTip::updateBalloonPosition(const QPoint& pos) | - | ||||||||||||
152 | { | - | ||||||||||||
153 | if (!theSolitaryBalloonTip
| 0 | ||||||||||||
154 | return; never executed: return; | 0 | ||||||||||||
155 | theSolitaryBalloonTip->hide(); | - | ||||||||||||
156 | theSolitaryBalloonTip->balloon(pos, 0, theSolitaryBalloonTip->showArrow); | - | ||||||||||||
157 | } never executed: end of block | 0 | ||||||||||||
158 | - | |||||||||||||
159 | bool QBalloonTip::isBalloonVisible() | - | ||||||||||||
160 | { | - | ||||||||||||
161 | return never executed: theSolitaryBalloonTip;return theSolitaryBalloonTip; never executed: return theSolitaryBalloonTip; | 0 | ||||||||||||
162 | } | - | ||||||||||||
163 | - | |||||||||||||
164 | QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title, | - | ||||||||||||
165 | const QString& message, QSystemTrayIcon *ti) | - | ||||||||||||
166 | : QWidget(0, Qt::ToolTip), | - | ||||||||||||
167 | trayIcon(ti), | - | ||||||||||||
168 | timerId(-1), | - | ||||||||||||
169 | showArrow(true) | - | ||||||||||||
170 | { | - | ||||||||||||
171 | setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
172 | QObject::connect(ti, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "439"), this, qFlagLocation("1""close()" "\0" __FILE__ ":" "439")); | - | ||||||||||||
173 | - | |||||||||||||
174 | QLabel *titleLabel = new QLabel; | - | ||||||||||||
175 | titleLabel->installEventFilter(this); | - | ||||||||||||
176 | titleLabel->setText(title); | - | ||||||||||||
177 | QFont f = titleLabel->font(); | - | ||||||||||||
178 | f.setBold(true); | - | ||||||||||||
179 | - | |||||||||||||
180 | - | |||||||||||||
181 | - | |||||||||||||
182 | titleLabel->setFont(f); | - | ||||||||||||
183 | titleLabel->setTextFormat(Qt::PlainText); | - | ||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | - | |||||||||||||
188 | - | |||||||||||||
189 | const int iconSize = 18; | - | ||||||||||||
190 | const int closeButtonSize = 15; | - | ||||||||||||
191 | - | |||||||||||||
192 | - | |||||||||||||
193 | QPushButton *closeButton = new QPushButton; | - | ||||||||||||
194 | closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); | - | ||||||||||||
195 | closeButton->setIconSize(QSize(closeButtonSize, closeButtonSize)); | - | ||||||||||||
196 | closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | - | ||||||||||||
197 | closeButton->setFixedSize(closeButtonSize, closeButtonSize); | - | ||||||||||||
198 | QObject::connect(closeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "465"), this, qFlagLocation("1""close()" "\0" __FILE__ ":" "465")); | - | ||||||||||||
199 | - | |||||||||||||
200 | QLabel *msgLabel = new QLabel; | - | ||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | - | |||||||||||||
205 | msgLabel->installEventFilter(this); | - | ||||||||||||
206 | msgLabel->setText(message); | - | ||||||||||||
207 | msgLabel->setTextFormat(Qt::PlainText); | - | ||||||||||||
208 | msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); | - | ||||||||||||
209 | - | |||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3; | - | ||||||||||||
215 | - | |||||||||||||
216 | if (msgLabel->sizeHint().width() > limit
| 0 | ||||||||||||
217 | msgLabel->setWordWrap(true); | - | ||||||||||||
218 | if (msgLabel->sizeHint().width() > limit
| 0 | ||||||||||||
219 | msgLabel->d_func()->ensureTextControl(); | - | ||||||||||||
220 | if (QWidgetTextControl *control = msgLabel->d_func()->control
| 0 | ||||||||||||
221 | QTextOption opt = control->document()->defaultTextOption(); | - | ||||||||||||
222 | opt.setWrapMode(QTextOption::WrapAnywhere); | - | ||||||||||||
223 | control->document()->setDefaultTextOption(opt); | - | ||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||
226 | - | |||||||||||||
227 | - | |||||||||||||
228 | - | |||||||||||||
229 | - | |||||||||||||
230 | - | |||||||||||||
231 | - | |||||||||||||
232 | - | |||||||||||||
233 | msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit)); | - | ||||||||||||
234 | - | |||||||||||||
235 | } never executed: end of block | 0 | ||||||||||||
236 | - | |||||||||||||
237 | QIcon si; | - | ||||||||||||
238 | switch (icon) { | - | ||||||||||||
239 | case never executed: QSystemTrayIcon::Warning:case QSystemTrayIcon::Warning: never executed: case QSystemTrayIcon::Warning: | 0 | ||||||||||||
240 | si = style()->standardIcon(QStyle::SP_MessageBoxWarning); | - | ||||||||||||
241 | break; never executed: break; | 0 | ||||||||||||
242 | case never executed: QSystemTrayIcon::Critical:case QSystemTrayIcon::Critical: never executed: case QSystemTrayIcon::Critical: | 0 | ||||||||||||
243 | si = style()->standardIcon(QStyle::SP_MessageBoxCritical); | - | ||||||||||||
244 | break; never executed: break; | 0 | ||||||||||||
245 | case never executed: QSystemTrayIcon::Information:case QSystemTrayIcon::Information: never executed: case QSystemTrayIcon::Information: | 0 | ||||||||||||
246 | si = style()->standardIcon(QStyle::SP_MessageBoxInformation); | - | ||||||||||||
247 | break; never executed: break; | 0 | ||||||||||||
248 | case never executed: QSystemTrayIcon::NoIcon:case QSystemTrayIcon::NoIcon: never executed: case QSystemTrayIcon::NoIcon: | 0 | ||||||||||||
249 | default never executed: :default: never executed: default: | 0 | ||||||||||||
250 | break; never executed: break; | 0 | ||||||||||||
251 | } | - | ||||||||||||
252 | - | |||||||||||||
253 | QGridLayout *layout = new QGridLayout; | - | ||||||||||||
254 | if (!si.isNull()
| 0 | ||||||||||||
255 | QLabel *iconLabel = new QLabel; | - | ||||||||||||
256 | iconLabel->setPixmap(si.pixmap(iconSize, iconSize)); | - | ||||||||||||
257 | iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | - | ||||||||||||
258 | iconLabel->setMargin(2); | - | ||||||||||||
259 | layout->addWidget(iconLabel, 0, 0); | - | ||||||||||||
260 | layout->addWidget(titleLabel, 0, 1); | - | ||||||||||||
261 | } never executed: else {end of block | 0 | ||||||||||||
262 | layout->addWidget(titleLabel, 0, 0, 1, 2); | - | ||||||||||||
263 | } never executed: end of block | 0 | ||||||||||||
264 | - | |||||||||||||
265 | layout->addWidget(closeButton, 0, 2); | - | ||||||||||||
266 | layout->addWidget(msgLabel, 1, 0, 1, 3); | - | ||||||||||||
267 | layout->setSizeConstraint(QLayout::SetFixedSize); | - | ||||||||||||
268 | layout->setMargin(3); | - | ||||||||||||
269 | setLayout(layout); | - | ||||||||||||
270 | - | |||||||||||||
271 | QPalette pal = palette(); | - | ||||||||||||
272 | pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1)); | - | ||||||||||||
273 | pal.setColor(QPalette::WindowText, Qt::black); | - | ||||||||||||
274 | setPalette(pal); | - | ||||||||||||
275 | } never executed: end of block | 0 | ||||||||||||
276 | - | |||||||||||||
277 | QBalloonTip::~QBalloonTip() | - | ||||||||||||
278 | { | - | ||||||||||||
279 | theSolitaryBalloonTip = 0; | - | ||||||||||||
280 | } never executed: end of block | 0 | ||||||||||||
281 | - | |||||||||||||
282 | void QBalloonTip::paintEvent(QPaintEvent *) | - | ||||||||||||
283 | { | - | ||||||||||||
284 | QPainter painter(this); | - | ||||||||||||
285 | painter.drawPixmap(rect(), pixmap); | - | ||||||||||||
286 | } never executed: end of block | 0 | ||||||||||||
287 | - | |||||||||||||
288 | void QBalloonTip::resizeEvent(QResizeEvent *ev) | - | ||||||||||||
289 | { | - | ||||||||||||
290 | QWidget::resizeEvent(ev); | - | ||||||||||||
291 | } never executed: end of block | 0 | ||||||||||||
292 | - | |||||||||||||
293 | void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow) | - | ||||||||||||
294 | { | - | ||||||||||||
295 | this->showArrow = showArrow; | - | ||||||||||||
296 | QRect scr = QApplication::desktop()->screenGeometry(pos); | - | ||||||||||||
297 | QSize sh = sizeHint(); | - | ||||||||||||
298 | const int border = 1; | - | ||||||||||||
299 | const int ah = 18, ao = 18, aw = 18, rc = 7; | - | ||||||||||||
300 | bool arrowAtTop = (pos.y() + sh.height() + ah < scr.height()); | - | ||||||||||||
301 | bool arrowAtLeft = (pos.x() + sh.width() - ao < scr.width()); | - | ||||||||||||
302 | setContentsMargins(border + 3, border + (arrowAtTop ? ah : 0) + 2, border + 3, border + (arrowAtTop ? 0 : ah) + 2); | - | ||||||||||||
303 | updateGeometry(); | - | ||||||||||||
304 | sh = sizeHint(); | - | ||||||||||||
305 | - | |||||||||||||
306 | int ml, mr, mt, mb; | - | ||||||||||||
307 | QSize sz = sizeHint(); | - | ||||||||||||
308 | if (!arrowAtTop
| 0 | ||||||||||||
309 | ml = mt = 0; | - | ||||||||||||
310 | mr = sz.width() - 1; | - | ||||||||||||
311 | mb = sz.height() - ah - 1; | - | ||||||||||||
312 | } never executed: else {end of block | 0 | ||||||||||||
313 | ml = 0; | - | ||||||||||||
314 | mt = ah; | - | ||||||||||||
315 | mr = sz.width() - 1; | - | ||||||||||||
316 | mb = sz.height() - 1; | - | ||||||||||||
317 | } never executed: end of block | 0 | ||||||||||||
318 | - | |||||||||||||
319 | QPainterPath path; | - | ||||||||||||
320 | path.moveTo(ml + rc, mt); | - | ||||||||||||
321 | if (arrowAtTop
| 0 | ||||||||||||
322 | if (showArrow
| 0 | ||||||||||||
323 | path.lineTo(ml + ao, mt); | - | ||||||||||||
324 | path.lineTo(ml + ao, mt - ah); | - | ||||||||||||
325 | path.lineTo(ml + ao + aw, mt); | - | ||||||||||||
326 | } never executed: end of block | 0 | ||||||||||||
327 | move(qMax(pos.x() - ao, scr.left() + 2), pos.y()); | - | ||||||||||||
328 | } never executed: else if (arrowAtTopend of block
| 0 | ||||||||||||
329 | if (showArrow
| 0 | ||||||||||||
330 | path.lineTo(mr - ao - aw, mt); | - | ||||||||||||
331 | path.lineTo(mr - ao, mt - ah); | - | ||||||||||||
332 | path.lineTo(mr - ao, mt); | - | ||||||||||||
333 | } never executed: end of block | 0 | ||||||||||||
334 | move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2), pos.y()); | - | ||||||||||||
335 | } never executed: end of block | 0 | ||||||||||||
336 | path.lineTo(mr - rc, mt); | - | ||||||||||||
337 | path.arcTo(QRect(mr - rc*2, mt, rc*2, rc*2), 90, -90); | - | ||||||||||||
338 | path.lineTo(mr, mb - rc); | - | ||||||||||||
339 | path.arcTo(QRect(mr - rc*2, mb - rc*2, rc*2, rc*2), 0, -90); | - | ||||||||||||
340 | if (!arrowAtTop
| 0 | ||||||||||||
341 | if (showArrow
| 0 | ||||||||||||
342 | path.lineTo(mr - ao, mb); | - | ||||||||||||
343 | path.lineTo(mr - ao, mb + ah); | - | ||||||||||||
344 | path.lineTo(mr - ao - aw, mb); | - | ||||||||||||
345 | } never executed: end of block | 0 | ||||||||||||
346 | move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2), | - | ||||||||||||
347 | pos.y() - sh.height()); | - | ||||||||||||
348 | } never executed: else if (!arrowAtTopend of block
| 0 | ||||||||||||
349 | if (showArrow
| 0 | ||||||||||||
350 | path.lineTo(ao + aw, mb); | - | ||||||||||||
351 | path.lineTo(ao, mb + ah); | - | ||||||||||||
352 | path.lineTo(ao, mb); | - | ||||||||||||
353 | } never executed: end of block | 0 | ||||||||||||
354 | move(qMax(pos.x() - ao, scr.x() + 2), pos.y() - sh.height()); | - | ||||||||||||
355 | } never executed: end of block | 0 | ||||||||||||
356 | path.lineTo(ml + rc, mb); | - | ||||||||||||
357 | path.arcTo(QRect(ml, mb - rc*2, rc*2, rc*2), -90, -90); | - | ||||||||||||
358 | path.lineTo(ml, mt + rc); | - | ||||||||||||
359 | path.arcTo(QRect(ml, mt, rc*2, rc*2), 180, -90); | - | ||||||||||||
360 | - | |||||||||||||
361 | - | |||||||||||||
362 | QBitmap bitmap = QBitmap(sizeHint()); | - | ||||||||||||
363 | bitmap.fill(Qt::color0); | - | ||||||||||||
364 | QPainter painter1(&bitmap); | - | ||||||||||||
365 | painter1.setPen(QPen(Qt::color1, border)); | - | ||||||||||||
366 | painter1.setBrush(QBrush(Qt::color1)); | - | ||||||||||||
367 | painter1.drawPath(path); | - | ||||||||||||
368 | setMask(bitmap); | - | ||||||||||||
369 | - | |||||||||||||
370 | - | |||||||||||||
371 | - | |||||||||||||
372 | pixmap = QPixmap(sz); | - | ||||||||||||
373 | QPainter painter2(&pixmap); | - | ||||||||||||
374 | painter2.setPen(QPen(palette().color(QPalette::Window).darker(160), border)); | - | ||||||||||||
375 | painter2.setBrush(palette().color(QPalette::Window)); | - | ||||||||||||
376 | painter2.drawPath(path); | - | ||||||||||||
377 | - | |||||||||||||
378 | if (msecs > 0
| 0 | ||||||||||||
379 | timerId = startTimer(msecs); never executed: timerId = startTimer(msecs); | 0 | ||||||||||||
380 | show(); | - | ||||||||||||
381 | } never executed: end of block | 0 | ||||||||||||
382 | - | |||||||||||||
383 | void QBalloonTip::mousePressEvent(QMouseEvent *e) | - | ||||||||||||
384 | { | - | ||||||||||||
385 | close(); | - | ||||||||||||
386 | if(e->button() == Qt::LeftButton
| 0 | ||||||||||||
387 | trayIcon->messageClicked(); never executed: trayIcon->messageClicked(); | 0 | ||||||||||||
388 | } never executed: end of block | 0 | ||||||||||||
389 | - | |||||||||||||
390 | void QBalloonTip::timerEvent(QTimerEvent *e) | - | ||||||||||||
391 | { | - | ||||||||||||
392 | if (e->timerId() == timerId
| 0 | ||||||||||||
393 | killTimer(timerId); | - | ||||||||||||
394 | if (!underMouse()
| 0 | ||||||||||||
395 | close(); never executed: close(); | 0 | ||||||||||||
396 | return; never executed: return; | 0 | ||||||||||||
397 | } | - | ||||||||||||
398 | QWidget::timerEvent(e); | - | ||||||||||||
399 | } never executed: end of block | 0 | ||||||||||||
400 | - | |||||||||||||
401 | - | |||||||||||||
402 | void QSystemTrayIconPrivate::install_sys_qpa() | - | ||||||||||||
403 | { | - | ||||||||||||
404 | qpa_sys->init(); | - | ||||||||||||
405 | QObject::connect(qpa_sys, qFlagLocation("2""activated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "682"), | - | ||||||||||||
406 | q_func(), qFlagLocation("1""_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "683")); | - | ||||||||||||
407 | QObject::connect(qpa_sys, &QPlatformSystemTrayIcon::messageClicked, | - | ||||||||||||
408 | q_func(), &QSystemTrayIcon::messageClicked); | - | ||||||||||||
409 | updateMenu_sys(); | - | ||||||||||||
410 | updateIcon_sys(); | - | ||||||||||||
411 | updateToolTip_sys(); | - | ||||||||||||
412 | } never executed: end of block | 0 | ||||||||||||
413 | - | |||||||||||||
414 | void QSystemTrayIconPrivate::remove_sys_qpa() | - | ||||||||||||
415 | { | - | ||||||||||||
416 | QObject::disconnect(qpa_sys, qFlagLocation("2""activated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "693"), | - | ||||||||||||
417 | q_func(), qFlagLocation("1""_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "694")); | - | ||||||||||||
418 | QObject::disconnect(qpa_sys, &QPlatformSystemTrayIcon::messageClicked, | - | ||||||||||||
419 | q_func(), &QSystemTrayIcon::messageClicked); | - | ||||||||||||
420 | qpa_sys->cleanup(); | - | ||||||||||||
421 | } never executed: end of block | 0 | ||||||||||||
422 | - | |||||||||||||
423 | QRect QSystemTrayIconPrivate::geometry_sys_qpa() const | - | ||||||||||||
424 | { | - | ||||||||||||
425 | return never executed: qpa_sys->geometry();return qpa_sys->geometry(); never executed: return qpa_sys->geometry(); | 0 | ||||||||||||
426 | } | - | ||||||||||||
427 | - | |||||||||||||
428 | void QSystemTrayIconPrivate::updateIcon_sys_qpa() | - | ||||||||||||
429 | { | - | ||||||||||||
430 | qpa_sys->updateIcon(icon); | - | ||||||||||||
431 | } never executed: end of block | 0 | ||||||||||||
432 | - | |||||||||||||
433 | void QSystemTrayIconPrivate::updateMenu_sys_qpa() | - | ||||||||||||
434 | { | - | ||||||||||||
435 | if (menu
| 0 | ||||||||||||
436 | addPlatformMenu(menu); | - | ||||||||||||
437 | qpa_sys->updateMenu(menu->platformMenu()); | - | ||||||||||||
438 | } never executed: end of block | 0 | ||||||||||||
439 | } never executed: end of block | 0 | ||||||||||||
440 | - | |||||||||||||
441 | void QSystemTrayIconPrivate::updateToolTip_sys_qpa() | - | ||||||||||||
442 | { | - | ||||||||||||
443 | qpa_sys->updateToolTip(toolTip); | - | ||||||||||||
444 | } never executed: end of block | 0 | ||||||||||||
445 | - | |||||||||||||
446 | void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title, | - | ||||||||||||
447 | const QString &message, | - | ||||||||||||
448 | QSystemTrayIcon::MessageIcon icon, | - | ||||||||||||
449 | int msecs) | - | ||||||||||||
450 | { | - | ||||||||||||
451 | QIcon notificationIcon; | - | ||||||||||||
452 | switch (icon) { | - | ||||||||||||
453 | case never executed: QSystemTrayIcon::Information:case QSystemTrayIcon::Information: never executed: case QSystemTrayIcon::Information: | 0 | ||||||||||||
454 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); | - | ||||||||||||
455 | break; never executed: break; | 0 | ||||||||||||
456 | case never executed: QSystemTrayIcon::Warning:case QSystemTrayIcon::Warning: never executed: case QSystemTrayIcon::Warning: | 0 | ||||||||||||
457 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); | - | ||||||||||||
458 | break; never executed: break; | 0 | ||||||||||||
459 | case never executed: QSystemTrayIcon::Critical:case QSystemTrayIcon::Critical: never executed: case QSystemTrayIcon::Critical: | 0 | ||||||||||||
460 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); | - | ||||||||||||
461 | break; never executed: break; | 0 | ||||||||||||
462 | default never executed: :default: never executed: default: | 0 | ||||||||||||
463 | break; never executed: break; | 0 | ||||||||||||
464 | } | - | ||||||||||||
465 | qpa_sys->showMessage(title, message, notificationIcon, | - | ||||||||||||
466 | static_cast<QPlatformSystemTrayIcon::MessageIcon>(icon), msecs); | - | ||||||||||||
467 | } never executed: end of block | 0 | ||||||||||||
468 | - | |||||||||||||
469 | void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const | - | ||||||||||||
470 | { | - | ||||||||||||
471 | if (menu->platformMenu()
| 0 | ||||||||||||
472 | return; never executed: return; | 0 | ||||||||||||
473 | - | |||||||||||||
474 | - | |||||||||||||
475 | - | |||||||||||||
476 | QListIterator<QAction *> it(menu->actions()); | - | ||||||||||||
477 | while (it.hasNext()
| 0 | ||||||||||||
478 | QAction *action = it.next(); | - | ||||||||||||
479 | if (action->menu()
| 0 | ||||||||||||
480 | addPlatformMenu(action->menu()); never executed: addPlatformMenu(action->menu()); | 0 | ||||||||||||
481 | } never executed: end of block | 0 | ||||||||||||
482 | - | |||||||||||||
483 | - | |||||||||||||
484 | - | |||||||||||||
485 | QPlatformMenu *platformMenu = qpa_sys->createMenu(); | - | ||||||||||||
486 | if (platformMenu
| 0 | ||||||||||||
487 | menu->setPlatformMenu(platformMenu); never executed: menu->setPlatformMenu(platformMenu); | 0 | ||||||||||||
488 | } never executed: end of block | 0 | ||||||||||||
489 | - | |||||||||||||
490 | - | |||||||||||||
491 | - | |||||||||||||
492 | - | |||||||||||||
493 | - | |||||||||||||
Switch to Source code | Preprocessed file |