From e298af3c7151fc38e7c3e72548b8a9c512b6a3d7 Mon Sep 17 00:00:00 2001 From: Malcolm Anderson Date: Mon, 15 Dec 2025 09:00:14 -0800 Subject: [PATCH] Add note to extension-change error message about how to make editor recognize an extension Update editor/docks/filesystem_dock.cpp Update editor/docks/filesystem_dock.cpp Update editor/docks/filesystem_dock.cpp Use pressed signal for button Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Tomasz Chabora --- editor/docks/filesystem_dock.cpp | 21 ++++++++++++++++++++- editor/docks/filesystem_dock.h | 5 +++++ editor/settings/editor_settings_dialog.cpp | 8 ++++++++ editor/settings/editor_settings_dialog.h | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp index 4d70d4cfc9..3c29931727 100644 --- a/editor/docks/filesystem_dock.cpp +++ b/editor/docks/filesystem_dock.cpp @@ -41,6 +41,7 @@ #include "editor/docks/editor_dock_manager.h" #include "editor/docks/import_dock.h" #include "editor/docks/scene_tree_dock.h" +#include "editor/editor_interface.h" #include "editor/editor_node.h" #include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" @@ -58,6 +59,7 @@ #include "editor/settings/editor_command_palette.h" #include "editor/settings/editor_feature_profile.h" #include "editor/settings/editor_settings.h" +#include "editor/settings/editor_settings_dialog.h" #include "editor/shader/shader_create_dialog.h" #include "editor/themes/editor_scale.h" #include "editor/themes/editor_theme_manager.h" @@ -1860,7 +1862,7 @@ void FileSystemDock::_rename_operation_confirm() { rename_error = true; } else if (to_rename.is_file && to_rename.path.get_extension() != new_name.get_extension()) { if (!EditorFileSystem::get_singleton()->get_valid_extensions().find(new_name.get_extension())) { - EditorNode::get_singleton()->show_warning(TTRC("This file extension is not recognized by the editor.\nIf you want to rename it anyway, use your operating system's file manager.\nAfter renaming to an unknown extension, the file won't be shown in the editor anymore.")); + unrecognized_ext_dialog->popup_centered_clamped(); rename_error = true; } } @@ -4282,6 +4284,17 @@ void FileSystemDock::load_layout_from_config(const Ref &p_layout, co } } +void FileSystemDock::_on_open_editor_settings_file_exts() { + unrecognized_ext_dialog->hide(); + + // The FileSystem settings are under "advanced settings", so we have to ensure + // that setting is enabled before we attempt to open the menu to them. + EditorSettingsDialog *ed_settings = EditorNode::get_singleton()->editor_settings_dialog; + ed_settings->set_advanced_mode_enabled(true); + ed_settings->popup_edit_settings(); + ed_settings->set_current_section("docks/filesystem"); +} + void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("navigate_to_path", "path"), &FileSystemDock::navigate_to_path); @@ -4572,6 +4585,12 @@ FileSystemDock::FileSystemDock() { add_child(move_confirm_dialog); move_confirm_dialog->connect(SceneStringName(confirmed), callable_mp(this, &FileSystemDock::_move_confirm)); + unrecognized_ext_dialog = memnew(AcceptDialog); + add_child(unrecognized_ext_dialog); + unrecognized_ext_dialog->set_text(TTRC("This file extension is not recognized by the editor.\nIf you want to rename it anyway, use your operating system's file manager.\nAfter renaming to an unknown extension, the file won't be shown in the editor anymore.\nTo make the editor recognize this file extension, add it to one of the lists of extensions in Editor Settings > Docks > FileSystem.")); + Button *settings_button = unrecognized_ext_dialog->add_button(TTRC("Open Editor Settings"), false, "open_editor_settings_docks_filesystem"); + settings_button->connect("pressed", callable_mp(this, &FileSystemDock::_on_open_editor_settings_file_exts)); + uncollapsed_paths_before_search = Vector(); tree_update_id = 0; diff --git a/editor/docks/filesystem_dock.h b/editor/docks/filesystem_dock.h index e0aaeed774..39d9e63d8c 100644 --- a/editor/docks/filesystem_dock.h +++ b/editor/docks/filesystem_dock.h @@ -44,6 +44,7 @@ #include "scene/gui/split_container.h" #include "scene/gui/tree.h" +class AcceptDialog; class CreateDialog; class DependencyEditor; class DependencyEditorOwners; @@ -211,6 +212,8 @@ private: ShaderCreateDialog *make_shader_dialog = nullptr; CreateDialog *new_resource_dialog = nullptr; + AcceptDialog *unrecognized_ext_dialog = nullptr; + String confirm_move_to_dir; bool confirm_to_copy = false; @@ -380,6 +383,8 @@ private: void _project_settings_changed(); static Vector _remove_self_included_paths(Vector selected_strings); + void _on_open_editor_settings_file_exts(); + private: inline static FileSystemDock *singleton = nullptr; diff --git a/editor/settings/editor_settings_dialog.cpp b/editor/settings/editor_settings_dialog.cpp index f5252eeea7..508fa40e74 100644 --- a/editor/settings/editor_settings_dialog.cpp +++ b/editor/settings/editor_settings_dialog.cpp @@ -238,6 +238,14 @@ void EditorSettingsDialog::popup_edit_settings() { _focus_current_search_box(); } +void EditorSettingsDialog::set_advanced_mode_enabled(bool p_enabled) { + advanced_switch->set_pressed(p_enabled); +} + +void EditorSettingsDialog::set_current_section(const String &p_section) { + inspector->set_current_section(p_section); +} + void EditorSettingsDialog::_undo_redo_callback(void *p_self, const String &p_name) { EditorNode::get_log()->add_message(p_name, EditorLog::MSG_TYPE_EDITOR); } diff --git a/editor/settings/editor_settings_dialog.h b/editor/settings/editor_settings_dialog.h index 26e29c6ed8..f8a7950a69 100644 --- a/editor/settings/editor_settings_dialog.h +++ b/editor/settings/editor_settings_dialog.h @@ -131,6 +131,8 @@ protected: public: void popup_edit_settings(); static void update_navigation_preset(); + void set_current_section(const String &p_section); + void set_advanced_mode_enabled(bool p_enabled); EditorSettingsDialog(); };