diff --git a/src/dolphinbookmarkhandler.cpp b/src/dolphinbookmarkhandler.cpp --- a/src/dolphinbookmarkhandler.cpp +++ b/src/dolphinbookmarkhandler.cpp @@ -121,7 +121,7 @@ QString DolphinBookmarkHandler::title(DolphinViewContainer* viewContainer) { - return viewContainer->caption(); + return viewContainer->caption(DolphinViewContainer::BookmarkHandlerTitleCall); } QUrl DolphinBookmarkHandler::url(DolphinViewContainer* viewContainer) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1269,7 +1269,7 @@ void DolphinMainWindow::updateWindowTitle() { - const QString newTitle = m_activeViewContainer->caption(); + const QString newTitle = m_activeViewContainer->caption(DolphinViewContainer::WindowTitleCall); if (windowTitle() != newTitle) { setWindowTitle(newTitle); } diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -120,7 +120,7 @@ { // Left-elision is better when showing full paths, since you care most // about the current directory which is on the right - if (GeneralSettings::showFullPathInTitlebar()) { + if (GeneralSettings::showFullPathInTitlebar() || GeneralSettings::showFullPathInTabName()) { setElideMode(Qt::ElideLeft); } else { setElideMode(Qt::ElideRight); @@ -425,7 +425,8 @@ if (!tabPage) { return QString(); } - QString name = tabPage->activeViewContainer()->caption(); + QString name = tabPage->activeViewContainer()->caption(DolphinViewContainer::TabNameCall); + // Make sure that a '&' inside the directory name is displayed correctly // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText() return name.replace('&', QLatin1String("&&")); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -69,6 +69,13 @@ Error }; + enum CaptionCallFrom + { + BookmarkHandlerTitleCall, + WindowTitleCall, + TabNameCall + }; + DolphinViewContainer(const QUrl& url, QWidget* parent); ~DolphinViewContainer() override; @@ -138,7 +145,7 @@ * calculated depending on settings, if a search is active and other * factors. */ - QString caption() const; + QString caption(CaptionCallFrom callFrom) const; public slots: /** diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -449,9 +449,12 @@ m_messageWidget->hide(); } -QString DolphinViewContainer::caption() const +QString DolphinViewContainer::caption(CaptionCallFrom callFrom) const { - if (GeneralSettings::showFullPathInTitlebar()) { + if ((GeneralSettings::showFullPathInTitlebar() && GeneralSettings::showFullPathInTabName()) + || (GeneralSettings::showFullPathInTitlebar() && callFrom == WindowTitleCall) + || (GeneralSettings::showFullPathInTabName() && callFrom == TabNameCall) + ) { if (!url().isLocalFile()) { return url().adjusted(QUrl::StripTrailingSlash).toString(); } diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -26,6 +26,10 @@ false + + + false + true diff --git a/src/settings/startup/startupsettingspage.h b/src/settings/startup/startupsettingspage.h --- a/src/settings/startup/startupsettingspage.h +++ b/src/settings/startup/startupsettingspage.h @@ -64,6 +64,7 @@ QCheckBox* m_showFullPath; QCheckBox* m_filterBar; QCheckBox* m_showFullPathInTitlebar; + QCheckBox* m_showFullPathInTabName; QCheckBox* m_openExternallyCalledFolderInNewTab; }; diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -44,6 +44,7 @@ m_showFullPath(nullptr), m_filterBar(nullptr), m_showFullPathInTitlebar(nullptr), + m_showFullPathInTabName(nullptr), m_openExternallyCalledFolderInNewTab(nullptr) { QFormLayout* topLayout = new QFormLayout(this); @@ -101,18 +102,20 @@ topLayout->addRow(QString(), m_filterBar); m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); topLayout->addRow(QString(), m_showFullPathInTitlebar); + m_showFullPathInTabName = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in tab title")); + topLayout->addRow(QString(), m_showFullPathInTabName); m_openExternallyCalledFolderInNewTab = new QCheckBox(i18nc("@option:check Startup Settings", "Open new folders in tabs")); topLayout->addRow(QString(), m_openExternallyCalledFolderInNewTab); - loadSettings(); connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); + connect(m_showFullPathInTabName, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); connect(m_openExternallyCalledFolderInNewTab, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); } @@ -137,6 +140,7 @@ settings->setShowFullPath(m_showFullPath->isChecked()); settings->setFilterBar(m_filterBar->isChecked()); settings->setShowFullPathInTitlebar(m_showFullPathInTitlebar->isChecked()); + settings->setShowFullPathInTabName(m_showFullPathInTabName->isChecked()); settings->setOpenExternallyCalledFolderInNewTab(m_openExternallyCalledFolderInNewTab->isChecked()); settings->save(); } @@ -187,5 +191,6 @@ m_showFullPath->setChecked(GeneralSettings::showFullPath()); m_filterBar->setChecked(GeneralSettings::filterBar()); m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar()); + m_showFullPathInTabName->setChecked(GeneralSettings::showFullPathInTabName()); m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab()); }