LibWebView: Add language settings to about:settings

This implements a setting to change the languages provided to websites
from `navigator.language(s)` and the `Accept-Language` header. Whereas
the existing Qt settings dialog allows users to type their language of
choice, this setting allows users to select from a predefined list of
languages. They may choose any number of languages and their preferred
order.

This patch only implements the persisted settings and their UI. It does
not integrate the choses languages into the WebContent process.
This commit is contained in:
Timothy Flynn 2025-04-03 13:42:39 -04:00 committed by Jelle Raaijmakers
commit f242920cc9
Notes: github-actions[bot] 2025-04-04 08:17:38 +00:00
8 changed files with 466 additions and 13 deletions

View file

@ -24,6 +24,9 @@ void SettingsUI::register_interfaces()
register_interface("setNewTabPageURL"sv, [this](auto const& data) {
set_new_tab_page_url(data);
});
register_interface("setLanguages"sv, [this](auto const& data) {
set_languages(data);
});
register_interface("loadAvailableEngines"sv, [this](auto const&) {
load_available_engines();
@ -80,6 +83,14 @@ void SettingsUI::set_new_tab_page_url(JsonValue const& new_tab_page_url)
WebView::Application::settings().set_new_tab_page_url(parsed_new_tab_page_url.release_value());
}
void SettingsUI::set_languages(JsonValue const& languages)
{
auto parsed_languages = Settings::parse_json_languages(languages);
WebView::Application::settings().set_languages(move(parsed_languages));
load_current_settings();
}
void SettingsUI::load_available_engines()
{
JsonArray search_engines;