| 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 (__builtin_expect(!!(visible && d->icon.isNull()), false)
| 0 | ||||||||||||
| 76 | QMessageLogger(__FILE__, 274, __PRETTY_FUNCTION__).warning("QSystemTrayIcon::setVisible: No Icon set"); never executed: QMessageLogger(__FILE__, 274, __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), trayIcon(ti), timerId(-1) | - | ||||||||||||
| 167 | { | - | ||||||||||||
| 168 | setAttribute(Qt::WA_DeleteOnClose); | - | ||||||||||||
| 169 | QObject::connect(ti, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "442"), this, qFlagLocation("1""close()" "\0" __FILE__ ":" "442")); | - | ||||||||||||
| 170 | - | |||||||||||||
| 171 | QLabel *titleLabel = new QLabel; | - | ||||||||||||
| 172 | titleLabel->installEventFilter(this); | - | ||||||||||||
| 173 | titleLabel->setText(title); | - | ||||||||||||
| 174 | QFont f = titleLabel->font(); | - | ||||||||||||
| 175 | f.setBold(true); | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | - | |||||||||||||
| 178 | - | |||||||||||||
| 179 | titleLabel->setFont(f); | - | ||||||||||||
| 180 | titleLabel->setTextFormat(Qt::PlainText); | - | ||||||||||||
| 181 | - | |||||||||||||
| 182 | - | |||||||||||||
| 183 | - | |||||||||||||
| 184 | - | |||||||||||||
| 185 | - | |||||||||||||
| 186 | const int iconSize = 18; | - | ||||||||||||
| 187 | const int closeButtonSize = 15; | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | - | |||||||||||||
| 190 | QPushButton *closeButton = new QPushButton; | - | ||||||||||||
| 191 | closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton)); | - | ||||||||||||
| 192 | closeButton->setIconSize(QSize(closeButtonSize, closeButtonSize)); | - | ||||||||||||
| 193 | closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | - | ||||||||||||
| 194 | closeButton->setFixedSize(closeButtonSize, closeButtonSize); | - | ||||||||||||
| 195 | QObject::connect(closeButton, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "468"), this, qFlagLocation("1""close()" "\0" __FILE__ ":" "468")); | - | ||||||||||||
| 196 | - | |||||||||||||
| 197 | QLabel *msgLabel = new QLabel; | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | - | |||||||||||||
| 200 | - | |||||||||||||
| 201 | - | |||||||||||||
| 202 | msgLabel->installEventFilter(this); | - | ||||||||||||
| 203 | msgLabel->setText(message); | - | ||||||||||||
| 204 | msgLabel->setTextFormat(Qt::PlainText); | - | ||||||||||||
| 205 | msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); | - | ||||||||||||
| 206 | - | |||||||||||||
| 207 | - | |||||||||||||
| 208 | - | |||||||||||||
| 209 | - | |||||||||||||
| 210 | - | |||||||||||||
| 211 | int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3; | - | ||||||||||||
| 212 | - | |||||||||||||
| 213 | if (msgLabel->sizeHint().width() > limit
| 0 | ||||||||||||
| 214 | msgLabel->setWordWrap(true); | - | ||||||||||||
| 215 | if (msgLabel->sizeHint().width() > limit
| 0 | ||||||||||||
| 216 | msgLabel->d_func()->ensureTextControl(); | - | ||||||||||||
| 217 | if (QWidgetTextControl *control = msgLabel->d_func()->control
| 0 | ||||||||||||
| 218 | QTextOption opt = control->document()->defaultTextOption(); | - | ||||||||||||
| 219 | opt.setWrapMode(QTextOption::WrapAnywhere); | - | ||||||||||||
| 220 | control->document()->setDefaultTextOption(opt); | - | ||||||||||||
| 221 | } never executed: end of block | 0 | ||||||||||||
| 222 | } never executed: end of block | 0 | ||||||||||||
| 223 | - | |||||||||||||
| 224 | - | |||||||||||||
| 225 | - | |||||||||||||
| 226 | - | |||||||||||||
| 227 | - | |||||||||||||
| 228 | - | |||||||||||||
| 229 | - | |||||||||||||
| 230 | msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit)); | - | ||||||||||||
| 231 | - | |||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||
| 233 | - | |||||||||||||
| 234 | QIcon si; | - | ||||||||||||
| 235 | switch (icon) { | - | ||||||||||||
| 236 | case never executed: QSystemTrayIcon::Warning:case QSystemTrayIcon::Warning:never executed: case QSystemTrayIcon::Warning: | 0 | ||||||||||||
| 237 | si = style()->standardIcon(QStyle::SP_MessageBoxWarning); | - | ||||||||||||
| 238 | break; never executed: break; | 0 | ||||||||||||
| 239 | case never executed: QSystemTrayIcon::Critical:case QSystemTrayIcon::Critical:never executed: case QSystemTrayIcon::Critical: | 0 | ||||||||||||
| 240 | si = style()->standardIcon(QStyle::SP_MessageBoxCritical); | - | ||||||||||||
| 241 | break; never executed: break; | 0 | ||||||||||||
| 242 | case never executed: QSystemTrayIcon::Information:case QSystemTrayIcon::Information:never executed: case QSystemTrayIcon::Information: | 0 | ||||||||||||
| 243 | si = style()->standardIcon(QStyle::SP_MessageBoxInformation); | - | ||||||||||||
| 244 | break; never executed: break; | 0 | ||||||||||||
| 245 | case never executed: QSystemTrayIcon::NoIcon:case QSystemTrayIcon::NoIcon:never executed: case QSystemTrayIcon::NoIcon: | 0 | ||||||||||||
| 246 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 247 | break; never executed: break; | 0 | ||||||||||||
| 248 | } | - | ||||||||||||
| 249 | - | |||||||||||||
| 250 | QGridLayout *layout = new QGridLayout; | - | ||||||||||||
| 251 | if (!si.isNull()
| 0 | ||||||||||||
| 252 | QLabel *iconLabel = new QLabel; | - | ||||||||||||
| 253 | iconLabel->setPixmap(si.pixmap(iconSize, iconSize)); | - | ||||||||||||
| 254 | iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | - | ||||||||||||
| 255 | iconLabel->setMargin(2); | - | ||||||||||||
| 256 | layout->addWidget(iconLabel, 0, 0); | - | ||||||||||||
| 257 | layout->addWidget(titleLabel, 0, 1); | - | ||||||||||||
| 258 | } never executed: else {end of block | 0 | ||||||||||||
| 259 | layout->addWidget(titleLabel, 0, 0, 1, 2); | - | ||||||||||||
| 260 | } never executed: end of block | 0 | ||||||||||||
| 261 | - | |||||||||||||
| 262 | layout->addWidget(closeButton, 0, 2); | - | ||||||||||||
| 263 | layout->addWidget(msgLabel, 1, 0, 1, 3); | - | ||||||||||||
| 264 | layout->setSizeConstraint(QLayout::SetFixedSize); | - | ||||||||||||
| 265 | layout->setMargin(3); | - | ||||||||||||
| 266 | setLayout(layout); | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | QPalette pal = palette(); | - | ||||||||||||
| 269 | pal.setColor(QPalette::Window, QColor(0xff, 0xff, 0xe1)); | - | ||||||||||||
| 270 | pal.setColor(QPalette::WindowText, Qt::black); | - | ||||||||||||
| 271 | setPalette(pal); | - | ||||||||||||
| 272 | } never executed: end of block | 0 | ||||||||||||
| 273 | - | |||||||||||||
| 274 | QBalloonTip::~QBalloonTip() | - | ||||||||||||
| 275 | { | - | ||||||||||||
| 276 | theSolitaryBalloonTip = 0; | - | ||||||||||||
| 277 | } never executed: end of block | 0 | ||||||||||||
| 278 | - | |||||||||||||
| 279 | void QBalloonTip::paintEvent(QPaintEvent *) | - | ||||||||||||
| 280 | { | - | ||||||||||||
| 281 | QPainter painter(this); | - | ||||||||||||
| 282 | painter.drawPixmap(rect(), pixmap); | - | ||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||
| 284 | - | |||||||||||||
| 285 | void QBalloonTip::resizeEvent(QResizeEvent *ev) | - | ||||||||||||
| 286 | { | - | ||||||||||||
| 287 | QWidget::resizeEvent(ev); | - | ||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||
| 289 | - | |||||||||||||
| 290 | void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow) | - | ||||||||||||
| 291 | { | - | ||||||||||||
| 292 | this->showArrow = showArrow; | - | ||||||||||||
| 293 | QRect scr = QApplication::desktop()->screenGeometry(pos); | - | ||||||||||||
| 294 | QSize sh = sizeHint(); | - | ||||||||||||
| 295 | const int border = 1; | - | ||||||||||||
| 296 | const int ah = 18, ao = 18, aw = 18, rc = 7; | - | ||||||||||||
| 297 | bool arrowAtTop = (pos.y() + sh.height() + ah < scr.height()); | - | ||||||||||||
| 298 | bool arrowAtLeft = (pos.x() + sh.width() - ao < scr.width()); | - | ||||||||||||
| 299 | setContentsMargins(border + 3, border + (arrowAtTop ? ah : 0) + 2, border + 3, border + (arrowAtTop ? 0 : ah) + 2); | - | ||||||||||||
| 300 | updateGeometry(); | - | ||||||||||||
| 301 | sh = sizeHint(); | - | ||||||||||||
| 302 | - | |||||||||||||
| 303 | int ml, mr, mt, mb; | - | ||||||||||||
| 304 | QSize sz = sizeHint(); | - | ||||||||||||
| 305 | if (!arrowAtTop
| 0 | ||||||||||||
| 306 | ml = mt = 0; | - | ||||||||||||
| 307 | mr = sz.width() - 1; | - | ||||||||||||
| 308 | mb = sz.height() - ah - 1; | - | ||||||||||||
| 309 | } never executed: else {end of block | 0 | ||||||||||||
| 310 | ml = 0; | - | ||||||||||||
| 311 | mt = ah; | - | ||||||||||||
| 312 | mr = sz.width() - 1; | - | ||||||||||||
| 313 | mb = sz.height() - 1; | - | ||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||
| 315 | - | |||||||||||||
| 316 | QPainterPath path; | - | ||||||||||||
| 317 | path.moveTo(ml + rc, mt); | - | ||||||||||||
| 318 | if (arrowAtTop
| 0 | ||||||||||||
| 319 | if (showArrow
| 0 | ||||||||||||
| 320 | path.lineTo(ml + ao, mt); | - | ||||||||||||
| 321 | path.lineTo(ml + ao, mt - ah); | - | ||||||||||||
| 322 | path.lineTo(ml + ao + aw, mt); | - | ||||||||||||
| 323 | } never executed: end of block | 0 | ||||||||||||
| 324 | move(qMax(pos.x() - ao, scr.left() + 2), pos.y()); | - | ||||||||||||
| 325 | } never executed: else if (arrowAtTopend of block
| 0 | ||||||||||||
| 326 | if (showArrow
| 0 | ||||||||||||
| 327 | path.lineTo(mr - ao - aw, mt); | - | ||||||||||||
| 328 | path.lineTo(mr - ao, mt - ah); | - | ||||||||||||
| 329 | path.lineTo(mr - ao, mt); | - | ||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||
| 331 | move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2), pos.y()); | - | ||||||||||||
| 332 | } never executed: end of block | 0 | ||||||||||||
| 333 | path.lineTo(mr - rc, mt); | - | ||||||||||||
| 334 | path.arcTo(QRect(mr - rc*2, mt, rc*2, rc*2), 90, -90); | - | ||||||||||||
| 335 | path.lineTo(mr, mb - rc); | - | ||||||||||||
| 336 | path.arcTo(QRect(mr - rc*2, mb - rc*2, rc*2, rc*2), 0, -90); | - | ||||||||||||
| 337 | if (!arrowAtTop
| 0 | ||||||||||||
| 338 | if (showArrow
| 0 | ||||||||||||
| 339 | path.lineTo(mr - ao, mb); | - | ||||||||||||
| 340 | path.lineTo(mr - ao, mb + ah); | - | ||||||||||||
| 341 | path.lineTo(mr - ao - aw, mb); | - | ||||||||||||
| 342 | } never executed: end of block | 0 | ||||||||||||
| 343 | move(qMin(pos.x() - sh.width() + ao, scr.right() - sh.width() - 2), | - | ||||||||||||
| 344 | pos.y() - sh.height()); | - | ||||||||||||
| 345 | } never executed: else if (!arrowAtTopend of block
| 0 | ||||||||||||
| 346 | if (showArrow
| 0 | ||||||||||||
| 347 | path.lineTo(ao + aw, mb); | - | ||||||||||||
| 348 | path.lineTo(ao, mb + ah); | - | ||||||||||||
| 349 | path.lineTo(ao, mb); | - | ||||||||||||
| 350 | } never executed: end of block | 0 | ||||||||||||
| 351 | move(qMax(pos.x() - ao, scr.x() + 2), pos.y() - sh.height()); | - | ||||||||||||
| 352 | } never executed: end of block | 0 | ||||||||||||
| 353 | path.lineTo(ml + rc, mb); | - | ||||||||||||
| 354 | path.arcTo(QRect(ml, mb - rc*2, rc*2, rc*2), -90, -90); | - | ||||||||||||
| 355 | path.lineTo(ml, mt + rc); | - | ||||||||||||
| 356 | path.arcTo(QRect(ml, mt, rc*2, rc*2), 180, -90); | - | ||||||||||||
| 357 | - | |||||||||||||
| 358 | - | |||||||||||||
| 359 | QBitmap bitmap = QBitmap(sizeHint()); | - | ||||||||||||
| 360 | bitmap.fill(Qt::color0); | - | ||||||||||||
| 361 | QPainter painter1(&bitmap); | - | ||||||||||||
| 362 | painter1.setPen(QPen(Qt::color1, border)); | - | ||||||||||||
| 363 | painter1.setBrush(QBrush(Qt::color1)); | - | ||||||||||||
| 364 | painter1.drawPath(path); | - | ||||||||||||
| 365 | setMask(bitmap); | - | ||||||||||||
| 366 | - | |||||||||||||
| 367 | - | |||||||||||||
| 368 | - | |||||||||||||
| 369 | pixmap = QPixmap(sz); | - | ||||||||||||
| 370 | QPainter painter2(&pixmap); | - | ||||||||||||
| 371 | painter2.setPen(QPen(palette().color(QPalette::Window).darker(160), border)); | - | ||||||||||||
| 372 | painter2.setBrush(palette().color(QPalette::Window)); | - | ||||||||||||
| 373 | painter2.drawPath(path); | - | ||||||||||||
| 374 | - | |||||||||||||
| 375 | if (msecs > 0
| 0 | ||||||||||||
| 376 | timerId = startTimer(msecs); never executed: timerId = startTimer(msecs); | 0 | ||||||||||||
| 377 | show(); | - | ||||||||||||
| 378 | } never executed: end of block | 0 | ||||||||||||
| 379 | - | |||||||||||||
| 380 | void QBalloonTip::mousePressEvent(QMouseEvent *e) | - | ||||||||||||
| 381 | { | - | ||||||||||||
| 382 | close(); | - | ||||||||||||
| 383 | if(e->button() == Qt::LeftButton
| 0 | ||||||||||||
| 384 | trayIcon->messageClicked(); never executed: trayIcon->messageClicked(); | 0 | ||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||
| 386 | - | |||||||||||||
| 387 | void QBalloonTip::timerEvent(QTimerEvent *e) | - | ||||||||||||
| 388 | { | - | ||||||||||||
| 389 | if (e->timerId() == timerId
| 0 | ||||||||||||
| 390 | killTimer(timerId); | - | ||||||||||||
| 391 | if (!underMouse()
| 0 | ||||||||||||
| 392 | close(); never executed: close(); | 0 | ||||||||||||
| 393 | return; never executed: return; | 0 | ||||||||||||
| 394 | } | - | ||||||||||||
| 395 | QWidget::timerEvent(e); | - | ||||||||||||
| 396 | } never executed: end of block | 0 | ||||||||||||
| 397 | - | |||||||||||||
| 398 | - | |||||||||||||
| 399 | void QSystemTrayIconPrivate::install_sys_qpa() | - | ||||||||||||
| 400 | { | - | ||||||||||||
| 401 | qpa_sys->init(); | - | ||||||||||||
| 402 | QObject::connect(qpa_sys, qFlagLocation("2""activated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "685"), | - | ||||||||||||
| 403 | q_func(), qFlagLocation("1""_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "686")); | - | ||||||||||||
| 404 | QObject::connect(qpa_sys, &QPlatformSystemTrayIcon::messageClicked, | - | ||||||||||||
| 405 | q_func(), &QSystemTrayIcon::messageClicked); | - | ||||||||||||
| 406 | updateMenu_sys(); | - | ||||||||||||
| 407 | updateIcon_sys(); | - | ||||||||||||
| 408 | updateToolTip_sys(); | - | ||||||||||||
| 409 | } never executed: end of block | 0 | ||||||||||||
| 410 | - | |||||||||||||
| 411 | void QSystemTrayIconPrivate::remove_sys_qpa() | - | ||||||||||||
| 412 | { | - | ||||||||||||
| 413 | QObject::disconnect(qpa_sys, qFlagLocation("2""activated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "696"), | - | ||||||||||||
| 414 | q_func(), qFlagLocation("1""_q_emitActivated(QPlatformSystemTrayIcon::ActivationReason)" "\0" __FILE__ ":" "697")); | - | ||||||||||||
| 415 | QObject::disconnect(qpa_sys, &QPlatformSystemTrayIcon::messageClicked, | - | ||||||||||||
| 416 | q_func(), &QSystemTrayIcon::messageClicked); | - | ||||||||||||
| 417 | qpa_sys->cleanup(); | - | ||||||||||||
| 418 | } never executed: end of block | 0 | ||||||||||||
| 419 | - | |||||||||||||
| 420 | QRect QSystemTrayIconPrivate::geometry_sys_qpa() const | - | ||||||||||||
| 421 | { | - | ||||||||||||
| 422 | return never executed: qpa_sys->geometry();return qpa_sys->geometry();never executed: return qpa_sys->geometry(); | 0 | ||||||||||||
| 423 | } | - | ||||||||||||
| 424 | - | |||||||||||||
| 425 | void QSystemTrayIconPrivate::updateIcon_sys_qpa() | - | ||||||||||||
| 426 | { | - | ||||||||||||
| 427 | qpa_sys->updateIcon(icon); | - | ||||||||||||
| 428 | } never executed: end of block | 0 | ||||||||||||
| 429 | - | |||||||||||||
| 430 | void QSystemTrayIconPrivate::updateMenu_sys_qpa() | - | ||||||||||||
| 431 | { | - | ||||||||||||
| 432 | if (menu
| 0 | ||||||||||||
| 433 | addPlatformMenu(menu); | - | ||||||||||||
| 434 | qpa_sys->updateMenu(menu->platformMenu()); | - | ||||||||||||
| 435 | } never executed: end of block | 0 | ||||||||||||
| 436 | } never executed: end of block | 0 | ||||||||||||
| 437 | - | |||||||||||||
| 438 | void QSystemTrayIconPrivate::updateToolTip_sys_qpa() | - | ||||||||||||
| 439 | { | - | ||||||||||||
| 440 | qpa_sys->updateToolTip(toolTip); | - | ||||||||||||
| 441 | } never executed: end of block | 0 | ||||||||||||
| 442 | - | |||||||||||||
| 443 | void QSystemTrayIconPrivate::showMessage_sys_qpa(const QString &title, | - | ||||||||||||
| 444 | const QString &message, | - | ||||||||||||
| 445 | QSystemTrayIcon::MessageIcon icon, | - | ||||||||||||
| 446 | int msecs) | - | ||||||||||||
| 447 | { | - | ||||||||||||
| 448 | QIcon notificationIcon; | - | ||||||||||||
| 449 | switch (icon) { | - | ||||||||||||
| 450 | case never executed: QSystemTrayIcon::Information:case QSystemTrayIcon::Information:never executed: case QSystemTrayIcon::Information: | 0 | ||||||||||||
| 451 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); | - | ||||||||||||
| 452 | break; never executed: break; | 0 | ||||||||||||
| 453 | case never executed: QSystemTrayIcon::Warning:case QSystemTrayIcon::Warning:never executed: case QSystemTrayIcon::Warning: | 0 | ||||||||||||
| 454 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); | - | ||||||||||||
| 455 | break; never executed: break; | 0 | ||||||||||||
| 456 | case never executed: QSystemTrayIcon::Critical:case QSystemTrayIcon::Critical:never executed: case QSystemTrayIcon::Critical: | 0 | ||||||||||||
| 457 | notificationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); | - | ||||||||||||
| 458 | break; never executed: break; | 0 | ||||||||||||
| 459 | default never executed: :default:never executed: default: | 0 | ||||||||||||
| 460 | break; never executed: break; | 0 | ||||||||||||
| 461 | } | - | ||||||||||||
| 462 | qpa_sys->showMessage(title, message, notificationIcon, | - | ||||||||||||
| 463 | static_cast<QPlatformSystemTrayIcon::MessageIcon>(icon), msecs); | - | ||||||||||||
| 464 | } never executed: end of block | 0 | ||||||||||||
| 465 | - | |||||||||||||
| 466 | void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const | - | ||||||||||||
| 467 | { | - | ||||||||||||
| 468 | if (menu->platformMenu()
| 0 | ||||||||||||
| 469 | return; never executed: return; | 0 | ||||||||||||
| 470 | - | |||||||||||||
| 471 | - | |||||||||||||
| 472 | - | |||||||||||||
| 473 | QListIterator<QAction *> it(menu->actions()); | - | ||||||||||||
| 474 | while (it.hasNext()
| 0 | ||||||||||||
| 475 | QAction *action = it.next(); | - | ||||||||||||
| 476 | if (action->menu()
| 0 | ||||||||||||
| 477 | addPlatformMenu(action->menu()); never executed: addPlatformMenu(action->menu()); | 0 | ||||||||||||
| 478 | } never executed: end of block | 0 | ||||||||||||
| 479 | - | |||||||||||||
| 480 | - | |||||||||||||
| 481 | - | |||||||||||||
| 482 | QPlatformMenu *platformMenu = qpa_sys->createMenu(); | - | ||||||||||||
| 483 | if (platformMenu
| 0 | ||||||||||||
| 484 | menu->setPlatformMenu(platformMenu); never executed: menu->setPlatformMenu(platformMenu); | 0 | ||||||||||||
| 485 | } never executed: end of block | 0 | ||||||||||||
| 486 | - | |||||||||||||
| 487 | - | |||||||||||||
| 488 | - | |||||||||||||
| 489 | - | |||||||||||||
| 490 | - | |||||||||||||
| Switch to Source code | Preprocessed file |