Add option to copy absolute path in file system dock popup
This commit is contained in:
parent
a7b860250f
commit
5c1d1ea620
2 changed files with 15 additions and 0 deletions
|
@ -2531,6 +2531,14 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
|
|||
}
|
||||
} break;
|
||||
|
||||
case FILE_COPY_ABSOLUTE_PATH: {
|
||||
if (!p_selected.is_empty()) {
|
||||
const String &fpath = p_selected[0];
|
||||
const String absolute_path = ProjectSettings::get_singleton()->globalize_path(fpath);
|
||||
DisplayServer::get_singleton()->clipboard_set(absolute_path);
|
||||
}
|
||||
} break;
|
||||
|
||||
case FILE_COPY_UID: {
|
||||
if (!p_selected.is_empty()) {
|
||||
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
|
|||
|
||||
if (p_paths.size() == 1) {
|
||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH);
|
||||
p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_absolute_path"), FILE_COPY_ABSOLUTE_PATH);
|
||||
if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) {
|
||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID);
|
||||
}
|
||||
|
@ -3481,6 +3490,8 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) {
|
|||
_tree_rmb_option(FILE_DUPLICATE);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) {
|
||||
_tree_rmb_option(FILE_COPY_PATH);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_absolute_path", p_event)) {
|
||||
_tree_rmb_option(FILE_COPY_ABSOLUTE_PATH);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_uid", p_event)) {
|
||||
_tree_rmb_option(FILE_COPY_UID);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) {
|
||||
|
@ -3553,6 +3564,8 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
|
|||
_file_list_rmb_option(FILE_DUPLICATE);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) {
|
||||
_file_list_rmb_option(FILE_COPY_PATH);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/copy_absolute_path", p_event)) {
|
||||
_file_list_rmb_option(FILE_COPY_ABSOLUTE_PATH);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) {
|
||||
_file_list_rmb_option(FILE_REMOVE);
|
||||
} else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) {
|
||||
|
@ -3856,6 +3869,7 @@ FileSystemDock::FileSystemDock() {
|
|||
|
||||
// `KeyModifierMask::CMD_OR_CTRL | Key::C` conflicts with other editor shortcuts.
|
||||
ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C);
|
||||
ED_SHORTCUT("filesystem_dock/copy_absolute_path", TTR("Copy Absolute Path"));
|
||||
ED_SHORTCUT("filesystem_dock/copy_uid", TTR("Copy UID"));
|
||||
ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KeyModifierMask::CMD_OR_CTRL | Key::D);
|
||||
ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), Key::KEY_DELETE);
|
||||
|
|
|
@ -129,6 +129,7 @@ private:
|
|||
FILE_OPEN_EXTERNAL,
|
||||
FILE_OPEN_IN_TERMINAL,
|
||||
FILE_COPY_PATH,
|
||||
FILE_COPY_ABSOLUTE_PATH,
|
||||
FILE_COPY_UID,
|
||||
FOLDER_EXPAND_ALL,
|
||||
FOLDER_COLLAPSE_ALL,
|
||||
|
|
Loading…
Reference in a new issue