From 30da21f073a0fde1c6ea700cc367f3e33d4e35cc Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 2 Aug 2024 14:02:19 +0200 Subject: [PATCH] Fix project name cleared when browsing path --- editor/project_manager/project_dialog.cpp | 13 +++++++++---- editor/project_manager/project_dialog.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/editor/project_manager/project_dialog.cpp b/editor/project_manager/project_dialog.cpp index 52d86a1a950..ee2253b2945 100644 --- a/editor/project_manager/project_dialog.cpp +++ b/editor/project_manager/project_dialog.cpp @@ -370,6 +370,8 @@ void ProjectDialog::_browse_project_path() { } else { fdialog_project->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR); } + + hide(); fdialog_project->popup_file_dialog(); } @@ -389,7 +391,7 @@ void ProjectDialog::_browse_install_path() { } void ProjectDialog::_project_path_selected(const String &p_path) { - show_dialog(); + show_dialog(false); if (create_dir->is_pressed() && (mode == MODE_NEW || mode == MODE_INSTALL)) { // Replace parent directory, but keep target dir name. @@ -691,7 +693,7 @@ void ProjectDialog::ask_for_path_and_show() { _browse_project_path(); } -void ProjectDialog::show_dialog() { +void ProjectDialog::show_dialog(bool p_reset_name) { if (mode == MODE_RENAME) { // Name and path are set in `ProjectManager::_rename_project`. project_path->set_editable(false); @@ -711,8 +713,10 @@ void ProjectDialog::show_dialog() { callable_mp((Control *)project_name, &Control::grab_focus).call_deferred(); callable_mp(project_name, &LineEdit::select_all).call_deferred(); } else { - String proj = TTR("New Game Project"); - project_name->set_text(proj); + if (p_reset_name) { + String proj = TTR("New Game Project"); + project_name->set_text(proj); + } project_path->set_editable(true); String fav_dir = EDITOR_GET("filesystem/directories/default_project_path"); @@ -793,6 +797,7 @@ void ProjectDialog::_notification(int p_what) { fdialog_project->set_access(EditorFileDialog::ACCESS_FILESYSTEM); fdialog_project->connect("dir_selected", callable_mp(this, &ProjectDialog::_project_path_selected)); fdialog_project->connect("file_selected", callable_mp(this, &ProjectDialog::_project_path_selected)); + fdialog_project->connect("canceled", callable_mp(this, &ProjectDialog::show_dialog).bind(false), CONNECT_DEFERRED); callable_mp((Node *)this, &Node::add_sibling).call_deferred(fdialog_project, false); } break; } diff --git a/editor/project_manager/project_dialog.h b/editor/project_manager/project_dialog.h index 8517189e5aa..0efe1991ab8 100644 --- a/editor/project_manager/project_dialog.h +++ b/editor/project_manager/project_dialog.h @@ -139,7 +139,7 @@ public: void set_zip_title(const String &p_title); void ask_for_path_and_show(); - void show_dialog(); + void show_dialog(bool p_reset_name = true); ProjectDialog(); };