From 3a019a9662c8ba5d321566cc6aeebb6cfc01c225 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 17 Aug 2022 20:27:29 +0200 Subject: [PATCH] Notifications: Don't use place for paths under root This avoids showing paths like /tmp/somefile as "500 GiB Internal Hard Drive/tmp/somefile", or "Root/tmp/somefile". It's more sensible to show the actual path in this case. --- libnotificationmanager/job_p.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libnotificationmanager/job_p.cpp b/libnotificationmanager/job_p.cpp index c86da354d..6a89f9c69 100644 --- a/libnotificationmanager/job_p.cpp +++ b/libnotificationmanager/job_p.cpp @@ -114,12 +114,18 @@ QString JobPrivate::prettyUrl(const QUrl &_url) const QString pathInsidePlace = url.path().mid(placeUrl.path().length()); - if (!pathInsidePlace.isEmpty() && !pathInsidePlace.startsWith(QLatin1Char('/'))) { + if (!pathInsidePlace.startsWith(QLatin1Char('/'))) { pathInsidePlace.prepend(QLatin1Char('/')); } if (pathInsidePlace != QLatin1Char('/')) { - text.append(pathInsidePlace); + // Avoid "500 GiB Internal Hard Drive/foo/bar" when path originates directly from root. + const bool isRoot = placeUrl.isLocalFile() && placeUrl.path() == QLatin1Char('/'); + if (isRoot) { + text = pathInsidePlace; + } else { + text.append(pathInsidePlace); + } } return text;