┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp18
-rw-r--r--src/views/dolphinview.h5
-rw-r--r--src/views/dolphinviewactionhandler.cpp17
-rw-r--r--src/views/dolphinviewactionhandler.h5
4 files changed, 44 insertions, 1 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 9af691927..54f2f721d 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -1949,3 +1949,21 @@ void DolphinView::forceUrlsSelection(const QUrl& current, const QList<QUrl>& sel
markUrlAsCurrent(current);
markUrlsAsSelected(selected);
}
+
+void DolphinView::copyPathToClipboard()
+{
+ const KFileItemList list = selectedItems();
+ if (list.isEmpty()) {
+ return;
+ }
+ const KFileItem& item = list.at(0);
+ QString path = item.localPath();
+ if (path.isEmpty()) {
+ path = item.url().toDisplayString();
+ }
+ QClipboard* clipboard = QApplication::clipboard();
+ if (clipboard == nullptr) {
+ return;
+ }
+ clipboard->setText(path);
+}
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 4306b3eb7..91203b8e0 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -391,6 +391,11 @@ public slots:
void pasteIntoFolder();
/**
+ * Copies the path of the first selected KFileItem into Clipboard.
+ */
+ void copyPathToClipboard();
+
+ /**
* Creates duplicates of selected items, appending "copy"
* to the end.
*/
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 <KNewFileMenu>
#include <KPropertiesDialog>
#include <KProtocolManager>
-
#include <QMenu>
#include <QPointer>
@@ -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();
+}
diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h
index 3228e7364..d6b0d3b84 100644
--- a/src/views/dolphinviewactionhandler.h
+++ b/src/views/dolphinviewactionhandler.h
@@ -219,6 +219,11 @@ private Q_SLOTS:
*/
void slotProperties();
+ /**
+ * Copies the path of the first selected KFileItem into Clipboard.
+ */
+ void slotCopyPath();
+
private:
/**
* Create all the actions.