diff options
| author | David Hallas <[email protected]> | 2018-07-28 17:29:00 +0200 |
|---|---|---|
| committer | David Hallas <[email protected]> | 2018-08-24 12:09:26 +0200 |
| commit | 44a21ea51a055c7429ddee866e35b0a5a21c072b (patch) | |
| tree | 024226885442cdf341a660482efc29b4365dba3f /src/dolphinmainwindow.cpp | |
| parent | 79c485a66de7444e87708ae25c5f8a661a89dd21 (diff) | |
Unify window and tab title
Summary:
Previously the title of tabs was a prettyfied version of the URL.
This is inconsistent with the title of the Window and in some cases
for specials URLs kind of misleading. This commit generalizes the
code from DolphinMainWindow so that both the DolphinMainWindow title
and the tab title uses the same function for the title. This also
means that the 'Show Full Path in Title Bar' also applies to the
tab title, and also that searches changes the tab title.
FEATURE: 387851
Test Plan: Open a new tab from the places panel and navigate around.
Reviewers: #dolphin, ngraham, elvisangelaccio, markg
Reviewed By: #dolphin, ngraham, markg
Subscribers: markg, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D14442
Diffstat (limited to 'src/dolphinmainwindow.cpp')
| -rw-r--r-- | src/dolphinmainwindow.cpp | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 3b905b4d3..23894f346 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -25,7 +25,6 @@ #include "dolphindockwidget.h" #include "dolphincontextmenu.h" #include "dolphinnewfilemenu.h" -#include "dolphinplacesmodelsingleton.h" #include "dolphinrecenttabsmenu.h" #include "dolphintabwidget.h" #include "dolphinviewcontainer.h" @@ -49,7 +48,6 @@ #include <KAuthorized> #include <KConfig> #include <KFileItemListProperties> -#include <KFilePlacesModel> #include <KHelpMenu> #include <KIO/JobUiDelegate> #include <KIO/OpenFileManagerWindowJob> @@ -137,7 +135,7 @@ DolphinMainWindow::DolphinMainWindow() : connect(m_tabWidget, &DolphinTabWidget::tabCountChanged, this, &DolphinMainWindow::tabCountChanged); connect(m_tabWidget, &DolphinTabWidget::currentUrlChanged, - this, &DolphinMainWindow::setUrlAsCaption); + this, &DolphinMainWindow::updateWindowTitle); setCentralWidget(m_tabWidget); setupActions(); @@ -1001,46 +999,9 @@ void DolphinMainWindow::tabCountChanged(int count) actionCollection()->action(QStringLiteral("activate_prev_tab"))->setEnabled(enableTabActions); } -void DolphinMainWindow::setUrlAsCaption(const QUrl& url) +void DolphinMainWindow::updateWindowTitle() { - QString schemePrefix; - if (!url.isLocalFile()) { - schemePrefix.append(url.scheme() + " - "); - if (!url.host().isEmpty()) { - schemePrefix.append(url.host() + " - "); - } - } - - if (GeneralSettings::showFullPathInTitlebar()) { - const QString path = url.adjusted(QUrl::StripTrailingSlash).path(); - setWindowTitle(schemePrefix + path); - return; - } - - KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); - const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); - - if (!matchedPlaces.isEmpty()) { - setWindowTitle(placesModel->text(matchedPlaces.first())); - return; - } - - QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName(); - if (fileName.isEmpty()) { - fileName = '/'; - } - - if (m_activeViewContainer->isSearchModeEnabled()) { - if(m_activeViewContainer->currentSearchText().isEmpty()){ - setWindowTitle(i18n("Search")); - } else { - const auto searchText = i18n("Search for %1", m_activeViewContainer->currentSearchText()); - setWindowTitle(searchText); - } - return; - } - - setWindowTitle(schemePrefix + fileName); + setWindowTitle(m_activeViewContainer->getCaption()); } void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath) @@ -1506,7 +1467,7 @@ void DolphinMainWindow::refreshViews() const bool splitView = GeneralSettings::splitView(); m_tabWidget->currentTabPage()->setSplitViewEnabled(splitView); updateSplitAction(); - setUrlAsCaption(activeViewContainer()->url()); + updateWindowTitle(); } emit settingsChanged(); |
