Commit 248030db authored by Harald Sitter's avatar Harald Sitter 🏳️‍🌈
Browse files

correctly calculate fontmetrics

- use the fontmetrics of the target label not the application (makes no
difference but is practically more correct)
- use horizontalAdvance instead of boundingrect width. the latter is
relative to the rect coordinates and as such not nearly as straight
forward to use. horizontaladvance is the actual width the text will
occupy, it's what we intend to know here

BUG: 431447
parent e873c3bf
Pipeline #168769 passed with stage
in 2 minutes and 37 seconds
......@@ -808,12 +808,12 @@ void RadialMap::Item::hoverMoveEvent(QHoverEvent *e)
string += i18n("\nClick to go up to parent directory");
}
// Calculate a semi-sane size for the tooltip
QFontMetrics fontMetrics(QGuiApplication::font());
QFontMetrics fontMetrics(m_tooltip.fontMetrics());
int tooltipWidth = 0;
int tooltipHeight = 0;
for (const QString &part : string.split(QLatin1Char('\n'))) {
tooltipHeight += fontMetrics.height();
tooltipWidth = qMax(tooltipWidth, fontMetrics.boundingRect(part).width());
tooltipWidth = qMax(tooltipWidth, fontMetrics.horizontalAdvance(part));
}
tooltipWidth += 10;
tooltipHeight += 10;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment