Просмотр исходного кода

Ladybird: Convert theme configuration to resource URIs

Timothy Flynn 1 год назад
Родитель
Сommit
9249f8bda8
2 измененных файлов с 7 добавлено и 3 удалено
  1. 3 2
      Ladybird/AppKit/UI/Palette.mm
  2. 4 1
      Ladybird/Qt/WebContentView.cpp

+ 3 - 2
Ladybird/AppKit/UI/Palette.mm

@@ -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));
 

+ 4 - 1
Ladybird/Qt/WebContentView.cpp

@@ -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));