diff options
author | Ben Maxwell <macdue@dueutil.tech> | 2022-04-03 10:51:54 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-03 12:58:46 +0200 |
commit | 8070a982887be775ee657798452248ce42506d21 (patch) | |
tree | e9b781a33cb2b5ca856c445bbb785f61c5b2c658 /Userland/Applications | |
parent | e6ad55ab5328dc2bb5538c2ed7469b2a973f12ee (diff) | |
download | serenity-8070a982887be775ee657798452248ce42506d21.zip |
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.
Diffstat (limited to 'Userland/Applications')
5 files changed, 26 insertions, 9 deletions
diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index d4c9fdc060..36e635abce 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -31,7 +31,8 @@ namespace DisplaySettings { -BackgroundSettingsWidget::BackgroundSettingsWidget() +BackgroundSettingsWidget::BackgroundSettingsWidget(bool& background_settings_changed) + : m_background_settings_changed { background_settings_changed } { m_modes.append("tile"); m_modes.append("center"); @@ -86,20 +87,27 @@ void BackgroundSettingsWidget::create_frame() return; m_wallpaper_view->selection().clear(); m_monitor_widget->set_wallpaper(path.value()); + m_background_settings_changed = true; }; m_mode_combo = *find_descendant_of_type_named<GUI::ComboBox>("mode_combo"); m_mode_combo->set_only_allow_values_from_model(true); m_mode_combo->set_model(*GUI::ItemListModel<String>::create(m_modes)); - m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { + bool first_mode_change = true; + m_mode_combo->on_change = [this, first_mode_change](auto&, const GUI::ModelIndex& index) mutable { m_monitor_widget->set_wallpaper_mode(m_modes.at(index.row())); + m_background_settings_changed = !first_mode_change; + first_mode_change = false; }; m_color_input = *find_descendant_of_type_named<GUI::ColorInput>("color_input"); m_color_input->set_color_has_alpha_channel(false); m_color_input->set_color_picker_title("Select color for desktop"); - m_color_input->on_change = [this] { + bool first_color_change = true; + m_color_input->on_change = [this, first_color_change]() mutable { m_monitor_widget->set_background_color(m_color_input->color()); + m_background_settings_changed = !first_color_change; + first_color_change = false; }; } @@ -133,6 +141,7 @@ void BackgroundSettingsWidget::load_current_settings() m_color_input->set_color(palette_desktop_color); m_monitor_widget->set_background_color(palette_desktop_color); + m_background_settings_changed = false; } void BackgroundSettingsWidget::apply_settings() diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.h b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.h index 0fa8a191cf..2a187b0f58 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.h +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.h @@ -27,13 +27,15 @@ public: virtual void apply_settings() override; private: - BackgroundSettingsWidget(); + BackgroundSettingsWidget(bool& background_settings_changed); void create_frame(); void load_current_settings(); Vector<String> m_modes; + bool& m_background_settings_changed; + RefPtr<DisplaySettings::MonitorWidget> m_monitor_widget; RefPtr<GUI::IconView> m_wallpaper_view; RefPtr<GUI::ComboBox> m_mode_combo; diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp index 955c079612..bdfd64ccac 100644 --- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp @@ -19,7 +19,8 @@ static inline String current_system_theme() return GUI::ConnectionToWindowServer::the().get_system_theme(); } -ThemesSettingsWidget::ThemesSettingsWidget() +ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed) + : m_background_settings_changed { background_settings_changed } { load_from_gml(themes_settings_gml); m_themes = Gfx::list_installed_system_themes(); @@ -50,7 +51,8 @@ ThemesSettingsWidget::ThemesSettingsWidget() void ThemesSettingsWidget::apply_settings() { if (m_selected_theme && m_selected_theme->name != current_system_theme()) - VERIFY(GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name)); + VERIFY(GUI::ConnectionToWindowServer::the().set_system_theme(m_selected_theme->path, m_selected_theme->name, m_background_settings_changed)); + m_background_settings_changed = false; } } diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.h b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.h index 520a754642..7975487148 100644 --- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.h +++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.h @@ -31,7 +31,9 @@ private: Gfx::SystemThemeMetaData const* m_selected_theme { nullptr }; - ThemesSettingsWidget(); + bool& m_background_settings_changed; + + ThemesSettingsWidget(bool& background_settings_changed); }; } diff --git a/Userland/Applications/DisplaySettings/main.cpp b/Userland/Applications/DisplaySettings/main.cpp index b8b2fef93a..154d9da393 100644 --- a/Userland/Applications/DisplaySettings/main.cpp +++ b/Userland/Applications/DisplaySettings/main.cpp @@ -27,9 +27,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app_icon = GUI::Icon::default_icon("app-display-settings"); + bool background_settings_changed = false; + auto window = TRY(GUI::SettingsWindow::create("Display Settings")); - (void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background")); - (void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes")); + (void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background", background_settings_changed)); + (void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes", background_settings_changed)); (void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts")); (void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor")); (void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces")); |