summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorPablo Andres Fuente <pablo.andres.fuente@gmail.com>2024-10-24 09:42:43 -0300
committerPablo Andres Fuente <pablo.andres.fuente@gmail.com>2024-11-18 01:04:30 -0300
commit56d01fb46731c07503ee80ff774fa9aab4522e82 (patch)
treeef4a1ffd41ad582a806ba6d51bd450b214a6cbc1 /editor
parent5efd124ca10bf46df62fa2441d80589777e54a5a (diff)
downloadredot-engine-56d01fb46731c07503ee80ff774fa9aab4522e82.tar.gz
Show file names in the remove files confirmation dialog
Closes #85261 Co-authored-by: jsjtxietian <jsjtxietian@outlook.com>
Diffstat (limited to 'editor')
-rw-r--r--editor/dependency_editor.cpp46
-rw-r--r--editor/dependency_editor.h4
2 files changed, 47 insertions, 3 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 8ba5811ffa..c9f0bd1f24 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -527,6 +527,20 @@ void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<Removed
}
}
+void DependencyRemoveDialog::_show_files_to_delete_list() {
+ files_to_delete_list->clear();
+
+ for (const String &s : dirs_to_delete) {
+ String t = s.trim_prefix("res://");
+ files_to_delete_list->add_item(t, Ref<Texture2D>(), false);
+ }
+
+ for (const String &s : files_to_delete) {
+ String t = s.trim_prefix("res://");
+ files_to_delete_list->add_item(t, Ref<Texture2D>(), false);
+ }
+}
+
void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<String> &p_files) {
all_remove_files.clear();
dirs_to_delete.clear();
@@ -543,21 +557,24 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
files_to_delete.push_back(p_files[i]);
}
+ _show_files_to_delete_list();
+
Vector<RemovedDependency> removed_deps;
_find_all_removed_dependencies(EditorFileSystem::get_singleton()->get_filesystem(), removed_deps);
_find_localization_remaps_of_removed_files(removed_deps);
removed_deps.sort();
if (removed_deps.is_empty()) {
- owners->hide();
+ vb_owners->hide();
text->set_text(TTR("Remove the selected files from the project? (Cannot be undone.)\nDepending on your filesystem configuration, the files will either be moved to the system trash or deleted permanently."));
reset_size();
popup_centered();
} else {
_build_removed_dependency_tree(removed_deps);
- owners->show();
+ vb_owners->show();
text->set_text(TTR("The files being removed are required by other resources in order for them to work.\nRemove them anyway? (Cannot be undone.)\nDepending on your filesystem configuration, the files will either be moved to the system trash or deleted permanently."));
popup_centered(Size2(500, 350));
}
+
EditorFileSystem::get_singleton()->scan_changes();
}
@@ -666,15 +683,38 @@ DependencyRemoveDialog::DependencyRemoveDialog() {
set_ok_button_text(TTR("Remove"));
VBoxContainer *vb = memnew(VBoxContainer);
+ vb->set_h_size_flags(Control::SIZE_EXPAND_FILL);
add_child(vb);
text = memnew(Label);
vb->add_child(text);
+ Label *files_to_delete_label = memnew(Label);
+ files_to_delete_label->set_theme_type_variation("HeaderSmall");
+ files_to_delete_label->set_text(TTR("Files to be deleted:"));
+ vb->add_child(files_to_delete_label);
+
+ files_to_delete_list = memnew(ItemList);
+ files_to_delete_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ files_to_delete_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ files_to_delete_list->set_custom_minimum_size(Size2(0, 94) * EDSCALE);
+ vb->add_child(files_to_delete_list);
+
+ vb_owners = memnew(VBoxContainer);
+ vb_owners->set_h_size_flags(Control::SIZE_EXPAND_FILL);
+ vb_owners->set_v_size_flags(Control::SIZE_EXPAND_FILL);
+ vb->add_child(vb_owners);
+
+ Label *owners_label = memnew(Label);
+ owners_label->set_theme_type_variation("HeaderSmall");
+ owners_label->set_text(TTR("Dependencies of files to be deleted:"));
+ vb_owners->add_child(owners_label);
+
owners = memnew(Tree);
owners->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
owners->set_hide_root(true);
- vb->add_child(owners);
+ owners->set_custom_minimum_size(Size2(0, 94) * EDSCALE);
+ vb_owners->add_child(owners);
owners->set_v_size_flags(Control::SIZE_EXPAND_FILL);
}
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index 0256f39979..93954cbd97 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -31,6 +31,7 @@
#ifndef DEPENDENCY_EDITOR_H
#define DEPENDENCY_EDITOR_H
+#include "scene/gui/box_container.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/item_list.h"
#include "scene/gui/tab_container.h"
@@ -98,6 +99,8 @@ class DependencyRemoveDialog : public ConfirmationDialog {
Label *text = nullptr;
Tree *owners = nullptr;
+ VBoxContainer *vb_owners = nullptr;
+ ItemList *files_to_delete_list = nullptr;
HashMap<String, String> all_remove_files;
Vector<String> dirs_to_delete;
@@ -122,6 +125,7 @@ class DependencyRemoveDialog : public ConfirmationDialog {
void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
+ void _show_files_to_delete_list();
void ok_pressed() override;