| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/kernel/qtooltip.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | class QTipLabel : public QLabel | - | ||||||||||||||||||
| 10 | { | - | ||||||||||||||||||
| 11 | 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; } | - | ||||||||||||||||||
| 12 | #pragma GCC diagnostic push | - | ||||||||||||||||||
| 13 | 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 **); | - | ||||||||||||||||||
| 14 | #pragma GCC diagnostic pop | - | ||||||||||||||||||
| 15 | struct QPrivateSignal {}; | - | ||||||||||||||||||
| 16 | public: | - | ||||||||||||||||||
| 17 | QTipLabel(const QString &text, QWidget *w, int msecDisplayTime); | - | ||||||||||||||||||
| 18 | ~QTipLabel(); | - | ||||||||||||||||||
| 19 | static QTipLabel *instance; | - | ||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | bool eventFilter(QObject *, QEvent *) override; | - | ||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | QBasicTimer hideTimer, expireTimer; | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | bool fadingOut; | - | ||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | void reuseTip(const QString &text, int msecDisplayTime); | - | ||||||||||||||||||
| 28 | void hideTip(); | - | ||||||||||||||||||
| 29 | void hideTipImmediately(); | - | ||||||||||||||||||
| 30 | void setTipRect(QWidget *w, const QRect &r); | - | ||||||||||||||||||
| 31 | void restartExpireTimer(int msecDisplayTime); | - | ||||||||||||||||||
| 32 | bool tipChanged(const QPoint &pos, const QString &text, QObject *o); | - | ||||||||||||||||||
| 33 | void placeTip(const QPoint &pos, QWidget *w); | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | static int getTipScreen(const QPoint &pos, QWidget *w); | - | ||||||||||||||||||
| 36 | protected: | - | ||||||||||||||||||
| 37 | void timerEvent(QTimerEvent *e) override; | - | ||||||||||||||||||
| 38 | void paintEvent(QPaintEvent *e) override; | - | ||||||||||||||||||
| 39 | void mouseMoveEvent(QMouseEvent *e) override; | - | ||||||||||||||||||
| 40 | void resizeEvent(QResizeEvent *e) override; | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | public : | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | void styleSheetParentDestroyed() { | - | ||||||||||||||||||
| 48 | setProperty("_q_stylesheet_parent", QVariant()); | - | ||||||||||||||||||
| 49 | styleSheetParent = 0; | - | ||||||||||||||||||
| 50 | } never executed: end of block | 0 | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | private: | - | ||||||||||||||||||
| 53 | QWidget *styleSheetParent; | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | private: | - | ||||||||||||||||||
| 57 | QWidget *widget; | - | ||||||||||||||||||
| 58 | QRect rect; | - | ||||||||||||||||||
| 59 | }; | - | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | QTipLabel *QTipLabel::instance = 0; | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | QTipLabel::QTipLabel(const QString &text, QWidget *w, int msecDisplayTime) | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | : QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget), styleSheetParent(0), widget(0) | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | { | - | ||||||||||||||||||
| 70 | delete instance; | - | ||||||||||||||||||
| 71 | instance = this; | - | ||||||||||||||||||
| 72 | setForegroundRole(QPalette::ToolTipText); | - | ||||||||||||||||||
| 73 | setBackgroundRole(QPalette::ToolTipBase); | - | ||||||||||||||||||
| 74 | setPalette(QToolTip::palette()); | - | ||||||||||||||||||
| 75 | ensurePolished(); | - | ||||||||||||||||||
| 76 | setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this)); | - | ||||||||||||||||||
| 77 | setFrameStyle(QFrame::NoFrame); | - | ||||||||||||||||||
| 78 | setAlignment(Qt::AlignLeft); | - | ||||||||||||||||||
| 79 | setIndent(1); | - | ||||||||||||||||||
| 80 | (static_cast<QApplication *>(QCoreApplication::instance()))->installEventFilter(this); | - | ||||||||||||||||||
| 81 | setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); | - | ||||||||||||||||||
| 82 | setMouseTracking(true); | - | ||||||||||||||||||
| 83 | fadingOut = false; | - | ||||||||||||||||||
| 84 | reuseTip(text, msecDisplayTime); | - | ||||||||||||||||||
| 85 | } never executed: end of block | 0 | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | void QTipLabel::restartExpireTimer(int msecDisplayTime) | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | int time = 10000 + 40 * qMax(0, text().length()-100); | - | ||||||||||||||||||
| 90 | if (msecDisplayTime > 0
| 0 | ||||||||||||||||||
| 91 | time = msecDisplayTime; never executed: time = msecDisplayTime; | 0 | ||||||||||||||||||
| 92 | expireTimer.start(time, this); | - | ||||||||||||||||||
| 93 | hideTimer.stop(); | - | ||||||||||||||||||
| 94 | } never executed: end of block | 0 | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | void QTipLabel::reuseTip(const QString &text, int msecDisplayTime) | - | ||||||||||||||||||
| 97 | { | - | ||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | if (styleSheetParent
| 0 | ||||||||||||||||||
| 100 | disconnect(styleSheetParent, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "203"), | - | ||||||||||||||||||
| 101 | QTipLabel::instance, qFlagLocation("1""styleSheetParentDestroyed()" "\0" __FILE__ ":" "204")); | - | ||||||||||||||||||
| 102 | styleSheetParent = 0; | - | ||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | setWordWrap(Qt::mightBeRichText(text)); | - | ||||||||||||||||||
| 107 | setText(text); | - | ||||||||||||||||||
| 108 | QFontMetrics fm(font()); | - | ||||||||||||||||||
| 109 | QSize extra(1, 0); | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | if (fm.descent() == 2
| 0 | ||||||||||||||||||
| 112 | ++ never executed: extra.rheight();++extra.rheight();never executed: ++extra.rheight(); | 0 | ||||||||||||||||||
| 113 | resize(sizeHint() + extra); | - | ||||||||||||||||||
| 114 | restartExpireTimer(msecDisplayTime); | - | ||||||||||||||||||
| 115 | } never executed: end of block | 0 | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | void QTipLabel::paintEvent(QPaintEvent *ev) | - | ||||||||||||||||||
| 118 | { | - | ||||||||||||||||||
| 119 | QStylePainter p(this); | - | ||||||||||||||||||
| 120 | QStyleOptionFrame opt; | - | ||||||||||||||||||
| 121 | opt.init(this); | - | ||||||||||||||||||
| 122 | p.drawPrimitive(QStyle::PE_PanelTipLabel, opt); | - | ||||||||||||||||||
| 123 | p.end(); | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | QLabel::paintEvent(ev); | - | ||||||||||||||||||
| 126 | } never executed: end of block | 0 | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | void QTipLabel::resizeEvent(QResizeEvent *e) | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | QStyleHintReturnMask frameMask; | - | ||||||||||||||||||
| 131 | QStyleOption option; | - | ||||||||||||||||||
| 132 | option.init(this); | - | ||||||||||||||||||
| 133 | if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask)
| 0 | ||||||||||||||||||
| 134 | setMask(frameMask.region); never executed: setMask(frameMask.region); | 0 | ||||||||||||||||||
| 135 | - | |||||||||||||||||||
| 136 | QLabel::resizeEvent(e); | - | ||||||||||||||||||
| 137 | } never executed: end of block | 0 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | void QTipLabel::mouseMoveEvent(QMouseEvent *e) | - | ||||||||||||||||||
| 140 | { | - | ||||||||||||||||||
| 141 | if (rect.isNull()
| 0 | ||||||||||||||||||
| 142 | return; never executed: return; | 0 | ||||||||||||||||||
| 143 | QPoint pos = e->globalPos(); | - | ||||||||||||||||||
| 144 | if (widget
| 0 | ||||||||||||||||||
| 145 | pos = widget->mapFromGlobal(pos); never executed: pos = widget->mapFromGlobal(pos); | 0 | ||||||||||||||||||
| 146 | if (!rect.contains(pos)
| 0 | ||||||||||||||||||
| 147 | hideTip(); never executed: hideTip(); | 0 | ||||||||||||||||||
| 148 | QLabel::mouseMoveEvent(e); | - | ||||||||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | QTipLabel::~QTipLabel() | - | ||||||||||||||||||
| 152 | { | - | ||||||||||||||||||
| 153 | instance = 0; | - | ||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | void QTipLabel::hideTip() | - | ||||||||||||||||||
| 157 | { | - | ||||||||||||||||||
| 158 | if (!hideTimer.isActive()
| 0 | ||||||||||||||||||
| 159 | hideTimer.start(300, this); never executed: hideTimer.start(300, this); | 0 | ||||||||||||||||||
| 160 | } never executed: end of block | 0 | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | void QTipLabel::hideTipImmediately() | - | ||||||||||||||||||
| 163 | { | - | ||||||||||||||||||
| 164 | close(); | - | ||||||||||||||||||
| 165 | deleteLater(); | - | ||||||||||||||||||
| 166 | } never executed: end of block | 0 | ||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | void QTipLabel::setTipRect(QWidget *w, const QRect &r) | - | ||||||||||||||||||
| 169 | { | - | ||||||||||||||||||
| 170 | if (__builtin_expect(!!(!r.isNull() && !w), false)
| 0 | ||||||||||||||||||
| 171 | QMessageLogger(__FILE__, 274, __PRETTY_FUNCTION__).warning("QToolTip::setTipRect: Cannot pass null widget if rect is set"); | - | ||||||||||||||||||
| 172 | return; never executed: return; | 0 | ||||||||||||||||||
| 173 | } | - | ||||||||||||||||||
| 174 | widget = w; | - | ||||||||||||||||||
| 175 | rect = r; | - | ||||||||||||||||||
| 176 | } never executed: end of block | 0 | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | void QTipLabel::timerEvent(QTimerEvent *e) | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | if (e->timerId() == hideTimer.timerId()
| 0 | ||||||||||||||||||
| 181 | || e->timerId() == expireTimer.timerId()
| 0 | ||||||||||||||||||
| 182 | hideTimer.stop(); | - | ||||||||||||||||||
| 183 | expireTimer.stop(); | - | ||||||||||||||||||
| 184 | hideTipImmediately(); | - | ||||||||||||||||||
| 185 | - | |||||||||||||||||||
| 186 | } never executed: end of block | 0 | ||||||||||||||||||
| 187 | } never executed: end of block | 0 | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | bool QTipLabel::eventFilter(QObject *o, QEvent *e) | - | ||||||||||||||||||
| 190 | { | - | ||||||||||||||||||
| 191 | switch (e->type()) { | - | ||||||||||||||||||
| 192 | case never executed: QEvent::Leave:case QEvent::Leave:never executed: case QEvent::Leave: | 0 | ||||||||||||||||||
| 193 | hideTip(); | - | ||||||||||||||||||
| 194 | break; never executed: break; | 0 | ||||||||||||||||||
| 195 | case never executed: QEvent::WindowActivate:case QEvent::WindowActivate:never executed: case QEvent::WindowActivate: | 0 | ||||||||||||||||||
| 196 | case never executed: QEvent::WindowDeactivate:case QEvent::WindowDeactivate:never executed: case QEvent::WindowDeactivate: | 0 | ||||||||||||||||||
| 197 | case never executed: QEvent::FocusIn:case QEvent::FocusIn:never executed: case QEvent::FocusIn: | 0 | ||||||||||||||||||
| 198 | case never executed: QEvent::FocusOut:case QEvent::FocusOut:never executed: case QEvent::FocusOut: | 0 | ||||||||||||||||||
| 199 | - | |||||||||||||||||||
| 200 | case never executed: QEvent::Close:case QEvent::Close:never executed: case QEvent::Close: | 0 | ||||||||||||||||||
| 201 | case never executed: QEvent::MouseButtonPress:case QEvent::MouseButtonPress:never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||
| 202 | case never executed: QEvent::MouseButtonRelease:case QEvent::MouseButtonRelease:never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||
| 203 | case never executed: QEvent::MouseButtonDblClick:case QEvent::MouseButtonDblClick:never executed: case QEvent::MouseButtonDblClick: | 0 | ||||||||||||||||||
| 204 | case never executed: QEvent::Wheel:case QEvent::Wheel:never executed: case QEvent::Wheel: | 0 | ||||||||||||||||||
| 205 | hideTipImmediately(); | - | ||||||||||||||||||
| 206 | break; never executed: break; | 0 | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | case never executed: QEvent::MouseMove:case QEvent::MouseMove:never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||
| 209 | if (o == widget
| 0 | ||||||||||||||||||
| 210 | hideTip(); never executed: hideTip(); | 0 | ||||||||||||||||||
| 211 | default never executed: :default:never executed: default:code before this statement never executed: default: | 0 | ||||||||||||||||||
| 212 | break; never executed: break; | 0 | ||||||||||||||||||
| 213 | } | - | ||||||||||||||||||
| 214 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 215 | } | - | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | int QTipLabel::getTipScreen(const QPoint &pos, QWidget *w) | - | ||||||||||||||||||
| 218 | { | - | ||||||||||||||||||
| 219 | if (QApplication::desktop()->isVirtualDesktop()
| 0 | ||||||||||||||||||
| 220 | return never executed: QApplication::desktop()->screenNumber(pos);return QApplication::desktop()->screenNumber(pos);never executed: return QApplication::desktop()->screenNumber(pos); | 0 | ||||||||||||||||||
| 221 | else | - | ||||||||||||||||||
| 222 | return never executed: QApplication::desktop()->screenNumber(w);return QApplication::desktop()->screenNumber(w);never executed: return QApplication::desktop()->screenNumber(w); | 0 | ||||||||||||||||||
| 223 | } | - | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | void QTipLabel::placeTip(const QPoint &pos, QWidget *w) | - | ||||||||||||||||||
| 226 | { | - | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | if (testAttribute(Qt::WA_StyleSheet)
| 0 | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w)); | - | ||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | QTipLabel::instance->setStyleSheet(QLatin1String("/* */")); | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | QTipLabel::instance->styleSheetParent = w; | - | ||||||||||||||||||
| 236 | if (w
| 0 | ||||||||||||||||||
| 237 | connect(w, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "382"), | - | ||||||||||||||||||
| 238 | QTipLabel::instance, qFlagLocation("1""styleSheetParentDestroyed()" "\0" __FILE__ ":" "383")); | - | ||||||||||||||||||
| 239 | } never executed: end of block | 0 | ||||||||||||||||||
| 240 | } never executed: end of block | 0 | ||||||||||||||||||
| 241 | QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w)); | - | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | - | |||||||||||||||||||
| 244 | QPoint p = pos; | - | ||||||||||||||||||
| 245 | p += QPoint(2, | - | ||||||||||||||||||
| 246 | - | |||||||||||||||||||
| 247 | - | |||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | 16 | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | ); | - | ||||||||||||||||||
| 252 | if (p.x() + this->width() > screen.x() + screen.width()
| 0 | ||||||||||||||||||
| 253 | p.rx() -= 4 + this->width(); never executed: p.rx() -= 4 + this->width(); | 0 | ||||||||||||||||||
| 254 | if (p.y() + this->height() > screen.y() + screen.height()
| 0 | ||||||||||||||||||
| 255 | p.ry() -= 24 + this->height(); never executed: p.ry() -= 24 + this->height(); | 0 | ||||||||||||||||||
| 256 | if (p.y() < screen.y()
| 0 | ||||||||||||||||||
| 257 | p.setY(screen.y()); never executed: p.setY(screen.y()); | 0 | ||||||||||||||||||
| 258 | if (p.x() + this->width() > screen.x() + screen.width()
| 0 | ||||||||||||||||||
| 259 | p.setX(screen.x() + screen.width() - this->width()); never executed: p.setX(screen.x() + screen.width() - this->width()); | 0 | ||||||||||||||||||
| 260 | if (p.x() < screen.x()
| 0 | ||||||||||||||||||
| 261 | p.setX(screen.x()); never executed: p.setX(screen.x()); | 0 | ||||||||||||||||||
| 262 | if (p.y() + this->height() > screen.y() + screen.height()
| 0 | ||||||||||||||||||
| 263 | p.setY(screen.y() + screen.height() - this->height()); never executed: p.setY(screen.y() + screen.height() - this->height()); | 0 | ||||||||||||||||||
| 264 | this->move(p); | - | ||||||||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | bool QTipLabel::tipChanged(const QPoint &pos, const QString &text, QObject *o) | - | ||||||||||||||||||
| 268 | { | - | ||||||||||||||||||
| 269 | if (QTipLabel::instance->text() != text
| 0 | ||||||||||||||||||
| 270 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | if (o != widget
| 0 | ||||||||||||||||||
| 273 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | if (!rect.isNull()
| 0 | ||||||||||||||||||
| 276 | return never executed: !rect.contains(pos);return !rect.contains(pos);never executed: return !rect.contains(pos); | 0 | ||||||||||||||||||
| 277 | else | - | ||||||||||||||||||
| 278 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 279 | } | - | ||||||||||||||||||
| 280 | void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect) | - | ||||||||||||||||||
| 281 | { | - | ||||||||||||||||||
| 282 | showText(pos, text, w, rect, -1); | - | ||||||||||||||||||
| 283 | } never executed: end of block | 0 | ||||||||||||||||||
| 284 | void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecDisplayTime) | - | ||||||||||||||||||
| 285 | { | - | ||||||||||||||||||
| 286 | if (QTipLabel::instance
| 0 | ||||||||||||||||||
| 287 | if (text.isEmpty()
| 0 | ||||||||||||||||||
| 288 | QTipLabel::instance->hideTip(); | - | ||||||||||||||||||
| 289 | return; never executed: return; | 0 | ||||||||||||||||||
| 290 | } | - | ||||||||||||||||||
| 291 | else if (!QTipLabel::instance->fadingOut
| 0 | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | QPoint localPos = pos; | - | ||||||||||||||||||
| 295 | if (w
| 0 | ||||||||||||||||||
| 296 | localPos = w->mapFromGlobal(pos); never executed: localPos = w->mapFromGlobal(pos); | 0 | ||||||||||||||||||
| 297 | if (QTipLabel::instance->tipChanged(localPos, text, w)
| 0 | ||||||||||||||||||
| 298 | QTipLabel::instance->reuseTip(text, msecDisplayTime); | - | ||||||||||||||||||
| 299 | QTipLabel::instance->setTipRect(w, rect); | - | ||||||||||||||||||
| 300 | QTipLabel::instance->placeTip(pos, w); | - | ||||||||||||||||||
| 301 | } never executed: end of block | 0 | ||||||||||||||||||
| 302 | return; never executed: return; | 0 | ||||||||||||||||||
| 303 | } | - | ||||||||||||||||||
| 304 | } never executed: end of block | 0 | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | if (!text.isEmpty()
| 0 | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | new QTipLabel(text, w, msecDisplayTime); | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | QTipLabel::instance->setTipRect(w, rect); | - | ||||||||||||||||||
| 315 | QTipLabel::instance->placeTip(pos, w); | - | ||||||||||||||||||
| 316 | QTipLabel::instance->setObjectName(QLatin1String("qtooltip_label")); | - | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | - | |||||||||||||||||||
| 320 | if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)
| 0 | ||||||||||||||||||
| 321 | qFadeEffect(QTipLabel::instance); never executed: qFadeEffect(QTipLabel::instance); | 0 | ||||||||||||||||||
| 322 | else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)
| 0 | ||||||||||||||||||
| 323 | qScrollEffect(QTipLabel::instance); never executed: qScrollEffect(QTipLabel::instance); | 0 | ||||||||||||||||||
| 324 | else | - | ||||||||||||||||||
| 325 | QTipLabel::instance->showNormal(); never executed: QTipLabel::instance->showNormal(); | 0 | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | - | |||||||||||||||||||
| 328 | - | |||||||||||||||||||
| 329 | } | - | ||||||||||||||||||
| 330 | } never executed: end of block | 0 | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w) | - | ||||||||||||||||||
| 339 | { | - | ||||||||||||||||||
| 340 | QToolTip::showText(pos, text, w, QRect()); | - | ||||||||||||||||||
| 341 | } never executed: end of block | 0 | ||||||||||||||||||
| 342 | bool QToolTip::isVisible() | - | ||||||||||||||||||
| 343 | { | - | ||||||||||||||||||
| 344 | return never executed: (QTipLabel::instance != 0 && QTipLabel::instance->isVisible());return (QTipLabel::instance != 0 && QTipLabel::instance->isVisible());never executed: return (QTipLabel::instance != 0 && QTipLabel::instance->isVisible()); | 0 | ||||||||||||||||||
| 345 | } | - | ||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | QString QToolTip::text() | - | ||||||||||||||||||
| 354 | { | - | ||||||||||||||||||
| 355 | if (QTipLabel::instance
| 0 | ||||||||||||||||||
| 356 | return never executed: QTipLabel::instance->text();return QTipLabel::instance->text();never executed: return QTipLabel::instance->text(); | 0 | ||||||||||||||||||
| 357 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | namespace { namespace Q_QGS_tooltip_palette { typedef QPalette Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QPalette, Q_QGS_tooltip_palette::innerFunction, Q_QGS_tooltip_palette::guard> tooltip_palette;return &holder.value; | 0 | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | QPalette QToolTip::palette() | - | ||||||||||||||||||
| 370 | { | - | ||||||||||||||||||
| 371 | return never executed: *tooltip_palette();return *tooltip_palette();never executed: return *tooltip_palette(); | 0 | ||||||||||||||||||
| 372 | } | - | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | QFont QToolTip::font() | - | ||||||||||||||||||
| 380 | { | - | ||||||||||||||||||
| 381 | return never executed: QApplication::font("QTipLabel");return QApplication::font("QTipLabel");never executed: return QApplication::font("QTipLabel"); | 0 | ||||||||||||||||||
| 382 | } | - | ||||||||||||||||||
| 383 | void QToolTip::setPalette(const QPalette &palette) | - | ||||||||||||||||||
| 384 | { | - | ||||||||||||||||||
| 385 | *tooltip_palette() = palette; | - | ||||||||||||||||||
| 386 | if (QTipLabel::instance
| 0 | ||||||||||||||||||
| 387 | QTipLabel::instance->setPalette(palette); never executed: QTipLabel::instance->setPalette(palette); | 0 | ||||||||||||||||||
| 388 | } never executed: end of block | 0 | ||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | - | |||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | void QToolTip::setFont(const QFont &font) | - | ||||||||||||||||||
| 396 | { | - | ||||||||||||||||||
| 397 | QApplication::setFont(font, "QTipLabel"); | - | ||||||||||||||||||
| 398 | } never executed: end of block | 0 | ||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |