Skip to content

Commit 7d7d303

Browse files
committed
Merge pull request godotengine#90421 from Krigu/add_option_copy_absolute_path_to_file_system_dock_popup
Add option to copy absolute path in file system dock popup
2 parents 0d50f45 + 5c1d1ea commit 7d7d303

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

editor/filesystem_dock.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,14 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
25312531
}
25322532
} break;
25332533

2534+
case FILE_COPY_ABSOLUTE_PATH: {
2535+
if (!p_selected.is_empty()) {
2536+
const String &fpath = p_selected[0];
2537+
const String absolute_path = ProjectSettings::get_singleton()->globalize_path(fpath);
2538+
DisplayServer::get_singleton()->clipboard_set(absolute_path);
2539+
}
2540+
} break;
2541+
25342542
case FILE_COPY_UID: {
25352543
if (!p_selected.is_empty()) {
25362544
ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_selected[0]);
@@ -3193,6 +3201,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
31933201

31943202
if (p_paths.size() == 1) {
31953203
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH);
3204+
p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_absolute_path"), FILE_COPY_ABSOLUTE_PATH);
31963205
if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) {
31973206
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID);
31983207
}
@@ -3481,6 +3490,8 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
34813490
_tree_rmb_option(FILE_DUPLICATE);
34823491
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) {
34833492
_tree_rmb_option(FILE_COPY_PATH);
3493+
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_absolute_path", p_event)) {
3494+
_tree_rmb_option(FILE_COPY_ABSOLUTE_PATH);
34843495
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_uid", p_event)) {
34853496
_tree_rmb_option(FILE_COPY_UID);
34863497
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) {
@@ -3553,6 +3564,8 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
35533564
_file_list_rmb_option(FILE_DUPLICATE);
35543565
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) {
35553566
_file_list_rmb_option(FILE_COPY_PATH);
3567+
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_absolute_path", p_event)) {
3568+
_file_list_rmb_option(FILE_COPY_ABSOLUTE_PATH);
35563569
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) {
35573570
_file_list_rmb_option(FILE_REMOVE);
35583571
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) {
@@ -3856,6 +3869,7 @@ FileSystemDock::FileSystemDock() {
38563869

38573870
// `KeyModifierMask::CMD_OR_CTRL | Key::C` conflicts with other editor shortcuts.
38583871
ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C);
3872+
ED_SHORTCUT("filesystem_dock/copy_absolute_path", TTR("Copy Absolute Path"));
38593873
ED_SHORTCUT("filesystem_dock/copy_uid", TTR("Copy UID"));
38603874
ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KeyModifierMask::CMD_OR_CTRL | Key::D);
38613875
ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), Key::KEY_DELETE);

editor/filesystem_dock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class FileSystemDock : public VBoxContainer {
129129
FILE_OPEN_EXTERNAL,
130130
FILE_OPEN_IN_TERMINAL,
131131
FILE_COPY_PATH,
132+
FILE_COPY_ABSOLUTE_PATH,
132133
FILE_COPY_UID,
133134
FOLDER_EXPAND_ALL,
134135
FOLDER_COLLAPSE_ALL,

0 commit comments

Comments
 (0)