1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

Browser: Add setting to change homepage URL

This commit is contained in:
Marco Cutecchia 2021-06-15 22:49:34 +02:00 committed by Andreas Kling
parent 3c6d99f696
commit 24c243942d
2 changed files with 18 additions and 0 deletions

View file

@ -248,6 +248,23 @@ void BrowserWindow::build_menus()
auto& settings_menu = menubar->add_menu("&Settings");
m_change_homepage_action = GUI::Action::create(
"Set Homepage URL", [this](auto&) {
auto config = Core::ConfigFile::get_for_app("Browser");
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 (URL(homepage_url).is_valid()) {
config->write_entry("Preferences", "Home", homepage_url);
Browser::g_home_url = homepage_url;
} else {
GUI::MessageBox::show_error(this, "The URL you have entered is not valid");
}
}
},
this);
settings_menu.add_action(*m_change_homepage_action);
m_search_engine_actions.set_exclusive(true);
auto& search_engine_menu = settings_menu.add_submenu("&Search Engine");