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.
wilder-5.26
Kai Uwe Broulik 4 years ago
parent c18d69c26a
commit 3a019a9662
  1. 10
      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;

Loading…
Cancel
Save