diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-11-24 20:04:43 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-11-26 22:14:56 +0100 |
commit | 19330761433ba8bd91918cf047a59973ef17035b (patch) | |
tree | 84466198fed76b26e094426a2a15055996f287e8 /Userland | |
parent | 8a284be5c72242e847db7bc831ed2752b78fede6 (diff) | |
download | serenity-19330761433ba8bd91918cf047a59973ef17035b.zip |
Browser+BrowserSettings: Persist the "show bookmarks bar" setting
Previously this setting was only temporary, but we now save/load it from
the config file.
Diffstat (limited to 'Userland')
4 files changed, 40 insertions, 1 deletions
diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index 28950e72ce..91c836229e 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -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(); diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index 35ce49f4fd..36ce71a148 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -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()); } diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.gml b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.gml index d92a5dbffa..945af63495 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.gml +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.gml @@ -40,6 +40,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 diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h index 3720c86a5c..cd0ec39983 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h @@ -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; }; |