mirror of
https://github.com/godotengine/godot.git
synced 2025-11-03 23:21:15 +00:00
Disallow creating a project in the Home or Documents folder
Also don't prompt users to delete the project folder for now. This is a temporary fix to ensure that users do not delete their entire home folders by mistake
This commit is contained in:
parent
0c30a43d13
commit
45a26ff292
2 changed files with 22 additions and 10 deletions
|
|
@ -265,7 +265,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// check if the specified folder is empty, even though this is not an error, it is good to check here
|
// Check if the specified folder is empty, even though this is not an error, it is good to check here.
|
||||||
d->list_dir_begin();
|
d->list_dir_begin();
|
||||||
is_folder_empty = true;
|
is_folder_empty = true;
|
||||||
String n = d->get_next();
|
String n = d->get_next();
|
||||||
|
|
@ -283,6 +283,12 @@ private:
|
||||||
d->list_dir_end();
|
d->list_dir_end();
|
||||||
|
|
||||||
if (!is_folder_empty) {
|
if (!is_folder_empty) {
|
||||||
|
if (valid_path == OS::get_singleton()->get_environment("HOME") || valid_path == OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS) || valid_path == OS::get_singleton()->get_executable_path().get_base_dir()) {
|
||||||
|
set_message(TTR("You cannot save a project in the selected path. Please make a new folder or choose a new path."), MESSAGE_ERROR);
|
||||||
|
get_ok_button()->set_disabled(true);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
set_message(TTR("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING);
|
set_message(TTR("The selected path is not empty. Choosing an empty folder is highly recommended."), MESSAGE_WARNING);
|
||||||
get_ok_button()->set_disabled(false);
|
get_ok_button()->set_disabled(false);
|
||||||
return valid_path;
|
return valid_path;
|
||||||
|
|
@ -1828,9 +1834,11 @@ void ProjectList::erase_selected_projects(bool p_delete_project_contents) {
|
||||||
if (_selected_project_paths.has(item.path) && item.control->is_visible()) {
|
if (_selected_project_paths.has(item.path) && item.control->is_visible()) {
|
||||||
_config.erase_section(item.path);
|
_config.erase_section(item.path);
|
||||||
|
|
||||||
if (p_delete_project_contents) {
|
// Comment out for now until we have a better warning system to
|
||||||
OS::get_singleton()->move_to_trash(item.path);
|
// ensure users delete their project only.
|
||||||
}
|
//if (p_delete_project_contents) {
|
||||||
|
// OS::get_singleton()->move_to_trash(item.path);
|
||||||
|
//}
|
||||||
|
|
||||||
memdelete(item.control);
|
memdelete(item.control);
|
||||||
_projects.remove_at(i);
|
_projects.remove_at(i);
|
||||||
|
|
@ -2466,7 +2474,7 @@ void ProjectManager::_rename_project() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::_erase_project_confirm() {
|
void ProjectManager::_erase_project_confirm() {
|
||||||
_project_list->erase_selected_projects(delete_project_contents->is_pressed());
|
_project_list->erase_selected_projects(false);
|
||||||
_update_project_buttons();
|
_update_project_buttons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2490,7 +2498,7 @@ void ProjectManager::_erase_project() {
|
||||||
}
|
}
|
||||||
|
|
||||||
erase_ask_label->set_text(confirm_message);
|
erase_ask_label->set_text(confirm_message);
|
||||||
delete_project_contents->set_pressed(false);
|
//delete_project_contents->set_pressed(false);
|
||||||
erase_ask->popup_centered();
|
erase_ask->popup_centered();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2953,9 +2961,11 @@ ProjectManager::ProjectManager() {
|
||||||
erase_ask_label = memnew(Label);
|
erase_ask_label = memnew(Label);
|
||||||
erase_ask_vb->add_child(erase_ask_label);
|
erase_ask_vb->add_child(erase_ask_label);
|
||||||
|
|
||||||
delete_project_contents = memnew(CheckBox);
|
// Comment out for now until we have a better warning system to
|
||||||
delete_project_contents->set_text(TTR("Also delete project contents (no undo!)"));
|
// ensure users delete their project only.
|
||||||
erase_ask_vb->add_child(delete_project_contents);
|
//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 = memnew(ConfirmationDialog);
|
||||||
multi_open_ask->set_ok_button_text(TTR("Edit"));
|
multi_open_ask->set_ok_button_text(TTR("Edit"));
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,9 @@ class ProjectManager : public Control {
|
||||||
|
|
||||||
ConfirmationDialog *erase_ask = nullptr;
|
ConfirmationDialog *erase_ask = nullptr;
|
||||||
Label *erase_ask_label = nullptr;
|
Label *erase_ask_label = nullptr;
|
||||||
CheckBox *delete_project_contents = nullptr;
|
// Comment out for now until we have a better warning system to
|
||||||
|
// ensure users delete their project only.
|
||||||
|
//CheckBox *delete_project_contents = nullptr;
|
||||||
|
|
||||||
ConfirmationDialog *erase_missing_ask = nullptr;
|
ConfirmationDialog *erase_missing_ask = nullptr;
|
||||||
ConfirmationDialog *multi_open_ask = nullptr;
|
ConfirmationDialog *multi_open_ask = nullptr;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue