Fix Windows native FileDialog filters not showing descriptions

This commit is contained in:
Wagner 2025-10-11 18:50:09 -03:00
parent cb7cd815ee
commit f835707f7a
2 changed files with 12 additions and 11 deletions

View file

@ -555,7 +555,7 @@ void DisplayServerWindows::_thread_fd_monitor(void *p_ud) {
if (!exts.is_empty()) { if (!exts.is_empty()) {
String str = String(";").join(exts); String str = String(";").join(exts);
filter_exts.push_back(str.utf16()); filter_exts.push_back(str.utf16());
if (tokens.size() == 2) { if (tokens.size() >= 2) {
filter_names.push_back(tokens[1].strip_edges().utf16()); filter_names.push_back(tokens[1].strip_edges().utf16());
} else { } else {
filter_names.push_back(str.utf16()); filter_names.push_back(str.utf16());

View file

@ -1162,13 +1162,13 @@ void FileDialog::update_filters() {
} }
String native_all_name; String native_all_name;
native_all_name += all_filters;
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_MIME)) { if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_MIME)) {
native_all_name += all_filters; if (!native_all_name.is_empty()) {
native_all_name += ", ";
}
native_all_name += all_mime;
} }
if (!native_all_name.is_empty()) {
native_all_name += ", ";
}
native_all_name += all_mime;
if (max_filters < filters.size()) { if (max_filters < filters.size()) {
all_filters += ", ..."; all_filters += ", ...";
@ -1183,13 +1183,14 @@ void FileDialog::update_filters() {
String desc = filters[i].get_slicec(';', 1).strip_edges(); String desc = filters[i].get_slicec(';', 1).strip_edges();
String mime = filters[i].get_slicec(';', 2).strip_edges(); String mime = filters[i].get_slicec(';', 2).strip_edges();
String native_name; String native_name;
native_name += flt;
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_MIME)) { if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_MIME)) {
native_name += flt; if (!native_name.is_empty() && !mime.is_empty()) {
native_name += ", ";
}
native_name += mime;
} }
if (!native_name.is_empty() && !mime.is_empty()) {
native_name += ", ";
}
native_name += mime;
if (!desc.is_empty()) { if (!desc.is_empty()) {
filter->add_item(atr(desc) + " (" + flt + ")"); filter->add_item(atr(desc) + " (" + flt + ")");
processed_filters.push_back(flt + ";" + atr(desc) + " (" + native_name + ");" + mime); processed_filters.push_back(flt + ";" + atr(desc) + " (" + native_name + ");" + mime);