mirror of
https://github.com/godotengine/godot.git
synced 2025-04-07 00:44:24 +08:00
Merge pull request #96536 from YeldhamDev/copy_file_name
Add option to copy a file's name in the FileSystem dock
This commit is contained in:
commit
3eeaa56abb
@ -2545,6 +2545,14 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
|
||||
}
|
||||
} break;
|
||||
|
||||
case FILE_COPY_NAME: {
|
||||
if (!p_selected.is_empty()) {
|
||||
const String &fpath = p_selected[0];
|
||||
const String file_name = fpath.get_file();
|
||||
DisplayServer::get_singleton()->clipboard_set(file_name);
|
||||
}
|
||||
} break;
|
||||
|
||||
case FILE_COPY_UID: {
|
||||
if (!p_selected.is_empty()) {
|
||||
ResourceUID::ID uid = ResourceLoader::get_resource_uid(p_selected[0]);
|
||||
@ -3271,6 +3279,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);
|
||||
p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_name"), FILE_COPY_NAME);
|
||||
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);
|
||||
}
|
||||
@ -3628,6 +3637,8 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> 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_name", p_event)) {
|
||||
_tree_rmb_option(FILE_COPY_NAME);
|
||||
} 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)) {
|
||||
@ -3711,6 +3722,8 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> 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/copy_name", p_event)) {
|
||||
_tree_rmb_option(FILE_COPY_NAME);
|
||||
} 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)) {
|
||||
@ -4031,6 +4044,7 @@ FileSystemDock::FileSystemDock() {
|
||||
// `KeyModifierMask::CMD_OR_CTRL | Key::C` conflicts with other editor shortcuts.
|
||||
ED_SHORTCUT("filesystem_dock/copy_path", TTRC("Copy Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C);
|
||||
ED_SHORTCUT("filesystem_dock/copy_absolute_path", TTRC("Copy Absolute Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::C);
|
||||
ED_SHORTCUT("filesystem_dock/copy_name", TTR("Copy Name"));
|
||||
ED_SHORTCUT("filesystem_dock/copy_uid", TTRC("Copy UID"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | KeyModifierMask::SHIFT | Key::C);
|
||||
ED_SHORTCUT("filesystem_dock/duplicate", TTRC("Duplicate..."), KeyModifierMask::CMD_OR_CTRL | Key::D);
|
||||
ED_SHORTCUT("filesystem_dock/delete", TTRC("Delete"), Key::KEY_DELETE);
|
||||
|
@ -121,6 +121,7 @@ private:
|
||||
FILE_OPEN_IN_TERMINAL,
|
||||
FILE_COPY_PATH,
|
||||
FILE_COPY_ABSOLUTE_PATH,
|
||||
FILE_COPY_NAME,
|
||||
FILE_COPY_UID,
|
||||
FOLDER_EXPAND_ALL,
|
||||
FOLDER_COLLAPSE_ALL,
|
||||
|
Loading…
x
Reference in New Issue
Block a user