Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FILE_MODE_OPEN_ANY file dialog not selecting folders. #102080

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix FILE_MODE_OPEN_ANY file dialog not selecting folders.
bruvzg committed Jan 27, 2025
commit adceb32177b0b1e5f1328544c583c58c90c1da48
1 change: 1 addition & 0 deletions doc/classes/FileDialog.xml
Original file line number Diff line number Diff line change
@@ -151,6 +151,7 @@
<member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true">
If [code]true[/code], changing the [member file_mode] property will set the window title accordingly (e.g. setting [member file_mode] to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File").
</member>
<member name="ok_button_text" type="String" setter="set_ok_button_text" getter="get_ok_button_text" overrides="AcceptDialog" default="&quot;Save&quot;" />
<member name="option_count" type="int" setter="set_option_count" getter="get_option_count" default="0">
The number of additional [OptionButton]s and [CheckBox]es in the dialog.
</member>
12 changes: 10 additions & 2 deletions scene/gui/file_dialog.cpp
Original file line number Diff line number Diff line change
@@ -637,8 +637,10 @@ void FileDialog::deselect_all() {
set_ok_button_text(ETR("Select Current Folder"));
break;
case FILE_MODE_OPEN_ANY:
set_ok_button_text(ETR("Open"));
break;
case FILE_MODE_SAVE_FILE:
// FIXME: Implement, or refactor to avoid duplication with set_mode
set_ok_button_text(ETR("Save"));
break;
}
}
@@ -657,7 +659,13 @@ void FileDialog::_tree_selected() {

if (!d["dir"]) {
file->set_text(d["name"]);
} else if (mode == FILE_MODE_OPEN_DIR) {
if (mode == FILE_MODE_SAVE_FILE) {
set_ok_button_text(ETR("Save"));
} else {
set_ok_button_text(ETR("Open"));
}
} else if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) {
file->set_text("");
set_ok_button_text(ETR("Select This Folder"));
}