summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-12-11 22:21:27 +0100
committerkobewi <kobewi4e@gmail.com>2023-12-11 22:21:36 +0100
commitfc7cdd5c37527f7ad6afb96d7d38861b26bfe5f1 (patch)
tree4710075ec5867d0eca671c32a522f56f0b676d6a
parent6882e5042d1ebada62f07130a44a85b032944c31 (diff)
downloadredot-engine-fc7cdd5c37527f7ad6afb96d7d38861b26bfe5f1.tar.gz
Disable Add button when theme item name is empty
-rw-r--r--editor/plugins/theme_editor_plugin.cpp9
-rw-r--r--editor/plugins/theme_editor_plugin.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 9ea0a03e68..6c153f6113 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -2287,8 +2287,11 @@ VBoxContainer *ThemeTypeEditor::_create_item_list(Theme::DataType p_data_type) {
item_add_edit->connect("text_submitted", callable_mp(this, &ThemeTypeEditor::_item_add_lineedit_cbk).bind(p_data_type, item_add_edit));
Button *item_add_button = memnew(Button);
item_add_button->set_text(TTR("Add"));
+ item_add_button->set_disabled(true);
item_add_hb->add_child(item_add_button);
item_add_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_item_add_cbk).bind(p_data_type, item_add_edit));
+ item_add_edit->set_meta("button", item_add_button);
+ item_add_edit->connect("text_changed", callable_mp(this, &ThemeTypeEditor::_update_add_button).bind(item_add_edit));
return items_list;
}
@@ -2850,6 +2853,11 @@ void ThemeTypeEditor::_add_default_type_items() {
ur->commit_action();
}
+void ThemeTypeEditor::_update_add_button(const String &p_text, LineEdit *p_for_edit) {
+ Button *button = Object::cast_to<Button>(p_for_edit->get_meta("button"));
+ button->set_disabled(p_text.strip_edges().is_empty());
+}
+
void ThemeTypeEditor::_item_add_cbk(int p_data_type, Control *p_control) {
LineEdit *le = Object::cast_to<LineEdit>(p_control);
if (le->get_text().strip_edges().is_empty()) {
@@ -2895,6 +2903,7 @@ void ThemeTypeEditor::_item_add_cbk(int p_data_type, Control *p_control) {
ur->commit_action();
le->set_text("");
+ _update_add_button("", le);
}
void ThemeTypeEditor::_item_add_lineedit_cbk(String p_value, int p_data_type, Control *p_control) {
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 33accf587a..cf8c5ceb28 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -382,6 +382,7 @@ class ThemeTypeEditor : public MarginContainer {
void _add_type_button_cbk();
void _add_default_type_items();
+ void _update_add_button(const String &p_text, LineEdit *p_for_edit);
void _item_add_cbk(int p_data_type, Control *p_control);
void _item_add_lineedit_cbk(String p_value, int p_data_type, Control *p_control);
void _item_override_cbk(int p_data_type, String p_item_name);