1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:07:44 +00:00

DisplaySettings+WindowServer: Allow updating theme without background

With this change you can now set the theme and background color at the
same time in the Display Settings. Before if both were changed
before hitting 'apply' the theme background color would overwrite
the custom background.
This commit is contained in:
Ben Maxwell 2022-04-03 10:51:54 +01:00 committed by Andreas Kling
parent e6ad55ab53
commit 8070a98288
11 changed files with 35 additions and 17 deletions

View file

@ -2089,7 +2089,7 @@ void WindowManager::invalidate_after_theme_or_font_change()
Compositor::the().invalidate_after_theme_or_font_change();
}
bool WindowManager::update_theme(String theme_path, String theme_name)
bool WindowManager::update_theme(String theme_path, String theme_name, bool keep_desktop_background)
{
auto new_theme = Gfx::load_system_theme(theme_path);
if (!new_theme.is_valid())
@ -2097,7 +2097,8 @@ bool WindowManager::update_theme(String theme_path, String theme_name)
Gfx::set_system_theme(new_theme);
m_palette = Gfx::PaletteImpl::create_with_anonymous_buffer(new_theme);
m_config->write_entry("Theme", "Name", theme_name);
m_config->remove_entry("Background", "Color");
if (!keep_desktop_background)
m_config->remove_entry("Background", "Color");
if (auto result = m_config->sync(); result.is_error()) {
dbgln("Failed to save config file: {}", result.error());
return false;