mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
Browser: Use LibConfig instead of Core::ConfigFile
This commit is contained in:
parent
0cd4b8cbb7
commit
6ad63ae71c
4 changed files with 16 additions and 21 deletions
|
@ -13,7 +13,7 @@
|
||||||
#include "InspectorWidget.h"
|
#include "InspectorWidget.h"
|
||||||
#include "Tab.h"
|
#include "Tab.h"
|
||||||
#include <Applications/Browser/BrowserWindowGML.h>
|
#include <Applications/Browser/BrowserWindowGML.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGUI/AboutDialog.h>
|
#include <LibGUI/AboutDialog.h>
|
||||||
#include <LibGUI/Application.h>
|
#include <LibGUI/Application.h>
|
||||||
|
@ -236,11 +236,10 @@ void BrowserWindow::build_menus()
|
||||||
|
|
||||||
m_change_homepage_action = GUI::Action::create(
|
m_change_homepage_action = GUI::Action::create(
|
||||||
"Set Homepage URL", [this](auto&) {
|
"Set Homepage URL", [this](auto&) {
|
||||||
auto config = Core::ConfigFile::open_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
auto homepage_url = Config::read_string("Browser", "Preferences", "Home", "about:blank");
|
||||||
String homepage_url = config->read_entry("Preferences", "Home", "about:blank");
|
|
||||||
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) {
|
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecOK) {
|
||||||
if (URL(homepage_url).is_valid()) {
|
if (URL(homepage_url).is_valid()) {
|
||||||
config->write_entry("Preferences", "Home", homepage_url);
|
Config::write_string("Browser", "Preferences", "Home", homepage_url);
|
||||||
Browser::g_home_url = homepage_url;
|
Browser::g_home_url = homepage_url;
|
||||||
} else {
|
} else {
|
||||||
GUI::MessageBox::show_error(this, "The URL you have entered is not valid");
|
GUI::MessageBox::show_error(this, "The URL you have entered is not valid");
|
||||||
|
@ -259,8 +258,7 @@ void BrowserWindow::build_menus()
|
||||||
auto action = GUI::Action::create_checkable(
|
auto action = GUI::Action::create_checkable(
|
||||||
name, [&](auto&) {
|
name, [&](auto&) {
|
||||||
g_search_engine = url_format;
|
g_search_engine = url_format;
|
||||||
auto config = Core::ConfigFile::open_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
search_engine_menu.add_action(action);
|
search_engine_menu.add_action(action);
|
||||||
|
@ -276,8 +274,7 @@ void BrowserWindow::build_menus()
|
||||||
m_disable_search_engine_action = GUI::Action::create_checkable(
|
m_disable_search_engine_action = GUI::Action::create_checkable(
|
||||||
"Disable", [](auto&) {
|
"Disable", [](auto&) {
|
||||||
g_search_engine = {};
|
g_search_engine = {};
|
||||||
auto config = Core::ConfigFile::open_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
search_engine_menu.add_action(*m_disable_search_engine_action);
|
search_engine_menu.add_action(*m_disable_search_engine_action);
|
||||||
|
@ -306,8 +303,7 @@ void BrowserWindow::build_menus()
|
||||||
}
|
}
|
||||||
|
|
||||||
g_search_engine = search_engine;
|
g_search_engine = search_engine;
|
||||||
auto config = Core::ConfigFile::open_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
|
||||||
config->write_entry("Preferences", "SearchEngine", g_search_engine);
|
|
||||||
action.set_status_tip(search_engine);
|
action.set_status_tip(search_engine);
|
||||||
});
|
});
|
||||||
search_engine_menu.add_action(custom_search_engine_action);
|
search_engine_menu.add_action(custom_search_engine_action);
|
||||||
|
|
|
@ -27,4 +27,4 @@ set(SOURCES
|
||||||
)
|
)
|
||||||
|
|
||||||
serenity_app(Browser ICON app-browser)
|
serenity_app(Browser ICON app-browser)
|
||||||
target_link_libraries(Browser LibWeb LibProtocol LibGUI LibDesktop)
|
target_link_libraries(Browser LibWeb LibProtocol LibGUI LibDesktop LibConfig)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
#include "DownloadWidget.h"
|
#include "DownloadWidget.h"
|
||||||
#include <AK/NumberFormat.h>
|
#include <AK/NumberFormat.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/FileStream.h>
|
#include <LibCore/FileStream.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
|
@ -36,8 +36,7 @@ DownloadWidget::DownloadWidget(const URL& url)
|
||||||
m_destination_path = builder.to_string();
|
m_destination_path = builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto browser_config = Core::ConfigFile::open_for_app("Browser");
|
auto close_on_finish = Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", false);
|
||||||
auto close_on_finish = browser_config->read_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", false);
|
|
||||||
|
|
||||||
m_elapsed_timer.start();
|
m_elapsed_timer.start();
|
||||||
m_download = Web::ResourceLoader::the().protocol_client().start_request("GET", url);
|
m_download = Web::ResourceLoader::the().protocol_client().start_request("GET", url);
|
||||||
|
@ -90,8 +89,7 @@ DownloadWidget::DownloadWidget(const URL& url)
|
||||||
m_close_on_finish_checkbox->set_checked(close_on_finish);
|
m_close_on_finish_checkbox->set_checked(close_on_finish);
|
||||||
|
|
||||||
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
|
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
|
||||||
auto browser_config = Core::ConfigFile::open_for_app("Browser", Core::ConfigFile::AllowWriting::Yes);
|
Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", checked);
|
||||||
browser_config->write_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", checked);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
auto& button_container = add<GUI::Widget>();
|
auto& button_container = add<GUI::Widget>();
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
#include "Tab.h"
|
#include "Tab.h"
|
||||||
#include "WindowActions.h"
|
#include "WindowActions.h"
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <LibConfig/Client.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibDesktop/Launcher.h>
|
#include <LibDesktop/Launcher.h>
|
||||||
|
@ -52,6 +52,8 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto app = GUI::Application::construct(argc, argv);
|
auto app = GUI::Application::construct(argc, argv);
|
||||||
|
|
||||||
|
Config::pledge_domains("Browser");
|
||||||
|
|
||||||
// Connect to LaunchServer immediately and let it know that we won't ask for anything other than opening
|
// Connect to LaunchServer immediately and let it know that we won't ask for anything other than opening
|
||||||
// the user's downloads directory.
|
// the user's downloads directory.
|
||||||
// FIXME: This should go away with a standalone download manager at some point.
|
// FIXME: This should go away with a standalone download manager at some point.
|
||||||
|
@ -95,9 +97,8 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
auto app_icon = GUI::Icon::default_icon("app-browser");
|
auto app_icon = GUI::Icon::default_icon("app-browser");
|
||||||
|
|
||||||
auto m_config = Core::ConfigFile::open_for_app("Browser");
|
Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "about:blank");
|
||||||
Browser::g_home_url = m_config->read_entry("Preferences", "Home", "about:blank");
|
Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {});
|
||||||
Browser::g_search_engine = m_config->read_entry("Preferences", "SearchEngine", {});
|
|
||||||
|
|
||||||
auto ad_filter_list_or_error = Core::File::open(String::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::OpenMode::ReadOnly);
|
auto ad_filter_list_or_error = Core::File::open(String::formatted("{}/BrowserContentFilters.txt", Core::StandardPaths::config_directory()), Core::OpenMode::ReadOnly);
|
||||||
if (!ad_filter_list_or_error.is_error()) {
|
if (!ad_filter_list_or_error.is_error()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue