From 819c80428db9b838627b2cbae4dfe26f90bdb1c1 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 20 May 2025 14:47:05 +0800 Subject: [PATCH] Allow closing all scene tabs via shortcut --- editor/editor_node.cpp | 3 ++- editor/editor_node.h | 1 + editor/project_upgrade/project_upgrade_tool.cpp | 2 +- editor/scene/editor_scene_tabs.cpp | 3 ++- editor/scene/editor_scene_tabs.h | 1 - 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 13662af1b2f..013baa14c01 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3044,7 +3044,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } _proceed_closing_scene_tabs(); } break; - case EditorSceneTabs::SCENE_CLOSE_ALL: { + case SCENE_CLOSE_ALL: { tab_closing_menu_option = -1; for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { tabs_to_close.push_back(editor_data.get_scene_path(i)); @@ -8072,6 +8072,7 @@ EditorNode::EditorNode() { file_menu->add_separator(); file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/reload_saved_scene", TTRC("Reload Saved Scene")), SCENE_RELOAD_SAVED_SCENE); file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/close_scene", TTRC("Close Scene"), KeyModifierMask::CMD_OR_CTRL + KeyModifierMask::SHIFT + Key::W), SCENE_CLOSE); + file_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/close_all_scenes", TTRC("Close All Scenes")), SCENE_CLOSE_ALL); ED_SHORTCUT_OVERRIDE("editor/close_scene", "macos", KeyModifierMask::CMD_OR_CTRL + Key::W); if (!global_menu || !OS::get_singleton()->has_feature("macos")) { diff --git a/editor/editor_node.h b/editor/editor_node.h index f0a6dc270db..05504bee747 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -155,6 +155,7 @@ public: SCENE_REDO, SCENE_RELOAD_SAVED_SCENE, SCENE_CLOSE, + SCENE_CLOSE_ALL, SCENE_QUIT, FILE_EXPORT_MESH_LIBRARY, diff --git a/editor/project_upgrade/project_upgrade_tool.cpp b/editor/project_upgrade/project_upgrade_tool.cpp index f2abc594206..c984803b62b 100644 --- a/editor/project_upgrade/project_upgrade_tool.cpp +++ b/editor/project_upgrade/project_upgrade_tool.cpp @@ -96,7 +96,7 @@ void ProjectUpgradeTool::begin_upgrade() { } void ProjectUpgradeTool::finish_upgrade() { - EditorNode::get_singleton()->trigger_menu_option(EditorSceneTabs::SCENE_CLOSE_ALL, true); + EditorNode::get_singleton()->trigger_menu_option(EditorNode::SCENE_CLOSE_ALL, true); Vector paths = EditorSettings::get_singleton()->get_project_metadata(META_PROJECT_UPGRADE_TOOL, META_REIMPORT_PATHS, Vector()); EditorFileSystem::get_singleton()->reimport_files(paths); diff --git a/editor/scene/editor_scene_tabs.cpp b/editor/scene/editor_scene_tabs.cpp index c9821ed4451..f2088e970ab 100644 --- a/editor/scene/editor_scene_tabs.cpp +++ b/editor/scene/editor_scene_tabs.cpp @@ -208,7 +208,8 @@ void EditorSceneTabs::_update_context_menu() { DISABLE_LAST_OPTION_IF(EditorNode::get_editor_data().get_edited_scene_count() <= 1); scene_tabs_context_menu->add_item(TTR("Close Tabs to the Right"), SCENE_CLOSE_RIGHT); DISABLE_LAST_OPTION_IF(EditorNode::get_editor_data().get_edited_scene_count() == tab_id + 1); - scene_tabs_context_menu->add_item(TTR("Close All Tabs"), SCENE_CLOSE_ALL); + scene_tabs_context_menu->add_shortcut(ED_GET_SHORTCUT("editor/close_all_scenes"), EditorNode::SCENE_CLOSE_ALL); + scene_tabs_context_menu->set_item_text(-1, TTRC("Close All Tabs")); const PackedStringArray paths = { EditorNode::get_editor_data().get_scene_path(tab_id) }; EditorContextMenuPluginManager::get_singleton()->add_options_from_plugins(scene_tabs_context_menu, EditorContextMenuPlugin::CONTEXT_SLOT_SCENE_TABS, paths); diff --git a/editor/scene/editor_scene_tabs.h b/editor/scene/editor_scene_tabs.h index ee8dce75d64..75c29606d00 100644 --- a/editor/scene/editor_scene_tabs.h +++ b/editor/scene/editor_scene_tabs.h @@ -51,7 +51,6 @@ public: SCENE_RUN, SCENE_CLOSE_OTHERS, SCENE_CLOSE_RIGHT, - SCENE_CLOSE_ALL, }; private: