mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWebView: Disable autocomplete when search is disabled
Search suggestions don't make much sense when search itself is disabled. We now auto-disable autocomplete when search is disabled.
This commit is contained in:
parent
9267172e28
commit
1a9e78a774
Notes:
github-actions[bot]
2025-05-11 15:48:59 +00:00
Author: https://github.com/trflynn89
Commit: 1a9e78a774
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4694
3 changed files with 13 additions and 5 deletions
|
@ -23,6 +23,8 @@ function loadEngineSettings(settings) {
|
|||
SEARCH_ENGINE = settings.searchEngine || {};
|
||||
AUTOCOMPLETE_ENGINE = settings.autocompleteEngine || {};
|
||||
|
||||
autocompleteEngine.disabled = !SEARCH_ENGINE.name;
|
||||
|
||||
loadCustomSearchEngines();
|
||||
renderEngine(Engine.search, SEARCH_ENGINE);
|
||||
renderEngine(Engine.autocomplete, AUTOCOMPLETE_ENGINE);
|
||||
|
|
|
@ -108,9 +108,11 @@ Settings Settings::create(Badge<Application>)
|
|||
settings.m_search_engine = settings.find_search_engine_by_name(*search_engine_name);
|
||||
}
|
||||
|
||||
if (auto autocomplete_engine = settings_json.value().get_object(autocomplete_engine_key); autocomplete_engine.has_value()) {
|
||||
if (auto autocomplete_engine_name = autocomplete_engine->get_string(autocomplete_engine_name_key); autocomplete_engine_name.has_value())
|
||||
settings.m_autocomplete_engine = find_autocomplete_engine_by_name(*autocomplete_engine_name);
|
||||
if (settings.m_search_engine.has_value()) {
|
||||
if (auto autocomplete_engine = settings_json.value().get_object(autocomplete_engine_key); autocomplete_engine.has_value()) {
|
||||
if (auto autocomplete_engine_name = autocomplete_engine->get_string(autocomplete_engine_name_key); autocomplete_engine_name.has_value())
|
||||
settings.m_autocomplete_engine = find_autocomplete_engine_by_name(*autocomplete_engine_name);
|
||||
}
|
||||
}
|
||||
|
||||
auto load_site_setting = [&](SiteSetting& site_setting, StringView key) {
|
||||
|
|
|
@ -120,10 +120,14 @@ void SettingsUI::load_available_engines()
|
|||
|
||||
void SettingsUI::set_search_engine(JsonValue const& search_engine)
|
||||
{
|
||||
if (search_engine.is_null())
|
||||
if (search_engine.is_null()) {
|
||||
WebView::Application::settings().set_search_engine({});
|
||||
else if (search_engine.is_string())
|
||||
WebView::Application::settings().set_autocomplete_engine({});
|
||||
} else if (search_engine.is_string()) {
|
||||
WebView::Application::settings().set_search_engine(search_engine.as_string());
|
||||
}
|
||||
|
||||
load_current_settings();
|
||||
}
|
||||
|
||||
void SettingsUI::add_custom_search_engine(JsonValue const& search_engine)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue