From 8e94bfef53fa3ec501db7c4a78ef74bb885ae27c Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Sat, 1 Nov 2025 19:46:28 -0300 Subject: [PATCH] Make `EditorInspectorCategory`'s theme update happen via signal --- editor/inspector/editor_inspector.cpp | 18 +++++++++++------- editor/inspector/editor_inspector.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/editor/inspector/editor_inspector.cpp b/editor/inspector/editor_inspector.cpp index b515f501539..3a8e10b9296 100644 --- a/editor/inspector/editor_inspector.cpp +++ b/editor/inspector/editor_inspector.cpp @@ -1695,6 +1695,10 @@ void EditorInspectorCategory::_bind_methods() { void EditorInspectorCategory::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_POSTINITIALIZE: { + connect(SceneStringName(theme_changed), callable_mp(this, &EditorInspectorCategory::_theme_changed)); + } break; + case NOTIFICATION_ACCESSIBILITY_UPDATE: { RID ae = get_accessibility_element(); ERR_FAIL_COND(ae.is_null()); @@ -1708,13 +1712,6 @@ void EditorInspectorCategory::_notification(int p_what) { DisplayServer::get_singleton()->accessibility_update_add_action(ae, DisplayServer::AccessibilityAction::ACTION_SHOW_CONTEXT_MENU, callable_mp(this, &EditorInspectorCategory::_accessibility_action_menu)); } break; - case NOTIFICATION_THEME_CHANGED: { - EditorInspector::initialize_category_theme(theme_cache, this); - menu_icon_dirty = true; - _update_icon(); - update_minimum_size(); - } break; - case NOTIFICATION_TRANSLATION_CHANGED: { if (is_favorite) { label = TTR("Favorites"); @@ -1897,6 +1894,13 @@ void EditorInspectorCategory::_update_icon() { } } +void EditorInspectorCategory::_theme_changed() { + // This needs to be done via the signal, as it's fired before the minimum since is updated. + EditorInspector::initialize_category_theme(theme_cache, this); + menu_icon_dirty = true; + _update_icon(); +} + void EditorInspectorCategory::gui_input(const Ref &p_event) { const Ref &mb = p_event; if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) { diff --git a/editor/inspector/editor_inspector.h b/editor/inspector/editor_inspector.h index adc9282472a..623eb4676e2 100644 --- a/editor/inspector/editor_inspector.h +++ b/editor/inspector/editor_inspector.h @@ -412,6 +412,7 @@ class EditorInspectorCategory : public Control { void _handle_menu_option(int p_option); void _popup_context_menu(const Point2i &p_position); void _update_icon(); + void _theme_changed(); protected: static void _bind_methods();