┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2017-08-29 17:15:24 +0200
committerKai Uwe Broulik <[email protected]>2017-08-29 17:15:24 +0200
commit652f57d28152491c42ad740d2bacd12a12d3d3d7 (patch)
treed41088c48978f8058995e7333404cc4838adc021 /src/dolphinmainwindow.cpp
parent8be1e2aa07333ffbc4555f89e20461f580dc465c (diff)
Prefer place name over actual name in title bar
When inside a place, the address bar already gives it precedence over the actual folder name. By doing this in the title bar also, we make it consistent and can mask ugly technical terminology like "trash:/" and instead show the nice localized "Trash" place name as well as "Home" instead of lowercase internal user name. BUG: 211959 Differential Revision: https://phabricator.kde.org/D4826
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index ff834700b..3df25001c 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -62,6 +62,7 @@
#include <KProtocolInfo>
#include <QMenu>
#include <KMessageBox>
+#include <KFilePlacesModel>
#include <KFileItemListProperties>
#include <KRun>
#include <KShell>
@@ -962,26 +963,35 @@ void DolphinMainWindow::tabCountChanged(int count)
void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
{
- QString caption;
+ static KFilePlacesModel s_placesModel;
+
+ QString schemePrefix;
if (!url.isLocalFile()) {
- caption.append(url.scheme() + " - ");
+ schemePrefix.append(url.scheme() + " - ");
if (!url.host().isEmpty()) {
- caption.append(url.host() + " - ");
+ schemePrefix.append(url.host() + " - ");
}
}
if (GeneralSettings::showFullPathInTitlebar()) {
const QString path = url.adjusted(QUrl::StripTrailingSlash).path();
- caption.append(path);
- } else {
- QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
- if (fileName.isEmpty()) {
- fileName = '/';
- }
- caption.append(fileName);
+ setWindowTitle(schemePrefix + path);
+ return;
+ }
+
+ const auto& matchedPlaces = s_placesModel.match(s_placesModel.index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
+
+ if (!matchedPlaces.isEmpty()) {
+ setWindowTitle(s_placesModel.text(matchedPlaces.first()));
+ return;
+ }
+
+ QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName();
+ if (fileName.isEmpty()) {
+ fileName = '/';
}
- setWindowTitle(caption);
+ setWindowTitle(schemePrefix + fileName);
}
void DolphinMainWindow::setupActions()