X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/86f4fcb8cd574f6d886627fc5e01c9edfc84e977..e0f7fe87bdc2e32778cd6ce997b59b883cb245b8:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index c5067fe0e..d112007bc 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -25,6 +25,7 @@ #include "dolphindockwidget.h" #include "dolphincontextmenu.h" #include "dolphinnewfilemenu.h" +#include "dolphinplacesmodelsingleton.h" #include "dolphinrecenttabsmenu.h" #include "dolphintabwidget.h" #include "dolphinviewcontainer.h" @@ -357,6 +358,22 @@ void DolphinMainWindow::openInNewWindow() } } +void DolphinMainWindow::showTarget() +{ + const auto link = m_activeViewContainer->view()->selectedItems().at(0); + const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir(); + auto linkDestination = link.linkDest(); + if (QFileInfo(linkDestination).isRelative()) { + linkDestination = linkLocationDir.filePath(linkDestination); + } + if (QFileInfo::exists(linkDestination)) { + KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)}); + } else { + m_activeViewContainer->showMessage(xi18nc("@info", "Could not access %1.", linkDestination), + DolphinViewContainer::Warning); + } +} + void DolphinMainWindow::showEvent(QShowEvent* event) { KXmlGuiWindow::showEvent(event); @@ -977,8 +994,6 @@ void DolphinMainWindow::tabCountChanged(int count) void DolphinMainWindow::setUrlAsCaption(const QUrl& url) { - static KFilePlacesModel s_placesModel; - QString schemePrefix; if (!url.isLocalFile()) { schemePrefix.append(url.scheme() + " - "); @@ -993,10 +1008,11 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url) return; } - const auto& matchedPlaces = s_placesModel.match(s_placesModel.index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); + KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); + const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); if (!matchedPlaces.isEmpty()) { - setWindowTitle(s_placesModel.text(matchedPlaces.first())); + setWindowTitle(placesModel->text(matchedPlaces.first())); return; } @@ -1215,23 +1231,11 @@ void DolphinMainWindow::setupActions() actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys); // for context menu - QAction* showOriginal = actionCollection()->addAction(QStringLiteral("show_original")); - showOriginal->setText(i18nc("@action:inmenu", "Show Original")); - showOriginal->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder"))); - showOriginal->setEnabled(false); - connect(showOriginal, &QAction::triggered, [this]() { - const auto link = m_activeViewContainer->view()->selectedItems().at(0); - const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir(); - auto linkDestination = link.linkDest(); - if (QFileInfo(linkDestination).isRelative()) - linkDestination = linkLocationDir.filePath(linkDestination); - if (QFileInfo(linkDestination).exists()) { - KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)}); - } else { - m_activeViewContainer->showMessage( - i18n("Could not access \"%1\".").arg(linkDestination), DolphinViewContainer::Warning); - } - }); + QAction* showTarget = actionCollection()->addAction(QStringLiteral("show_target")); + showTarget->setText(i18nc("@action:inmenu", "Show Target")); + showTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder"))); + showTarget->setEnabled(false); + connect(showTarget, &QAction::triggered, this, &DolphinMainWindow::showTarget); QAction* openInNewTab = actionCollection()->addAction(QStringLiteral("open_in_new_tab")); openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab")); @@ -1398,7 +1402,7 @@ void DolphinMainWindow::updateEditActions() QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile)); QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut)); QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler - QAction* showOriginal = col->action(QStringLiteral("show_original")); + QAction* showTarget = col->action(QStringLiteral("show_target")); KFileItemListProperties capabilities(list); const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); @@ -1408,7 +1412,7 @@ void DolphinMainWindow::updateEditActions() deleteAction->setEnabled(capabilities.supportsDeleting()); deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash); cutAction->setEnabled(capabilities.supportsMoving()); - showOriginal->setEnabled(list.length() == 1 && list.at(0).isLink()); + showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); } }