summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-04-06 11:30:14 +0200
committerGitHub <noreply@github.com>2021-04-06 11:30:14 +0200
commit45f0b5db2847debacf24e4ca962338b237af19ae (patch)
tree09eb14085eb15653f3cae15a85d2d6f1f504090a /editor
parent12286a1fde7db7c5095a9acd894d3b11dba536da (diff)
parent93f944b0708c7c509a61aead93113ac1c6e89b2a (diff)
Merge pull request #47200 from LightningAA/delete-from-project-manager-4.0
Add the ability to remove project contents from the remove project dialog
Diffstat (limited to 'editor')
-rw-r--r--editor/project_manager.cpp27
-rw-r--r--editor/project_manager.h4
2 files changed, 25 insertions, 6 deletions
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 595110f7b3..d3def86bd1 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1031,7 +1031,7 @@ public:
int get_project_count() const;
void select_project(int p_index);
void select_first_visible_project();
- void erase_selected_projects();
+ void erase_selected_projects(bool p_delete_project_contents);
Vector<Item> get_selected_projects() const;
const Set<String> &get_selected_project_keys() const;
void ensure_project_visible(int p_index);
@@ -1686,7 +1686,7 @@ void ProjectList::toggle_select(int p_index) {
item.control->update();
}
-void ProjectList::erase_selected_projects() {
+void ProjectList::erase_selected_projects(bool p_delete_project_contents) {
if (_selected_project_keys.size() == 0) {
return;
}
@@ -1697,6 +1697,10 @@ void ProjectList::erase_selected_projects() {
EditorSettings::get_singleton()->erase("projects/" + item.project_key);
EditorSettings::get_singleton()->erase("favorite_projects/" + item.project_key);
+ if (p_delete_project_contents) {
+ OS::get_singleton()->move_to_trash(item.path);
+ }
+
memdelete(item.control);
_projects.remove(i);
--i;
@@ -2217,7 +2221,7 @@ void ProjectManager::_rename_project() {
}
void ProjectManager::_erase_project_confirm() {
- _project_list->erase_selected_projects();
+ _project_list->erase_selected_projects(delete_project_contents->is_pressed());
_update_project_buttons();
}
@@ -2235,12 +2239,13 @@ void ProjectManager::_erase_project() {
String confirm_message;
if (selected_list.size() >= 2) {
- confirm_message = vformat(TTR("Remove %d projects from the list?\nThe project folders' contents won't be modified."), selected_list.size());
+ confirm_message = vformat(TTR("Remove %d projects from the list?"), selected_list.size());
} else {
- confirm_message = TTR("Remove this project from the list?\nThe project folder's contents won't be modified.");
+ confirm_message = TTR("Remove this project from the list?");
}
- erase_ask->set_text(confirm_message);
+ erase_ask_label->set_text(confirm_message);
+ delete_project_contents->set_pressed(false);
erase_ask->popup_centered();
}
@@ -2665,6 +2670,16 @@ ProjectManager::ProjectManager() {
erase_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_erase_project_confirm));
add_child(erase_ask);
+ VBoxContainer *erase_ask_vb = memnew(VBoxContainer);
+ erase_ask->add_child(erase_ask_vb);
+
+ erase_ask_label = memnew(Label);
+ erase_ask_vb->add_child(erase_ask_label);
+
+ delete_project_contents = memnew(CheckBox);
+ delete_project_contents->set_text(TTR("Also delete project contents (no undo!)"));
+ erase_ask_vb->add_child(delete_project_contents);
+
multi_open_ask = memnew(ConfirmationDialog);
multi_open_ask->get_ok_button()->set_text(TTR("Edit"));
multi_open_ask->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_open_selected_projects));
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 49d672a8e5..d13315c022 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -67,7 +67,11 @@ class ProjectManager : public Control {
FileDialog *scan_dir;
ConfirmationDialog *language_restart_ask;
+
ConfirmationDialog *erase_ask;
+ Label *erase_ask_label;
+ CheckBox *delete_project_contents;
+
ConfirmationDialog *erase_missing_ask;
ConfirmationDialog *multi_open_ask;
ConfirmationDialog *multi_run_ask;