mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:27:34 +00:00
Browser: Store default config values in a single place
Note that this fixes contradictory default values for group "Preferences", key "Home". This is exactly the kind of errors I want to prevent with this new style. The hope is that this can later be used to: - verify that all accesses to the same key use the same default value, - and extract the default values more easily.
This commit is contained in:
parent
9ee098b119
commit
2420effa7d
8 changed files with 55 additions and 37 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "AutoplaySettingsWidget.h"
|
||||
#include <Applications/BrowserSettings/AutoplaySettingsWidgetGML.h>
|
||||
#include <Applications/BrowserSettings/Defaults.h>
|
||||
#include <LibConfig/Client.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -15,8 +16,6 @@
|
|||
#include <LibGUI/ListView.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
|
||||
static constexpr bool default_allow_autoplay_on_all_websites = false;
|
||||
|
||||
ErrorOr<String> AutoplayAllowlistModel::filter_list_file_path() const
|
||||
{
|
||||
return String::formatted("{}/BrowserAutoplayAllowlist.txt", Core::StandardPaths::config_directory());
|
||||
|
@ -38,7 +37,7 @@ ErrorOr<NonnullRefPtr<AutoplaySettingsWidget>> AutoplaySettingsWidget::create()
|
|||
TRY(widget->load_from_gml(autoplay_settings_widget_gml));
|
||||
|
||||
widget->m_allow_autoplay_on_all_websites_checkbox = widget->find_descendant_of_type_named<GUI::CheckBox>("allow_autoplay_on_all_websites_checkbox");
|
||||
widget->m_allow_autoplay_on_all_websites_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "AllowAutoplayOnAllWebsites"sv, default_allow_autoplay_on_all_websites), GUI::AllowCallback::No);
|
||||
widget->m_allow_autoplay_on_all_websites_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "AllowAutoplayOnAllWebsites"sv, Browser::default_allow_autoplay_on_all_websites), GUI::AllowCallback::No);
|
||||
widget->m_allow_autoplay_on_all_websites_checkbox->on_checked = [widget](auto) {
|
||||
widget->set_modified(true);
|
||||
};
|
||||
|
@ -86,5 +85,5 @@ void AutoplaySettingsWidget::apply_settings()
|
|||
void AutoplaySettingsWidget::reset_default_values()
|
||||
{
|
||||
m_allowlist_model->reset_default_values();
|
||||
m_allow_autoplay_on_all_websites_checkbox->set_checked(default_allow_autoplay_on_all_websites);
|
||||
m_allow_autoplay_on_all_websites_checkbox->set_checked(Browser::default_allow_autoplay_on_all_websites);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue