]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix file names overflowing after text eliding
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>
Mon, 23 Jun 2025 12:26:49 +0000 (15:26 +0300)
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>
Mon, 23 Jun 2025 12:26:49 +0000 (15:26 +0300)
When QFontMetrics::boundingRect().width was replaced with QFontMetrics::horizontalAdvance() in 76a46fd9094b17eb99e8a42cca8562fdc0b3814c, an extra line (formerly introduced by a203c271161ce953354b9e0722492605a4d17415) was changed as well.

Unfortunately, boundingRect().width is the correct function to use for calculating the size of the last line, while horizontalAdvance would be correct if we were laying it next to the previous line instead of below the previous line.

BUG: 432530

src/kitemviews/kstandarditemlistwidget.cpp

index d078b06573f3f5a35a3d0fba3b1699cc29a6acf9..2538cddcf6973fac086b3fed50fea7ef79b19f54 100644 (file)
@@ -1334,7 +1334,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
                     const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
                     nameTextInfo->staticText.setText(elidedText);
 
-                    lastLineWidth = m_customizedFontMetrics.horizontalAdvance(lastTextLine);
+                    lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
 
                     // We do the text eliding in a loop with decreasing width (1 px / iteration)
                     // to avoid problems related to different width calculation code paths