Browser+BrowserSettings: Persist the "show bookmarks bar" setting

Previously this setting was only temporary, but we now save/load it from
the config file.
This commit is contained in:
Sam Atkins 2021-11-24 20:04:43 +00:00 committed by Andreas Kling
parent 8a284be5c7
commit 1933076143
Notes: sideshowbarker 2024-07-18 00:39:30 +09:00
4 changed files with 40 additions and 1 deletions

View File

@ -110,9 +110,12 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
m_window_actions.on_show_bookmarks_bar = [](auto& action) {
Browser::BookmarksBarWidget::the().set_visible(action.is_checked());
Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", action.is_checked());
};
m_window_actions.show_bookmarks_bar_action().set_checked(true);
bool show_bookmarks_bar = Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", true);
m_window_actions.show_bookmarks_bar_action().set_checked(show_bookmarks_bar);
Browser::BookmarksBarWidget::the().set_visible(show_bookmarks_bar);
build_menus();

View File

@ -15,6 +15,9 @@ BrowserSettingsWidget::BrowserSettingsWidget()
m_homepage_url_textbox = find_descendant_of_type_named<GUI::TextBox>("homepage_url_textbox");
m_homepage_url_textbox->set_text(Config::read_string("Browser", "Preferences", "Home", "about:blank"));
m_show_bookmarks_bar_checkbox = find_descendant_of_type_named<GUI::CheckBox>("show_bookmarks_bar_checkbox");
m_show_bookmarks_bar_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", true), GUI::AllowCallback::No);
m_auto_close_download_windows_checkbox = find_descendant_of_type_named<GUI::CheckBox>("auto_close_download_windows_checkbox");
m_auto_close_download_windows_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", false), GUI::AllowCallback::No);
}
@ -28,5 +31,7 @@ void BrowserSettingsWidget::apply_settings()
// TODO: Ensure that the URL is valid, as we do in the BrowserWindow's change-homepage dialog
Config::write_string("Browser", "Preferences", "Home", m_homepage_url_textbox->text());
Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", m_show_bookmarks_bar_checkbox->is_checked());
Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", m_auto_close_download_windows_checkbox->is_checked());
}

View File

@ -39,6 +39,36 @@
}
}
@GUI::GroupBox {
title: "Appearance"
fixed_height: 64
layout: @GUI::VerticalBoxLayout {
margins: [16, 8, 8]
spacing: 2
}
@GUI::Widget {
layout: @GUI::HorizontalBoxLayout {
spacing: 16
}
@GUI::Label {
fixed_width: 32
}
@GUI::Label {
text: "Show bookmarks:"
text_alignment: "CenterLeft"
fixed_width: 110
}
@GUI::CheckBox {
name: "show_bookmarks_bar_checkbox"
}
}
}
@GUI::GroupBox {
title: "Downloads"
fixed_height: 70

View File

@ -21,5 +21,6 @@ private:
BrowserSettingsWidget();
RefPtr<GUI::TextBox> m_homepage_url_textbox;
RefPtr<GUI::CheckBox> m_show_bookmarks_bar_checkbox;
RefPtr<GUI::CheckBox> m_auto_close_download_windows_checkbox;
};