diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index f244bc0da86..985a789e414 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -1192,7 +1192,7 @@ void EditorAudioBuses::_server_save() { } void EditorAudioBuses::_select_layout() { - FileSystemDock::get_singleton()->select_file(edited_path); + FileSystemDock::get_singleton()->navigate_to_path(edited_path); } void EditorAudioBuses::_save_as_layout() { diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 3b7cce60bf8..a70ec230bff 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -237,7 +237,7 @@ void EditorResourcePicker::_update_menu_items() { if (edited_resource->get_path().is_resource_file()) { edit_menu->add_separator(); - edit_menu->add_item(TTR("Show in FileSystem"), OBJ_MENU_SHOW_IN_FILE_SYSTEM); + edit_menu->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTR("Show in FileSystem"), OBJ_MENU_SHOW_IN_FILE_SYSTEM); } } @@ -418,16 +418,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) { } break; case OBJ_MENU_SHOW_IN_FILE_SYSTEM: { - FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); - file_system_dock->navigate_to_path(edited_resource->get_path()); - - // Ensure that the FileSystem dock is visible. - if (file_system_dock->get_window() == get_tree()->get_root()) { - TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control(); - tab_container->set_current_tab(tab_container->get_tab_idx_from_control(file_system_dock)); - } else { - file_system_dock->get_window()->grab_focus(); - } + FileSystemDock::get_singleton()->navigate_to_path(edited_resource->get_path()); } break; default: { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 944da47242f..27050335071 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -756,6 +756,14 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa void FileSystemDock::navigate_to_path(const String &p_path) { file_list_search_box->clear(); _navigate_to_path(p_path); + + // Ensure that the FileSystem dock is visible. + if (get_window() == get_tree()->get_root()) { + TabContainer *tab_container = (TabContainer *)get_parent_control(); + tab_container->set_current_tab(tab_container->get_tab_idx_from_control((Control *)this)); + } else { + get_window()->grab_focus(); + } } void FileSystemDock::_file_list_thumbnail_done(const String &p_path, const Ref &p_preview, const Ref &p_small_preview, const Variant &p_udata) { diff --git a/editor/gui/editor_scene_tabs.cpp b/editor/gui/editor_scene_tabs.cpp index 1fe8eee6d78..b15871aa238 100644 --- a/editor/gui/editor_scene_tabs.cpp +++ b/editor/gui/editor_scene_tabs.cpp @@ -165,7 +165,7 @@ void EditorSceneTabs::_update_context_menu() { if (tab_id >= 0) { scene_tabs_context_menu->add_separator(); - scene_tabs_context_menu->add_item(TTR("Show in FileSystem"), EditorNode::FILE_SHOW_IN_FILESYSTEM); + scene_tabs_context_menu->add_icon_item(get_editor_theme_icon(SNAME("ShowInFileSystem")), TTR("Show in FileSystem"), EditorNode::FILE_SHOW_IN_FILESYSTEM); _disable_menu_option_if(EditorNode::FILE_SHOW_IN_FILESYSTEM, !ResourceLoader::exists(EditorNode::get_editor_data().get_scene_path(tab_id))); scene_tabs_context_menu->add_item(TTR("Play This Scene"), EditorNode::FILE_RUN_SCENE); _disable_menu_option_if(EditorNode::FILE_RUN_SCENE, no_root_node); diff --git a/editor/icons/ShowInFileSystem.svg b/editor/icons/ShowInFileSystem.svg new file mode 100644 index 00000000000..9cfeaf48d21 --- /dev/null +++ b/editor/icons/ShowInFileSystem.svg @@ -0,0 +1 @@ + diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 6c4636dba38..04ab30f2c24 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1427,11 +1427,7 @@ void ScriptEditor::_menu_option(int p_option) { path = path.get_slice("::", 0); // Show the scene instead. } - FileSystemDock *file_system_dock = FileSystemDock::get_singleton(); - file_system_dock->navigate_to_path(path); - // Ensure that the FileSystem dock is visible. - TabContainer *dock_tab_container = (TabContainer *)file_system_dock->get_parent_control(); - dock_tab_container->set_current_tab(dock_tab_container->get_tab_idx_from_control(file_system_dock)); + FileSystemDock::get_singleton()->navigate_to_path(path); } } break; case CLOSE_DOCS: { diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index a94c978a1ae..a6fb543ce68 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -46,6 +46,7 @@ #include "editor/editor_settings.h" #include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" +#include "editor/filesystem_dock.h" #include "editor/gui/editor_file_dialog.h" #include "editor/inspector_dock.h" #include "editor/multi_node_edit.h" @@ -148,6 +149,8 @@ void SceneTreeDock::shortcut_input(const Ref &p_event) { _tool_selected(TOOL_ERASE, true); } else if (ED_IS_SHORTCUT("scene_tree/copy_node_path", p_event)) { _tool_selected(TOOL_COPY_NODE_PATH); + } else if (ED_IS_SHORTCUT("scene_tree/show_in_file_system", p_event)) { + _tool_selected(TOOL_SHOW_IN_FILE_SYSTEM); } else if (ED_IS_SHORTCUT("scene_tree/toggle_unique_name", p_event)) { _tool_selected(TOOL_TOGGLE_SCENE_UNIQUE_NAME); } else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) { @@ -1016,6 +1019,16 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } } } break; + case TOOL_SHOW_IN_FILE_SYSTEM: { + List selection = editor_selection->get_selected_node_list(); + List::Element *e = selection.front(); + if (e) { + const Node *node = e->get(); + if (node) { + FileSystemDock::get_singleton()->navigate_to_path(node->get_scene_file_path()); + } + } + } break; case TOOL_OPEN_DOCUMENTATION: { List selection = editor_selection->get_selected_node_list(); for (int i = 0; i < selection.size(); i++) { @@ -3266,6 +3279,11 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { } #endif // MODULE_REGEX_ENABLED menu->add_separator(); + + if (full_selection.size() == 1 && !selection[0]->get_scene_file_path().is_empty()) { + menu->add_icon_shortcut(get_editor_theme_icon(SNAME("ShowInFileSystem")), ED_GET_SHORTCUT("scene_tree/show_in_file_system"), TOOL_SHOW_IN_FILE_SYSTEM); + } + menu->add_icon_item(get_editor_theme_icon(SNAME("Help")), TTR("Open Documentation"), TOOL_OPEN_DOCUMENTATION); if (profile_allow_editing) { @@ -3967,6 +3985,7 @@ SceneTreeDock::SceneTreeDock(Node *p_scene_root, EditorSelection *p_editor_selec ED_SHORTCUT("scene_tree/make_root", TTR("Make Scene Root")); ED_SHORTCUT("scene_tree/save_branch_as_scene", TTR("Save Branch as Scene")); ED_SHORTCUT("scene_tree/copy_node_path", TTR("Copy Node Path"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::C); + ED_SHORTCUT("scene_tree/show_in_file_system", TTR("Show In FileSystem")); ED_SHORTCUT("scene_tree/toggle_unique_name", TTR("Toggle Access as Unique Name")); ED_SHORTCUT("scene_tree/delete_no_confirm", TTR("Delete (No Confirm)"), KeyModifierMask::SHIFT | Key::KEY_DELETE); ED_SHORTCUT("scene_tree/delete", TTR("Delete"), Key::KEY_DELETE); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index 93c0e16db7a..fc9c271526d 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -79,6 +79,7 @@ class SceneTreeDock : public VBoxContainer { TOOL_MULTI_EDIT, TOOL_ERASE, TOOL_COPY_NODE_PATH, + TOOL_SHOW_IN_FILE_SYSTEM, TOOL_OPEN_DOCUMENTATION, TOOL_AUTO_EXPAND, TOOL_SCENE_EDITABLE_CHILDREN,