diff options
author | Andreas Kling <kling@serenityos.org> | 2021-05-19 21:50:51 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-20 00:03:30 +0200 |
commit | bb9e955ef8625e27670ff377ce67b58f011c23b6 (patch) | |
tree | 3c870e4312530bc4b6fbe072b83ad3264c64064d | |
parent | c79e33d00cf82470d9b6b7687911fd3b3276f868 (diff) | |
download | serenity-bb9e955ef8625e27670ff377ce67b58f011c23b6.zip |
DisplaySettings: Make MonitorWidget update itself on property changes
-rw-r--r-- | Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp | 5 | ||||
-rw-r--r-- | Userland/Applications/DisplaySettings/MonitorWidget.cpp | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 2b73f7f814..b2a124abb5 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -60,7 +60,6 @@ void BackgroundSettingsWidget::create_frame() } m_monitor_widget->set_wallpaper(path); - m_monitor_widget->update(); }; auto& button = *find_descendant_of_type_named<GUI::Button>("wallpaper_open_button"); @@ -78,7 +77,6 @@ void BackgroundSettingsWidget::create_frame() m_mode_combo->set_model(*GUI::ItemListModel<String>::create(m_modes)); m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { m_monitor_widget->set_wallpaper_mode(m_modes.at(index.row())); - m_monitor_widget->update(); }; m_color_input = *find_descendant_of_type_named<GUI::ColorInput>("color_input"); @@ -86,7 +84,6 @@ void BackgroundSettingsWidget::create_frame() m_color_input->set_color_picker_title("Select color for desktop"); m_color_input->on_change = [this] { m_monitor_widget->set_background_color(m_color_input->color()); - m_monitor_widget->update(); }; } @@ -121,8 +118,6 @@ void BackgroundSettingsWidget::load_current_settings() m_color_input->set_color(palette_desktop_color); m_monitor_widget->set_background_color(palette_desktop_color); - - m_monitor_widget->update(); } void BackgroundSettingsWidget::apply_settings() diff --git a/Userland/Applications/DisplaySettings/MonitorWidget.cpp b/Userland/Applications/DisplaySettings/MonitorWidget.cpp index 4d0d51a2e8..a916cb5f66 100644 --- a/Userland/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorWidget.cpp @@ -28,8 +28,9 @@ bool MonitorWidget::set_wallpaper(String path) auto bitmap_ptr = Gfx::Bitmap::load_from_file(path); if (!bitmap_ptr && !path.is_empty()) return false; - m_desktop_wallpaper_path = path; + m_desktop_wallpaper_path = move(path); m_desktop_wallpaper_bitmap = bitmap_ptr; + update(); return true; } @@ -40,7 +41,10 @@ String MonitorWidget::wallpaper() void MonitorWidget::set_wallpaper_mode(String mode) { - m_desktop_wallpaper_mode = mode; + if (m_desktop_wallpaper_mode == mode) + return; + m_desktop_wallpaper_mode = move(mode); + update(); } String MonitorWidget::wallpaper_mode() @@ -60,7 +64,10 @@ Gfx::IntSize MonitorWidget::desktop_resolution() void MonitorWidget::set_background_color(Gfx::Color color) { + if (m_desktop_color == color) + return; m_desktop_color = color; + update(); } Gfx::Color MonitorWidget::background_color() |