diff --git a/editor/scene/gui/theme_editor_plugin.cpp b/editor/scene/gui/theme_editor_plugin.cpp index a651b97ffd..9a3f7f201a 100644 --- a/editor/scene/gui/theme_editor_plugin.cpp +++ b/editor/scene/gui/theme_editor_plugin.cpp @@ -31,6 +31,7 @@ #include "theme_editor_plugin.h" #include "editor/doc/editor_help.h" +#include "editor/docks/filesystem_dock.h" #include "editor/docks/inspector_dock.h" #include "editor/editor_node.h" #include "editor/editor_string_names.h" @@ -3710,7 +3711,7 @@ void ThemeEditor::edit(const Ref &p_theme) { } if (theme.is_valid()) { - theme_name->set_text(TTR("Theme:") + " " + theme->get_path().get_file()); + _update_theme_name(theme->get_path().get_file()); } } @@ -3749,6 +3750,23 @@ void ThemeEditor::_scene_closed(const String &p_path) { } } +void ThemeEditor::_resource_saved(const Ref &p_resource) { + if (theme.is_valid() && theme == p_resource) { + _update_theme_name(theme->get_path().get_file()); + } +} + +void ThemeEditor::_files_moved(const String &p_old_path, const String &p_new_path) { + // Theme's path may not have been updated to new path yet - need to check both old and new. + if (theme.is_valid() && (theme->get_path() == p_old_path || theme->get_path() == p_new_path)) { + _update_theme_name(p_new_path.get_file()); + } +} + +void ThemeEditor::_update_theme_name(const String &p_name) { + theme_name->set_text(TTR("Theme:") + " " + p_name); +} + void ThemeEditor::_add_preview_button_cbk() { preview_scene_dialog->popup_file_dialog(); } @@ -3879,6 +3897,8 @@ void ThemeEditor::_notification(int p_what) { switch (p_what) { case NOTIFICATION_READY: { EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ThemeEditor::_scene_closed)); + EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &ThemeEditor::_resource_saved)); + FileSystemDock::get_singleton()->connect("files_moved", callable_mp(this, &ThemeEditor::_files_moved)); } break; case NOTIFICATION_THEME_CHANGED: { diff --git a/editor/scene/gui/theme_editor_plugin.h b/editor/scene/gui/theme_editor_plugin.h index b1ced140b9..6413f5ea96 100644 --- a/editor/scene/gui/theme_editor_plugin.h +++ b/editor/scene/gui/theme_editor_plugin.h @@ -454,6 +454,9 @@ class ThemeEditor : public VBoxContainer { void _theme_edit_button_cbk(); void _theme_close_button_cbk(); void _scene_closed(const String &p_path); + void _resource_saved(const Ref &p_resource); + void _files_moved(const String &p_old_path, const String &p_new_path); + void _update_theme_name(const String &p_name); void _add_preview_button_cbk(); void _preview_scene_dialog_cbk(const String &p_path);