]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Middle-elide file/folder labels so the extension is always visible
authorNate Graham <nate@kde.org>
Sat, 2 Mar 2019 13:00:34 +0000 (06:00 -0700)
committerNate Graham <nate@kde.org>
Sat, 24 Aug 2019 18:44:56 +0000 (12:44 -0600)
Summary:
This ensures that the filename extension is always visible, and also is just a
nicer way to elide file and folder names in general.

BUG: 404955
FIXED-IN: 19.12.0

Test Plan:
Details view: {F6648784}
Icons view with limited label height: {F6648785}

Reviewers: #dolphin, #vdg, elvisangelaccio, GB_2

Reviewed By: #dolphin, #vdg, elvisangelaccio, GB_2

Subscribers: GB_2, ndavis, rooty, elvisangelaccio, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D19471

src/kitemviews/kstandarditemlistwidget.cpp

index 15c01726fa8b972775d71880bee0ca4cc7298f2d..296cd9bbbfbbbfabce6d14436d914c37411ae103 100644 (file)
@@ -1165,7 +1165,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
                 do {
                     QString lastTextLine = nameText.mid(line.textStart());
                     lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
-                                                                      Qt::ElideRight,
+                                                                      Qt::ElideMiddle,
                                                                       elidingWidth);
                     const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
                     nameTextInfo->staticText.setText(elidedText);
@@ -1221,7 +1221,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
             textLine.setLineWidth(maxWidth);
             requiredWidth = textLine.naturalTextWidth();
             if (requiredWidth > maxWidth) {
-                const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideRight, maxWidth);
+                const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideMiddle, maxWidth);
                 textInfo->staticText.setText(elidedText);
                 requiredWidth = m_customizedFontMetrics.width(elidedText);
             } else if (role == "rating") {
@@ -1270,7 +1270,7 @@ void KStandardItemListWidget::updateCompactLayoutTextCache()
         qreal requiredWidth = m_customizedFontMetrics.width(text);
         if (requiredWidth > maxWidth) {
             requiredWidth = maxWidth;
-            const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideRight, maxWidth);
+            const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideMiddle, maxWidth);
             textInfo->staticText.setText(elidedText);
         }
 
@@ -1327,7 +1327,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
         }
 
         if (requiredWidth > availableTextWidth) {
-            text = m_customizedFontMetrics.elidedText(text, Qt::ElideRight, availableTextWidth);
+            text = m_customizedFontMetrics.elidedText(text, Qt::ElideMiddle, availableTextWidth);
             requiredWidth = m_customizedFontMetrics.width(text);
         }