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