|
31 | 31 | #include "theme_editor_plugin.h" |
32 | 32 |
|
33 | 33 | #include "editor/doc/editor_help.h" |
| 34 | +#include "editor/docks/filesystem_dock.h" |
34 | 35 | #include "editor/docks/inspector_dock.h" |
35 | 36 | #include "editor/editor_node.h" |
36 | 37 | #include "editor/editor_string_names.h" |
@@ -3710,7 +3711,7 @@ void ThemeEditor::edit(const Ref<Theme> &p_theme) { |
3710 | 3711 | } |
3711 | 3712 |
|
3712 | 3713 | if (theme.is_valid()) { |
3713 | | - theme_name->set_text(TTR("Theme:") + " " + theme->get_path().get_file()); |
| 3714 | + _update_theme_name(theme->get_path().get_file()); |
3714 | 3715 | } |
3715 | 3716 | } |
3716 | 3717 |
|
@@ -3749,6 +3750,23 @@ void ThemeEditor::_scene_closed(const String &p_path) { |
3749 | 3750 | } |
3750 | 3751 | } |
3751 | 3752 |
|
| 3753 | +void ThemeEditor::_resource_saved(const Ref<Resource> &p_resource) { |
| 3754 | + if (theme.is_valid() && theme == p_resource) { |
| 3755 | + _update_theme_name(theme->get_path().get_file()); |
| 3756 | + } |
| 3757 | +} |
| 3758 | + |
| 3759 | +void ThemeEditor::_files_moved(const String &p_old_path, const String &p_new_path) { |
| 3760 | + // Theme's path may not have been updated to new path yet - need to check both old and new. |
| 3761 | + if (theme.is_valid() && (theme->get_path() == p_old_path || theme->get_path() == p_new_path)) { |
| 3762 | + _update_theme_name(p_new_path.get_file()); |
| 3763 | + } |
| 3764 | +} |
| 3765 | + |
| 3766 | +void ThemeEditor::_update_theme_name(const String &p_name) { |
| 3767 | + theme_name->set_text(TTR("Theme:") + " " + p_name); |
| 3768 | +} |
| 3769 | + |
3752 | 3770 | void ThemeEditor::_add_preview_button_cbk() { |
3753 | 3771 | preview_scene_dialog->popup_file_dialog(); |
3754 | 3772 | } |
@@ -3879,6 +3897,8 @@ void ThemeEditor::_notification(int p_what) { |
3879 | 3897 | switch (p_what) { |
3880 | 3898 | case NOTIFICATION_READY: { |
3881 | 3899 | EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ThemeEditor::_scene_closed)); |
| 3900 | + EditorNode::get_singleton()->connect("resource_saved", callable_mp(this, &ThemeEditor::_resource_saved)); |
| 3901 | + FileSystemDock::get_singleton()->connect("files_moved", callable_mp(this, &ThemeEditor::_files_moved)); |
3882 | 3902 | } break; |
3883 | 3903 |
|
3884 | 3904 | case NOTIFICATION_THEME_CHANGED: { |
|
0 commit comments