Streamline the project import workflow.

This commit is contained in:
scorched 2021-07-22 01:47:31 +03:00
parent c82daaed48
commit 885a3dd149
2 changed files with 27 additions and 7 deletions

View file

@ -242,7 +242,7 @@ private:
}
} else {
set_message(TTR("Please choose a \"project.godot\" or \".zip\" file."), MESSAGE_ERROR);
set_message(TTR("Please choose a \"project.godot\", a directory with it, or a \".zip\" file."), MESSAGE_ERROR);
memdelete(d);
install_path_container->hide();
get_ok_button()->set_disabled(true);
@ -315,6 +315,9 @@ private:
}
void _file_selected(const String &p_path) {
// if not already shown
show_dialog();
String p = p_path;
if (mode == MODE_IMPORT) {
if (p.ends_with("project.godot")) {
@ -343,6 +346,9 @@ private:
}
void _path_selected(const String &p_path) {
// if not already shown
show_dialog();
String sp = p_path.simplify_path();
project_path->set_text(sp);
_path_text_changed(sp);
@ -360,7 +366,7 @@ private:
fdialog->set_current_dir(project_path->get_text());
if (mode == MODE_IMPORT) {
fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
fdialog->set_file_mode(FileDialog::FILE_MODE_OPEN_ANY);
fdialog->clear_filters();
fdialog->add_filter(vformat("project.godot ; %s %s", VERSION_NAME, TTR("Project")));
fdialog->add_filter("*.zip ; " + TTR("ZIP File"));
@ -685,6 +691,10 @@ public:
project_path->set_text(p_path);
}
void ask_for_path_and_show() {
_browse_path();
}
void show_dialog() {
if (mode == MODE_RENAME) {
project_path->set_editable(false);
@ -2207,7 +2217,8 @@ void ProjectManager::_new_project() {
void ProjectManager::_import_project() {
npdialog->set_mode(ProjectDialog::MODE_IMPORT);
npdialog->show_dialog();
npdialog->ask_for_path_and_show();
}
void ProjectManager::_rename_project() {

View file

@ -189,9 +189,10 @@ void FileDialog::_post_popup() {
set_process_unhandled_input(true);
// For open dir mode, deselect all items on file dialog open.
if (mode == FILE_MODE_OPEN_DIR) {
if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
deselect_all();
file_box->set_visible(false);
if (mode == FILE_MODE_OPEN_DIR)
file_box->set_visible(false);
} else {
file_box->set_visible(true);
}
@ -383,6 +384,7 @@ void FileDialog::_go_forward() {
void FileDialog::deselect_all() {
// Clear currently selected items in file manager.
tree->deselect_all();
file->set_text("");
// And change get_ok title.
if (!tree->is_anything_selected()) {
@ -393,10 +395,11 @@ void FileDialog::deselect_all() {
case FILE_MODE_OPEN_FILES:
get_ok_button()->set_text(TTRC("Open"));
break;
case FILE_MODE_OPEN_ANY:
case FILE_MODE_OPEN_DIR:
get_ok_button()->set_text(TTRC("Select Current Folder"));
break;
case FILE_MODE_OPEN_ANY:
case FILE_MODE_SAVE_FILE:
// FIXME: Implement, or refactor to avoid duplication with set_mode
break;
@ -417,8 +420,14 @@ void FileDialog::_tree_selected() {
if (!d["dir"]) {
file->set_text(d["name"]);
} else if (mode == FILE_MODE_OPEN_DIR) {
if (mode == FILE_MODE_OPEN_ANY)
get_ok_button()->set_text(TTRC("Open"));
} else if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
get_ok_button()->set_text(TTRC("Select This Folder"));
if (mode == FILE_MODE_OPEN_ANY)
file->set_text(d["name"]);
}
get_ok_button()->set_disabled(_is_open_should_be_disabled());