Bug 407004

Summary: Request: add right-click option to copy file path inDolphin
Product: [Applications] dolphin Reporter: David <david.cortes.rivera>
Component: generalAssignee: Dolphin Bug Assignee <dolphin-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: bizyaev, elvis.angelaccio, nate, vojtech
Priority: NOR Keywords: usability
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=423937
Latest Commit: Version Fixed In: 20.08.0

Description David 2019-04-28 09:19:14 UTC
Other file managers have a right-click option to copy the full path of a file (including the file name), which I think is a basic and handy functionality that Dolphin could also use.

There are some extensions for Dolphin in KDE store that can add this functionality, but since the frameworks and APIs are constantly changing, they all become outdated and stop working after some time.

As this is a common option, would be nice to have it in base Dolphin by default.

The following would, as of 2019-04-28 with Dolphin 18.08 in X.org, add such option when saved in a .desktop file:


[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin,inode/directory,inode/directory-locked,inode/directory-hidden
MimeType=application/octet-stream;inode/directory
Actions=CopyPath
X-KDE-Priority=TopLevel

[Desktop Action CopyPath]
Name=Copy Path
Exec=dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.setClipboardContents string:"%u"
Comment 1 Elvis Angelaccio 2019-04-28 10:45:08 UTC
You can press CTRL+C to copy the full path to the clipbpoard. Doesn't that work for you?
Comment 2 David 2019-04-28 12:08:16 UTC
(In reply to Elvis Angelaccio from comment #1)
> You can press CTRL+C to copy the full path to the clipbpoard. Doesn't that
> work for you?

Ctrl + C copies the full file, so in some scenarios it can paste the wrong thing (e.g. you cannot paste a file name as a new text file in Dolphin). Also it adds "file://".
Comment 3 Nate Graham 2019-04-30 15:40:21 UTC
Yeah, the fact that pasting a full file actually pastes the  the path it in some apps is an implementation detail/quirk of the fact that those apps don't handle file-based clipboard data.
Comment 4 Nate Graham 2019-04-30 15:40:52 UTC
Would you care to submit a patch, David? Or a file action plugin with this in it?
Comment 5 David 2019-04-30 15:51:35 UTC
(In reply to Nate Graham from comment #4)
> Would you care to submit a patch, David? Or a file action plugin with this
> in it?

I’m not really a programmer and would have no idea how to do that. I composed the text above by copy-pastying advice I found in some forums and other things I googled, but other than creating yet another dolphin extension in kdestore that might break after a couple months, I don’t know how to integrate it into Dolphin in a way that could survive simple API changes.
Comment 6 Nate Graham 2019-07-16 15:39:18 UTC
*** Bug 409828 has been marked as a duplicate of this bug. ***
Comment 7 Nate Graham 2019-07-16 15:40:32 UTC
I've found myself wanting this various times recently. Maybe adding a modifier key could do it, like we do to toggle between "move to trash" and "delete". Like Ctrl-Alt-C could do "Copy path to clipboard"
Comment 8 Elvis Angelaccio 2020-06-21 22:44:26 UTC
As discussed in https://invent.kde.org/system/dolphin/-/merge_requests/25, this should be fixed in Qt (QMimeData precisely).
Comment 9 Elvis Angelaccio 2020-06-29 21:24:21 UTC
(In reply to Elvis Angelaccio from comment #8)
> As discussed in https://invent.kde.org/system/dolphin/-/merge_requests/25,
> this should be fixed in Qt (QMimeData precisely).

Actually this wouldn't solve the "paste the location to dolphin" use case. Reopening.
Comment 10 Elvis Angelaccio 2020-06-29 22:27:37 UTC
Git commit 86e3b82efbbcdb287773cdaf6a5f4c1c22bb9fc6 by Elvis Angelaccio, on behalf of Yann Holme-Nielsen.
Committed on 29/06/2020 at 22:27.
Pushed by elvisangelaccio into branch 'master'.

## 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.

M  +4    -1    src/dolphincontextmenu.cpp
M  +4    -0    src/dolphinmainwindow.cpp
M  +10   -1    src/dolphinui.rc
M  +18   -0    src/views/dolphinview.cpp
M  +5    -0    src/views/dolphinview.h
M  +16   -1    src/views/dolphinviewactionhandler.cpp
M  +5    -0    src/views/dolphinviewactionhandler.h

https://invent.kde.org/system/dolphin/commit/86e3b82efbbcdb287773cdaf6a5f4c1c22bb9fc6
Comment 11 Ilya Bizyaev 2020-07-04 06:10:45 UTC
Looking at "Copy" and "Copy Location" one after the other, with the same icon, I wonder how many users are going to be confused by this addition.
Comment 12 Nate Graham 2020-07-06 16:17:51 UTC
Yes, we probably need a new icon for "Copy Location", especially now that multiple apps (Dolphin and Konsole) both have this menu item.

Heck, we could even define a KStandardAction for it.