From 529546e14f5c254b7ce8911e3042dce42c8035ea Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 7 Jun 2023 17:05:37 -0400 Subject: [PATCH] Ladybird: Use the same default new tab page URL as Browser --- Ladybird/Settings.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Ladybird/Settings.cpp b/Ladybird/Settings.cpp index c581ae83a10..684a6935eb4 100644 --- a/Ladybird/Settings.cpp +++ b/Ladybird/Settings.cpp @@ -5,9 +5,28 @@ */ #include "Settings.h" +#include "Utilities.h" +#include +#include namespace Browser { +static QString rebase_default_url_on_serenity_resource_root(StringView default_url) +{ + URL url { default_url }; + Vector paths; + + for (auto segment : s_serenity_resource_root.split('/')) + paths.append(move(segment)); + + for (size_t i = 0; i < url.path_segment_count(); ++i) + paths.append(url.path_segment_at_index(i)); + + url.set_paths(move(paths)); + + return qstring_from_ak_deprecated_string(url.to_deprecated_string()); +} + Settings::Settings() { m_qsettings = new QSettings("Serenity", "Ladybird", this); @@ -15,7 +34,8 @@ Settings::Settings() QString Settings::new_tab_page() { - return m_qsettings->value("new_tab_page", "about:blank").toString(); + static auto const default_new_tab_url = rebase_default_url_on_serenity_resource_root(Browser::default_new_tab_url); + return m_qsettings->value("new_tab_page", default_new_tab_url).toString(); } void Settings::set_new_tab_page(QString const& page)