diff options
| author | Paul Wicking <paul.wicking@qt.io> | 2019-02-01 13:33:25 +0100 |
|---|---|---|
| committer | Paul Wicking <paul.wicking@qt.io> | 2019-02-01 13:33:26 +0100 |
| commit | 2bc362c9fa37455afbeb56e5f1852188ede3eab4 (patch) | |
| tree | b89e3c2c082a0285e8cd91733ddbc772fe4362a5 /src/widgets/kernel/qtooltip.cpp | |
| parent | 5de981d3bc3df874f9df35a6899345f4f61fa951 (diff) | |
| parent | 481db443d502c8ebc169b7256cb696428cf02199 (diff) | |
Merge dev into 5.13
Change-Id: I8113c6d8735a151bd152e6096f8c8b8e63a05474
Diffstat (limited to 'src/widgets/kernel/qtooltip.cpp')
| -rw-r--r-- | src/widgets/kernel/qtooltip.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 9d8b0062f55..cf0f3f153b6 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -216,7 +216,6 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint } #endif - setWordWrap(true); setText(text); updateSize(pos); restartExpireTimer(msecDisplayTime); @@ -235,20 +234,17 @@ void QTipLabel::updateSize(const QPoint &pos) // Make it look good with the default ToolTip font on Mac, which has a small descent. if (fm.descent() == 2 && fm.ascent() >= 11) ++extra.rheight(); + setWordWrap(Qt::mightBeRichText(text())); QSize sh = sizeHint(); - if (wordWrap()) { - // ### When the above WinRT code is fixed, windowhandle should be used to find the screen. - QScreen *screen = QGuiApplication::screenAt(pos); - if (!screen) - screen = QGuiApplication::primaryScreen(); - if (screen) { - const qreal screenWidth = screen->geometry().width(); - if (sh.width() > screenWidth) { - // Try to use widely accepted 75chars max length or 80% of the screen width else. - // See https://en.wikipedia.org/wiki/Line_length - sh.setWidth(qMin(fm.averageCharWidth() * 75, static_cast<int>(screenWidth * .8))); - sh.setHeight(heightForWidth(sh.width())); - } + // ### When the above WinRT code is fixed, windowhandle should be used to find the screen. + QScreen *screen = QGuiApplication::screenAt(pos); + if (!screen) + screen = QGuiApplication::primaryScreen(); + if (screen) { + const qreal screenWidth = screen->geometry().width(); + if (!wordWrap() && sh.width() > screenWidth) { + setWordWrap(true); + sh = sizeHint(); } } resize(sh + extra); |
