From 55459dd74e530b50dd520f08b32def5b7725101a Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sat, 23 Mar 2024 17:49:40 +0800 Subject: [PATCH] Disable Clear All button when not filtering in Editor Settings --- editor/action_map_editor.cpp | 6 +++++- editor/action_map_editor.h | 3 ++- editor/editor_settings_dialog.cpp | 13 +++++++++---- editor/editor_settings_dialog.h | 14 ++++++++------ 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 6ff0520ab6f..3023c5907ad 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -505,6 +505,9 @@ void ActionMapEditor::update_action_list(const Vector &p_action_info event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75)); } } + + // Update UI. + clear_all_search->set_disabled(action_list_search->get_text().is_empty() && action_list_search_by_event->get_event().is_null()); } void ActionMapEditor::show_message(const String &p_message) { @@ -550,8 +553,9 @@ ActionMapEditor::ActionMapEditor() { action_list_search_by_event->connect(SceneStringName(focus_exited), callable_mp(this, &ActionMapEditor::_on_filter_unfocused)); top_hbox->add_child(action_list_search_by_event); - Button *clear_all_search = memnew(Button); + clear_all_search = memnew(Button); clear_all_search->set_text(TTR("Clear All")); + clear_all_search->set_tooltip_text(TTR("Clear all search filters.")); clear_all_search->connect(SceneStringName(pressed), callable_mp(action_list_search_by_event, &EventListenerLineEdit::clear_event)); clear_all_search->connect(SceneStringName(pressed), callable_mp(action_list_search, &LineEdit::clear)); top_hbox->add_child(clear_all_search); diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h index 2b329f2fca1..017296bfaa2 100644 --- a/editor/action_map_editor.h +++ b/editor/action_map_editor.h @@ -52,7 +52,7 @@ public: bool has_initial = false; Dictionary action_initial; - Ref icon = Ref(); + Ref icon; bool editable = true; }; @@ -85,6 +85,7 @@ private: CheckButton *show_builtin_actions_checkbutton = nullptr; LineEdit *action_list_search = nullptr; EventListenerLineEdit *action_list_search_by_event = nullptr; + Button *clear_all_search = nullptr; HBoxContainer *add_hbox = nullptr; LineEdit *add_edit = nullptr; diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp index 2c6c13401f9..b1f3875175a 100644 --- a/editor/editor_settings_dialog.cpp +++ b/editor/editor_settings_dialog.cpp @@ -30,14 +30,13 @@ #include "editor_settings_dialog.h" -#include "core/config/project_settings.h" #include "core/input/input_map.h" #include "core/os/keyboard.h" #include "editor/debugger/editor_debugger_node.h" -#include "editor/editor_file_system.h" #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/editor_property_name_processor.h" +#include "editor/editor_sectioned_inspector.h" #include "editor/editor_settings.h" #include "editor/editor_string_names.h" #include "editor/editor_undo_redo_manager.h" @@ -45,7 +44,9 @@ #include "editor/input_event_configuration_dialog.h" #include "editor/themes/editor_scale.h" #include "editor/themes/editor_theme_manager.h" -#include "scene/gui/margin_container.h" +#include "scene/gui/panel_container.h" +#include "scene/gui/tab_container.h" +#include "scene/gui/texture_rect.h" void EditorSettingsDialog::ok_pressed() { if (!EditorSettings::get_singleton()) { @@ -499,6 +500,9 @@ void EditorSettingsDialog::_update_shortcuts() { memdelete(section); } } + + // Update UI. + clear_all_search->set_disabled(shortcut_search_box->get_text().is_empty() && shortcut_search_by_event->get_event().is_null()); } void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button) { @@ -782,8 +786,9 @@ EditorSettingsDialog::EditorSettingsDialog() { shortcut_search_by_event->connect(SceneStringName(focus_exited), callable_mp((AcceptDialog *)this, &AcceptDialog::set_close_on_escape).bind(true)); top_hbox->add_child(shortcut_search_by_event); - Button *clear_all_search = memnew(Button); + clear_all_search = memnew(Button); clear_all_search->set_text(TTR("Clear All")); + clear_all_search->set_tooltip_text(TTR("Clear all search filters.")); clear_all_search->connect(SceneStringName(pressed), callable_mp(shortcut_search_box, &LineEdit::clear)); clear_all_search->connect(SceneStringName(pressed), callable_mp(shortcut_search_by_event, &EventListenerLineEdit::clear_event)); top_hbox->add_child(clear_all_search); diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h index fdfc0a43ec1..cab8fe9da14 100644 --- a/editor/editor_settings_dialog.h +++ b/editor/editor_settings_dialog.h @@ -32,13 +32,14 @@ #define EDITOR_SETTINGS_DIALOG_H #include "editor/action_map_editor.h" -#include "editor/editor_inspector.h" -#include "editor/editor_sectioned_inspector.h" #include "scene/gui/dialogs.h" -#include "scene/gui/panel_container.h" -#include "scene/gui/rich_text_label.h" -#include "scene/gui/tab_container.h" -#include "scene/gui/texture_rect.h" + +class PanelContainer; +class SectionedInspector; +class TabContainer; +class TextureRect; +class Tree; +class TreeItem; class EditorSettingsDialog : public AcceptDialog { GDCLASS(EditorSettingsDialog, AcceptDialog); @@ -53,6 +54,7 @@ class EditorSettingsDialog : public AcceptDialog { LineEdit *shortcut_search_box = nullptr; EventListenerLineEdit *shortcut_search_by_event = nullptr; SectionedInspector *inspector = nullptr; + Button *clear_all_search = nullptr; // Shortcuts enum ShortcutButton {