summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qtooltip.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 2e6575c163..b9d8758fe0 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -214,7 +214,6 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint
}
#endif
- setWordWrap(true);
setText(text);
updateSize(pos);
restartExpireTimer(msecDisplayTime);
@@ -227,19 +226,16 @@ 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()) {
- 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()));
- }
+ 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);