Fix some inspector action buttons not updating icon when theme changes

This commit is contained in:
Haoyu Qiu
2025-06-12 11:04:33 +08:00
parent 45509c284c
commit 5593ac4e3b
16 changed files with 48 additions and 121 deletions

View File

@ -456,8 +456,7 @@ void EditorPropertyArray::update_property() {
property_vbox->set_h_size_flags(SIZE_EXPAND_FILL);
vbox->add_child(property_vbox);
button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Element"));
button_add_item->set_button_icon(get_editor_theme_icon(SNAME("Add")));
button_add_item = memnew(EditorInspectorActionButton(TTRC("Add Element"), SNAME("Add")));
button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyArray::_add_element));
button_add_item->connect(SceneStringName(draw), callable_mp(this, &EditorPropertyArray::_button_add_item_draw));
SET_DRAG_FORWARDING_CD(button_add_item, EditorPropertyArray);
@ -750,12 +749,6 @@ Node *EditorPropertyArray::get_base_node() {
void EditorPropertyArray::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (button_add_item) {
button_add_item->set_button_icon(get_editor_theme_icon(SNAME("Add")));
}
} break;
case NOTIFICATION_DRAG_BEGIN: {
if (is_visible_in_tree()) {
if (_is_drop_valid(get_viewport()->gui_get_drag_data())) {
@ -1305,8 +1298,7 @@ void EditorPropertyDictionary::update_property() {
_create_new_property_slot(EditorPropertyDictionaryObject::NEW_KEY_INDEX);
_create_new_property_slot(EditorPropertyDictionaryObject::NEW_VALUE_INDEX);
button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Key/Value Pair"));
button_add_item->set_button_icon(get_theme_icon(SNAME("Add"), EditorStringName(EditorIcons)));
button_add_item = memnew(EditorInspectorActionButton(TTRC("Add Key/Value Pair"), SNAME("Add")));
button_add_item->set_disabled(is_read_only());
button_add_item->set_accessibility_name(TTRC("Add"));
button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyDictionary::_add_key_value));
@ -1454,7 +1446,6 @@ void EditorPropertyDictionary::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (button_add_item) {
button_add_item->set_button_icon(get_editor_theme_icon(SNAME("Add")));
add_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SNAME("DictionaryAddItem")));
}
} break;
@ -1661,9 +1652,8 @@ void EditorPropertyLocalizableString::update_property() {
}
if (page_index == max_page) {
button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Translation"));
button_add_item = memnew(EditorInspectorActionButton(TTRC("Add Translation"), SNAME("Add")));
button_add_item->set_accessibility_name(TTRC("Add Translation"));
button_add_item->set_button_icon(get_editor_theme_icon(SNAME("Add")));
button_add_item->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyLocalizableString::_add_locale_popup));
property_vbox->add_child(button_add_item);
}
@ -1684,16 +1674,6 @@ void EditorPropertyLocalizableString::_object_id_selected(const StringName &p_pr
emit_signal(SNAME("object_id_selected"), p_property, p_id);
}
void EditorPropertyLocalizableString::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
if (button_add_item) {
button_add_item->set_button_icon(get_editor_theme_icon(SNAME("Add")));
}
} break;
}
}
void EditorPropertyLocalizableString::_edit_pressed() {
Variant prop_val = get_edited_property_value();
if (prop_val.get_type() == Variant::NIL && edit->is_pressed()) {