From 8eb539d5c1960cafb5e6dd6d5fb727ef59784f84 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 15 Mar 2022 23:05:12 +0800 Subject: [PATCH] More icon updates on theme change (cherry picked from commit 0ac6e6acbe15b0a7ceddbdaea49ded083f2f7f5e) --- editor/editor_profiler.cpp | 9 ++++++--- .../plugins/resource_preloader_editor_plugin.cpp | 14 +++++--------- editor/plugins/shader_editor_plugin.cpp | 14 +++++++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index 2967fa4913c..4ae620371b6 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -425,9 +425,12 @@ void EditorProfiler::_clear_pressed() { } void EditorProfiler::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - activate->set_icon(get_icon("Play", "EditorIcons")); - clear_button->set_icon(get_icon("Clear", "EditorIcons")); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + activate->set_icon(get_icon("Play", "EditorIcons")); + clear_button->set_icon(get_icon("Clear", "EditorIcons")); + } break; } } diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index 102a42be6d7..3a01c62e76e 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -39,15 +39,11 @@ void ResourcePreloaderEditor::_gui_input(Ref p_event) { } void ResourcePreloaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - load->set_icon(get_icon("Folder", "EditorIcons")); - } - - if (p_what == NOTIFICATION_READY) { - //NodePath("/root")->connect("node_removed", this,"_node_removed",Vector(),true); - } - - if (p_what == NOTIFICATION_DRAW) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + load->set_icon(get_icon("Folder", "EditorIcons")); + } break; } } diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 0c0e40990e6..1f39636fb4b 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -349,8 +349,16 @@ void ShaderEditor::_menu_option(int p_option) { } void ShaderEditor::_notification(int p_what) { - if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { - _check_for_external_edit(); + switch (p_what) { + case NOTIFICATION_ENTER_TREE: + case NOTIFICATION_THEME_CHANGED: { + PopupMenu *popup = help_menu->get_popup(); + popup->set_item_icon(popup->get_item_index(HELP_DOCS), get_icon("Instance", "EditorIcons")); + } break; + + case MainLoop::NOTIFICATION_WM_FOCUS_IN: { + _check_for_external_edit(); + } break; } } @@ -664,7 +672,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { help_menu = memnew(MenuButton); help_menu->set_text(TTR("Help")); help_menu->set_switch_on_hover(true); - help_menu->get_popup()->add_icon_item(p_node->get_gui_base()->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); + help_menu->get_popup()->add_item(TTR("Online Docs"), HELP_DOCS); help_menu->get_popup()->connect("id_pressed", this, "_menu_option"); add_child(main_container);