Merge pull request #95600 from MajorMcDoom/project-dialog-optional-edit

Add an `Edit Now` option to project dialog to allow opting out of immediately opening a project after creation/import/install
This commit is contained in:
Rémi Verschelde 2024-12-12 14:09:37 +01:00
commit 43ef253024
No known key found for this signature in database
GPG Key ID: C3336907360768E1
4 changed files with 25 additions and 7 deletions

View File

@ -711,14 +711,17 @@ void ProjectManager::_on_projects_updated() {
project_list->update_dock_menu();
}
void ProjectManager::_on_project_created(const String &dir) {
void ProjectManager::_on_project_created(const String &dir, bool edit) {
project_list->add_project(dir, false);
project_list->save_config();
search_box->clear();
int i = project_list->refresh_project(dir);
project_list->select_project(i);
project_list->ensure_project_visible(i);
_open_selected_projects_ask();
if (edit) {
_open_selected_projects_ask();
}
project_list->update_dock_menu();
}

View File

@ -181,7 +181,7 @@ class ProjectManager : public Control {
void _erase_missing_projects_confirm();
void _update_project_buttons();
void _on_project_created(const String &dir);
void _on_project_created(const String &dir, bool edit);
void _on_projects_updated();
void _on_order_option_changed(int p_idx);

View File

@ -725,7 +725,7 @@ void ProjectDialog::ok_pressed() {
hide();
if (mode == MODE_NEW || mode == MODE_IMPORT || mode == MODE_INSTALL) {
emit_signal(SNAME("project_created"), path);
emit_signal(SNAME("project_created"), path, edit_check_box->is_pressed());
} else if (mode == MODE_RENAME) {
emit_signal(SNAME("projects_updated"));
}
@ -767,6 +767,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
create_dir->hide();
project_status_rect->hide();
project_browse->hide();
edit_check_box->hide();
name_container->show();
install_path_container->hide();
@ -797,10 +798,11 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
create_dir->show();
project_status_rect->show();
project_browse->show();
edit_check_box->show();
if (mode == MODE_IMPORT) {
set_title(TTR("Import Existing Project"));
set_ok_button_text(TTR("Import & Edit"));
set_ok_button_text(TTR("Import"));
name_container->hide();
install_path_container->hide();
@ -810,7 +812,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
// Project path dialog is also opened; no need to change focus.
} else if (mode == MODE_NEW) {
set_title(TTR("Create New Project"));
set_ok_button_text(TTR("Create & Edit"));
set_ok_button_text(TTR("Create"));
name_container->show();
install_path_container->hide();
@ -821,7 +823,7 @@ void ProjectDialog::show_dialog(bool p_reset_name) {
callable_mp(project_name, &LineEdit::select_all).call_deferred();
} else if (mode == MODE_INSTALL) {
set_title(TTR("Install Project:") + " " + zip_title);
set_ok_button_text(TTR("Install & Edit"));
set_ok_button_text(TTR("Install"));
project_name->set_text(zip_title);
@ -1063,6 +1065,16 @@ ProjectDialog::ProjectDialog() {
fdialog_install->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
add_child(fdialog_install);
Control *spacer2 = memnew(Control);
spacer2->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vb->add_child(spacer2);
edit_check_box = memnew(CheckBox);
edit_check_box->set_text(TTR("Edit Now"));
edit_check_box->set_h_size_flags(Control::SIZE_SHRINK_CENTER);
edit_check_box->set_pressed(true);
vb->add_child(edit_check_box);
project_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectDialog::_project_name_changed).unbind(1));
project_name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectDialog::ok_pressed).unbind(1));

View File

@ -34,6 +34,7 @@
#include "scene/gui/dialogs.h"
class Button;
class CheckBox;
class CheckButton;
class EditorFileDialog;
class LineEdit;
@ -90,6 +91,8 @@ private:
OptionButton *vcs_metadata_selection = nullptr;
CheckBox *edit_check_box = nullptr;
EditorFileDialog *fdialog_project = nullptr;
EditorFileDialog *fdialog_install = nullptr;
AcceptDialog *dialog_error = nullptr;