]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinQuery: Use prettier URL particularly for local paths
authorKai Uwe Broulik <kde@privat.broulik.de>
Thu, 5 Jun 2025 19:07:57 +0000 (21:07 +0200)
committerKai Uwe Broulik <kde@privat.broulik.de>
Thu, 5 Jun 2025 19:13:55 +0000 (21:13 +0200)
Use toLocalFile() to avoid the 'file://' prefix and use KShell::tildeCollapse
that collapses the home path into ~ as is done in many other places.

Also strip trailing slash for the other URLs.

src/search/dolphinquery.cpp

index e23f1f08e9cbe7c1a6ffda9dae479925a1b63979..100bac4d078004131a859a7d69cb94c9c2738de5 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <KFileMetaData/TypeInfo>
 #include <KLocalizedString>
+#include <KShell>
 
 #include <QRegularExpression>
 #include <QUrlQuery>
@@ -366,7 +367,11 @@ QString DolphinQuery::title() const
             prettySearchLocation = m_searchPath.fileName();
         }
         if (prettySearchLocation.isEmpty()) {
-            prettySearchLocation = m_searchPath.toString(QUrl::RemoveAuthority);
+            if (m_searchPath.isLocalFile()) {
+                prettySearchLocation = KShell::tildeCollapse(m_searchPath.adjusted(QUrl::StripTrailingSlash).toLocalFile());
+            } else {
+                prettySearchLocation = m_searchPath.toString(QUrl::RemoveAuthority | QUrl::StripTrailingSlash);
+            }
         }
 
         // A great title clearly identifies a search results page among many tabs, windows, or links in the Places panel.