┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorRoman Inflianskas <[email protected]>2018-03-18 13:55:24 +0300
committerRoman Inflianskas <[email protected]>2018-03-18 15:08:36 +0300
commit6f05c66cc0d2416a21fd8eaff0ec6e7a9161d59c (patch)
tree5359826c922bbf9fbb6ce1de36c14489e54146f4 /src/dolphinmainwindow.cpp
parenteb68fae15cdbf15e894d1a9d555c88d306261cc2 (diff)
Add "Show Target" into symlink context menu and file menu
Summary: Add "Show Target" into symlink context menu and file menu FEATURE: 215069 Reviewers: ngraham, elvisangelaccio Reviewed By: ngraham, elvisangelaccio Subscribers: rkflx, ngraham, elvisangelaccio, markg, #dolphin Differential Revision: https://phabricator.kde.org/D10990
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index c5067fe0e..b09d7deef 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -357,6 +357,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 <filename>%1</filename>.", linkDestination),
+ DolphinViewContainer::Warning);
+ }
+}
+
void DolphinMainWindow::showEvent(QShowEvent* event)
{
KXmlGuiWindow::showEvent(event);
@@ -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());
}
}