diff options
| author | Yann Holme-Nielsen <[email protected]> | 2020-06-29 22:27:33 +0000 |
|---|---|---|
| committer | Elvis Angelaccio <[email protected]> | 2020-06-29 22:27:33 +0000 |
| commit | 86e3b82efbbcdb287773cdaf6a5f4c1c22bb9fc6 (patch) | |
| tree | 7ce105d0ca28e4de8e019bc3dd36a050a5c05013 /src/views/dolphinview.cpp | |
| parent | d1baf3398e53931735b724672d5ae48649b44a18 (diff) | |
## 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
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 18 |
1 files changed, 18 insertions, 0 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); +} |
