Selaa lähdekoodia

Disable Clear All button when not filtering in Editor Settings

Haoyu Qiu 1 vuosi sitten
vanhempi
commit
55459dd74e

+ 5 - 1
editor/action_map_editor.cpp

@@ -505,6 +505,9 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
 			event_item->set_button_color(2, 1, Color(1, 1, 1, 0.75));
 			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) {
 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));
 	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);
 	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_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_by_event, &EventListenerLineEdit::clear_event));
 	clear_all_search->connect(SceneStringName(pressed), callable_mp(action_list_search, &LineEdit::clear));
 	clear_all_search->connect(SceneStringName(pressed), callable_mp(action_list_search, &LineEdit::clear));
 	top_hbox->add_child(clear_all_search);
 	top_hbox->add_child(clear_all_search);

+ 2 - 1
editor/action_map_editor.h

@@ -52,7 +52,7 @@ public:
 		bool has_initial = false;
 		bool has_initial = false;
 		Dictionary action_initial;
 		Dictionary action_initial;
 
 
-		Ref<Texture2D> icon = Ref<Texture2D>();
+		Ref<Texture2D> icon;
 		bool editable = true;
 		bool editable = true;
 	};
 	};
 
 
@@ -85,6 +85,7 @@ private:
 	CheckButton *show_builtin_actions_checkbutton = nullptr;
 	CheckButton *show_builtin_actions_checkbutton = nullptr;
 	LineEdit *action_list_search = nullptr;
 	LineEdit *action_list_search = nullptr;
 	EventListenerLineEdit *action_list_search_by_event = nullptr;
 	EventListenerLineEdit *action_list_search_by_event = nullptr;
+	Button *clear_all_search = nullptr;
 
 
 	HBoxContainer *add_hbox = nullptr;
 	HBoxContainer *add_hbox = nullptr;
 	LineEdit *add_edit = nullptr;
 	LineEdit *add_edit = nullptr;

+ 9 - 4
editor/editor_settings_dialog.cpp

@@ -30,14 +30,13 @@
 
 
 #include "editor_settings_dialog.h"
 #include "editor_settings_dialog.h"
 
 
-#include "core/config/project_settings.h"
 #include "core/input/input_map.h"
 #include "core/input/input_map.h"
 #include "core/os/keyboard.h"
 #include "core/os/keyboard.h"
 #include "editor/debugger/editor_debugger_node.h"
 #include "editor/debugger/editor_debugger_node.h"
-#include "editor/editor_file_system.h"
 #include "editor/editor_log.h"
 #include "editor/editor_log.h"
 #include "editor/editor_node.h"
 #include "editor/editor_node.h"
 #include "editor/editor_property_name_processor.h"
 #include "editor/editor_property_name_processor.h"
+#include "editor/editor_sectioned_inspector.h"
 #include "editor/editor_settings.h"
 #include "editor/editor_settings.h"
 #include "editor/editor_string_names.h"
 #include "editor/editor_string_names.h"
 #include "editor/editor_undo_redo_manager.h"
 #include "editor/editor_undo_redo_manager.h"
@@ -45,7 +44,9 @@
 #include "editor/input_event_configuration_dialog.h"
 #include "editor/input_event_configuration_dialog.h"
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_theme_manager.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() {
 void EditorSettingsDialog::ok_pressed() {
 	if (!EditorSettings::get_singleton()) {
 	if (!EditorSettings::get_singleton()) {
@@ -499,6 +500,9 @@ void EditorSettingsDialog::_update_shortcuts() {
 			memdelete(section);
 			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) {
 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));
 	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);
 	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_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_box, &LineEdit::clear));
 	clear_all_search->connect(SceneStringName(pressed), callable_mp(shortcut_search_by_event, &EventListenerLineEdit::clear_event));
 	clear_all_search->connect(SceneStringName(pressed), callable_mp(shortcut_search_by_event, &EventListenerLineEdit::clear_event));
 	top_hbox->add_child(clear_all_search);
 	top_hbox->add_child(clear_all_search);

+ 8 - 6
editor/editor_settings_dialog.h

@@ -32,13 +32,14 @@
 #define EDITOR_SETTINGS_DIALOG_H
 #define EDITOR_SETTINGS_DIALOG_H
 
 
 #include "editor/action_map_editor.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/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 {
 class EditorSettingsDialog : public AcceptDialog {
 	GDCLASS(EditorSettingsDialog, AcceptDialog);
 	GDCLASS(EditorSettingsDialog, AcceptDialog);
@@ -53,6 +54,7 @@ class EditorSettingsDialog : public AcceptDialog {
 	LineEdit *shortcut_search_box = nullptr;
 	LineEdit *shortcut_search_box = nullptr;
 	EventListenerLineEdit *shortcut_search_by_event = nullptr;
 	EventListenerLineEdit *shortcut_search_by_event = nullptr;
 	SectionedInspector *inspector = nullptr;
 	SectionedInspector *inspector = nullptr;
+	Button *clear_all_search = nullptr;
 
 
 	// Shortcuts
 	// Shortcuts
 	enum ShortcutButton {
 	enum ShortcutButton {