Fix missing native file dialog title translation.

This commit is contained in:
Pāvels Nadtočajevs 2024-11-14 14:36:40 +02:00
parent 76fa7b2914
commit 932b2269f8
5 changed files with 10 additions and 4 deletions

View File

@ -65,7 +65,7 @@ void EditorFileDialog::_native_popup() {
} else if (access == ACCESS_USERDATA) { } else if (access == ACCESS_USERDATA) {
root = OS::get_singleton()->get_user_data_dir(); root = OS::get_singleton()->get_user_data_dir();
} }
DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb)); DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb));
} }
void EditorFileDialog::popup(const Rect2i &p_rect) { void EditorFileDialog::popup(const Rect2i &p_rect) {

View File

@ -68,9 +68,9 @@ void FileDialog::_native_popup() {
root = OS::get_singleton()->get_user_data_dir(); root = OS::get_singleton()->get_user_data_dir();
} }
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_EXTRA)) { if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE_EXTRA)) {
DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options)); DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &FileDialog::_native_dialog_cb_with_options));
} else { } else {
DisplayServer::get_singleton()->file_dialog_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb)); DisplayServer::get_singleton()->file_dialog_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, callable_mp(this, &FileDialog::_native_dialog_cb));
} }
} }

View File

@ -330,7 +330,7 @@ void Viewport::_sub_window_update(Window *p_window) {
int close_h_ofs = p_window->theme_cache.close_h_offset; int close_h_ofs = p_window->theme_cache.close_h_offset;
int close_v_ofs = p_window->theme_cache.close_v_offset; int close_v_ofs = p_window->theme_cache.close_v_offset;
TextLine title_text = TextLine(p_window->atr(p_window->get_title()), title_font, font_size); TextLine title_text = TextLine(p_window->get_translated_title(), title_font, font_size);
title_text.set_width(r.size.width - panel->get_minimum_size().x - close_h_ofs); title_text.set_width(r.size.width - panel->get_minimum_size().x - close_h_ofs);
title_text.set_direction(p_window->is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR); title_text.set_direction(p_window->is_layout_rtl() ? TextServer::DIRECTION_RTL : TextServer::DIRECTION_LTR);
int x = (r.size.width - title_text.get_size().x) / 2; int x = (r.size.width - title_text.get_size().x) / 2;

View File

@ -303,6 +303,11 @@ String Window::get_title() const {
return title; return title;
} }
String Window::get_translated_title() const {
ERR_READ_THREAD_GUARD_V(String());
return tr_title;
}
void Window::_settings_changed() { void Window::_settings_changed() {
if (visible && initial_position != WINDOW_INITIAL_POSITION_ABSOLUTE && is_in_edited_scene_root()) { if (visible && initial_position != WINDOW_INITIAL_POSITION_ABSOLUTE && is_in_edited_scene_root()) {
Size2 screen_size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height")); Size2 screen_size = Size2(GLOBAL_GET("display/window/size/viewport_width"), GLOBAL_GET("display/window/size/viewport_height"));

View File

@ -274,6 +274,7 @@ public:
void set_title(const String &p_title); void set_title(const String &p_title);
String get_title() const; String get_title() const;
String get_translated_title() const;
void set_initial_position(WindowInitialPosition p_initial_position); void set_initial_position(WindowInitialPosition p_initial_position);
WindowInitialPosition get_initial_position() const; WindowInitialPosition get_initial_position() const;