From 622bae393b7bbaf966a178c308080f0ec98eabc5 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Silva Dias Date: Tue, 11 Sep 2018 03:32:14 -0300 Subject: [PATCH] Make EditorFileDialog be able to pick a folder when entering it --- editor/editor_file_dialog.cpp | 16 ++++++++++++++-- scene/gui/file_dialog.cpp | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index f11a30bb86b..08fd8a1319f 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -198,8 +198,18 @@ void EditorFileDialog::update_dir() { dir->set_text(dir_access->get_current_dir()); - // Disable "Open" button only when we in selecting file(s) mode or open dir mode. + // Disable "Open" button only when selecting file(s) mode. get_ok()->set_disabled(_is_open_should_be_disabled()); + switch (mode) { + + case MODE_OPEN_FILE: + case MODE_OPEN_FILES: + get_ok()->set_text(TTR("Open")); + break; + case MODE_OPEN_DIR: + get_ok()->set_text(TTR("Select Current Folder")); + break; + } } void EditorFileDialog::_dir_entered(String p_dir) { @@ -453,6 +463,8 @@ void EditorFileDialog::_item_selected(int p_item) { file->set_text(d["name"]); _request_single_thumbnail(get_current_dir().plus_file(get_current_file())); + } else if (mode == MODE_OPEN_DIR) { + get_ok()->set_text(TTR("Select This Folder")); } get_ok()->set_disabled(_is_open_should_be_disabled()); @@ -637,7 +649,7 @@ bool EditorFileDialog::_is_open_should_be_disabled() { Vector items = item_list->get_selected_items(); if (items.size() == 0) - return true; + return mode != MODE_OPEN_DIR; // In "Open folder" mode, having nothing selected picks the current folder. for (int i = 0; i < items.size(); i++) { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 5f162a36526..283d66d8de0 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -349,7 +349,7 @@ void FileDialog::_tree_selected() { file->set_text(d["name"]); } else if (mode == MODE_OPEN_DIR) { - get_ok()->set_text(RTR("Select this Folder")); + get_ok()->set_text(RTR("Select This Folder")); } get_ok()->set_disabled(_is_open_should_be_disabled());