Skip to content

Commit 4854c04

Browse files
committed
Merge pull request godotengine#109619 from aaronp64/theme_editor_name_change
`ThemeEditor` fix to show filename for new/renamed files
2 parents 4f393e0 + 842b44d commit 4854c04

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

editor/scene/gui/theme_editor_plugin.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "theme_editor_plugin.h"
3232

3333
#include "editor/doc/editor_help.h"
34+
#include "editor/docks/filesystem_dock.h"
3435
#include "editor/docks/inspector_dock.h"
3536
#include "editor/editor_node.h"
3637
#include "editor/editor_string_names.h"
@@ -3710,7 +3711,7 @@ void ThemeEditor::edit(const Ref<Theme> &p_theme) {
37103711
}
37113712

37123713
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());
37143715
}
37153716
}
37163717

@@ -3749,6 +3750,23 @@ void ThemeEditor::_scene_closed(const String &p_path) {
37493750
}
37503751
}
37513752

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+
37523770
void ThemeEditor::_add_preview_button_cbk() {
37533771
preview_scene_dialog->popup_file_dialog();
37543772
}
@@ -3879,6 +3897,8 @@ void ThemeEditor::_notification(int p_what) {
38793897
switch (p_what) {
38803898
case NOTIFICATION_READY: {
38813899
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));
38823902
} break;
38833903

38843904
case NOTIFICATION_THEME_CHANGED: {

editor/scene/gui/theme_editor_plugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ class ThemeEditor : public VBoxContainer {
454454
void _theme_edit_button_cbk();
455455
void _theme_close_button_cbk();
456456
void _scene_closed(const String &p_path);
457+
void _resource_saved(const Ref<Resource> &p_resource);
458+
void _files_moved(const String &p_old_path, const String &p_new_path);
459+
void _update_theme_name(const String &p_name);
457460

458461
void _add_preview_button_cbk();
459462
void _preview_scene_dialog_cbk(const String &p_path);

0 commit comments

Comments
 (0)