Ladybird: Convert theme configuration to resource URIs

This commit is contained in:
Timothy Flynn 2023-11-05 09:46:28 -05:00 committed by Andreas Kling
parent 818471b7a7
commit 9249f8bda8
2 changed files with 7 additions and 3 deletions

View file

@ -6,6 +6,7 @@
#include <AK/DeprecatedString.h>
#include <Ladybird/Utilities.h>
#include <LibCore/Resource.h>
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
@ -31,9 +32,9 @@ Core::AnonymousBuffer create_system_palette()
auto is_dark = is_using_dark_system_theme();
auto theme_file = is_dark ? "Dark"sv : "Default"sv;
auto theme_path = DeprecatedString::formatted("{}/res/themes/{}.ini", s_serenity_resource_root, theme_file);
auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file))));
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
auto theme = MUST(Gfx::load_system_theme(theme_path));
auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
auto palette = Gfx::Palette(move(palette_impl));

View file

@ -20,6 +20,7 @@
#include <Ladybird/Utilities.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/EventLoop.h>
#include <LibCore/Resource.h>
#include <LibCore/System.h>
#include <LibCore/Timer.h>
#include <LibGfx/Bitmap.h>
@ -567,7 +568,9 @@ static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget,
auto qt_palette = widget.palette();
auto theme_file = mode == WebContentView::PaletteMode::Default ? "Default"sv : "Dark"sv;
auto theme = Gfx::load_system_theme(DeprecatedString::formatted("{}/res/themes/{}.ini", s_serenity_resource_root, theme_file)).release_value_but_fixme_should_propagate_errors();
auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file))));
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
auto palette = Gfx::Palette(move(palette_impl));