From 86e3b82efbbcdb287773cdaf6a5f4c1c22bb9fc6 Mon Sep 17 00:00:00 2001 From: Yann Holme-Nielsen Date: Mon, 29 Jun 2020 22:27:33 +0000 Subject: ## Summary * Adds a "Copy location" item, after the "Copy" Context item and Edit Menu, which will attempt to copy the path of the fist item into clipboard. ## Reasoning Most File Managers have this option through one or another way. Also using the default Copy option often results in different behaviour depending on the target software, Konsole will take the path. Other Programs will use the URI. Which ultimately could lead to non optimal User Experience. ## Notes * Should the target file **not** be on a local hard drive, this fallback to using the remote URL, feedback is wanted on that matter. FEATURE: 407004 --- src/views/dolphinviewactionhandler.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/views/dolphinviewactionhandler.cpp') diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index e89e2e62c..29bd530b4 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -34,7 +34,6 @@ #include #include #include - #include #include @@ -156,6 +155,17 @@ void DolphinViewActionHandler::createActions() m_actionCollection->setDefaultShortcuts(propertiesAction, {Qt::ALT + Qt::Key_Return, Qt::ALT + Qt::Key_Enter}); connect(propertiesAction, &QAction::triggered, this, &DolphinViewActionHandler::slotProperties); + QAction *copyPathAction = m_actionCollection->addAction( QStringLiteral("copy_location") ); + copyPathAction->setText(i18nc("@action:incontextmenu", "Copy location")); + copyPathAction->setWhatsThis(i18nc("@info:whatsthis copy_location", + "This will copy the path of the first selected item into the clipboard." + )); + + copyPathAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy"))); + m_actionCollection->setDefaultShortcuts(copyPathAction, {Qt::CTRL + Qt::SHIFT + Qt::Key_C}); + connect(copyPathAction, &QAction::triggered, this, &DolphinViewActionHandler::slotCopyPath); + + // View menu KToggleAction* iconsAction = iconsModeAction(); KToggleAction* compactAction = compactModeAction(); @@ -709,3 +719,8 @@ void DolphinViewActionHandler::slotProperties() dialog->raise(); dialog->activateWindow(); } + +void DolphinViewActionHandler::slotCopyPath() +{ + m_currentView->copyPathToClipboard(); +} -- cgit v1.3