Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show file names in remove files confirmation dialog #98539

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions editor/dependency_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down