X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/101884841659cf7b1d735e894477415cddd1787f..2fd85facf85b39f84eeada10bcf80060bb72ab51:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 9369b3c77..3df25001c 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -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() @@ -1014,23 +1024,23 @@ void DolphinMainWindow::setupActions() closeTab->setEnabled(false); connect(closeTab, &QAction::triggered, m_tabWidget, static_cast(&DolphinTabWidget::closeTab)); - KStandardAction::quit(this, SLOT(quit()), actionCollection()); + KStandardAction::quit(this, &DolphinMainWindow::quit, actionCollection()); // setup 'Edit' menu KStandardAction::undo(this, - SLOT(undo()), + &DolphinMainWindow::undo, actionCollection()); - KStandardAction::cut(this, SLOT(cut()), actionCollection()); - KStandardAction::copy(this, SLOT(copy()), actionCollection()); - QAction* paste = KStandardAction::paste(this, SLOT(paste()), actionCollection()); + KStandardAction::cut(this, &DolphinMainWindow::cut, actionCollection()); + KStandardAction::copy(this, &DolphinMainWindow::copy, actionCollection()); + QAction* paste = KStandardAction::paste(this, &DolphinMainWindow::paste, actionCollection()); // The text of the paste-action is modified dynamically by Dolphin // (e. g. to "Paste One Folder"). To prevent that the size of the toolbar changes // due to the long text, the text "Paste" is used: paste->setIconText(i18nc("@action:inmenu Edit", "Paste")); - KStandardAction::find(this, SLOT(find()), actionCollection()); + KStandardAction::find(this, &DolphinMainWindow::find, actionCollection()); QAction* selectAll = actionCollection()->addAction(QStringLiteral("select_all")); selectAll->setText(i18nc("@action:inmenu Edit", "Select All")); @@ -1081,7 +1091,7 @@ void DolphinMainWindow::setupActions() connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation); // setup 'Go' menu - QAction* backAction = KStandardAction::back(this, SLOT(goBack()), actionCollection()); + QAction* backAction = KStandardAction::back(this, &DolphinMainWindow::goBack, actionCollection()); auto backShortcuts = backAction->shortcuts(); backShortcuts.append(QKeySequence(Qt::Key_Backspace)); actionCollection()->setDefaultShortcuts(backAction, backShortcuts); @@ -1105,9 +1115,9 @@ void DolphinMainWindow::setupActions() auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo)); undoAction->setEnabled(false); // undo should be disabled by default - KStandardAction::forward(this, SLOT(goForward()), actionCollection()); - KStandardAction::up(this, SLOT(goUp()), actionCollection()); - KStandardAction::home(this, SLOT(goHome()), actionCollection()); + KStandardAction::forward(this, &DolphinMainWindow::goForward, actionCollection()); + KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection()); + KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection()); // setup 'Tools' menu QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));