From d7190be3a35eacda44042b8405fa91ffe3d27b6f Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 11 May 2022 17:08:32 +0100 Subject: [PATCH] DisplaySettings: Set window modified state --- .../DisplaySettings/BackgroundSettingsWidget.cpp | 8 ++++++-- .../DisplaySettings/DesktopSettingsWidget.cpp | 10 ++++++++-- .../DisplaySettings/FontSettingsWidget.cpp | 2 ++ .../DisplaySettings/MonitorSettingsWidget.cpp | 7 +++++-- .../DisplaySettings/ThemesSettingsWidget.cpp | 3 ++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 75671e5d1e0..1a02a50ef20 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -61,6 +61,7 @@ void BackgroundSettingsWidget::create_frame() } m_monitor_widget->set_wallpaper(path); + set_modified(true); }; m_context_menu = GUI::Menu::construct(); @@ -93,6 +94,7 @@ void BackgroundSettingsWidget::create_frame() m_wallpaper_view->selection().clear(); m_monitor_widget->set_wallpaper(path.value()); m_background_settings_changed = true; + set_modified(true); }; m_mode_combo = *find_descendant_of_type_named("mode_combo"); @@ -103,6 +105,7 @@ void BackgroundSettingsWidget::create_frame() m_monitor_widget->set_wallpaper_mode(m_modes.at(index.row())); m_background_settings_changed = !first_mode_change; first_mode_change = false; + set_modified(true); }; m_color_input = *find_descendant_of_type_named("color_input"); @@ -113,6 +116,7 @@ void BackgroundSettingsWidget::create_frame() m_monitor_widget->set_background_color(m_color_input->color()); m_background_settings_changed = !first_color_change; first_color_change = false; + set_modified(true); }; } @@ -133,7 +137,7 @@ void BackgroundSettingsWidget::load_current_settings() mode = "center"; } m_monitor_widget->set_wallpaper_mode(mode); - m_mode_combo->set_selected_index(m_modes.find_first_index(mode).value_or(0)); + m_mode_combo->set_selected_index(m_modes.find_first_index(mode).value_or(0), GUI::AllowCallback::No); auto palette_desktop_color = palette().desktop_background(); auto background_color = ws_config->read_entry("Background", "Color", ""); @@ -144,7 +148,7 @@ void BackgroundSettingsWidget::load_current_settings() palette_desktop_color = opt_color.value(); } - m_color_input->set_color(palette_desktop_color); + m_color_input->set_color(palette_desktop_color, GUI::AllowCallback::No); m_monitor_widget->set_background_color(palette_desktop_color); m_background_settings_changed = false; } diff --git a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp index d0d5b8df70f..ba38f72e4a0 100644 --- a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp @@ -26,14 +26,20 @@ void DesktopSettingsWidget::create_frame() load_from_gml(desktop_settings_gml); m_workspace_rows_spinbox = *find_descendant_of_type_named("workspace_rows_spinbox"); + m_workspace_rows_spinbox->on_change = [&](auto) { + set_modified(true); + }; m_workspace_columns_spinbox = *find_descendant_of_type_named("workspace_columns_spinbox"); + m_workspace_columns_spinbox->on_change = [&](auto) { + set_modified(true); + }; } void DesktopSettingsWidget::load_current_settings() { auto& desktop = GUI::Desktop::the(); - m_workspace_rows_spinbox->set_value(desktop.workspace_rows()); - m_workspace_columns_spinbox->set_value(desktop.workspace_columns()); + m_workspace_rows_spinbox->set_value(desktop.workspace_rows(), GUI::AllowCallback::No); + m_workspace_columns_spinbox->set_value(desktop.workspace_columns(), GUI::AllowCallback::No); } void DesktopSettingsWidget::apply_settings() diff --git a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp index 7ab043a556b..00016ecb5c1 100644 --- a/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/FontSettingsWidget.cpp @@ -30,6 +30,7 @@ FontSettingsWidget::FontSettingsWidget() auto font_picker = GUI::FontPicker::construct(window(), &m_default_font_label->font(), false); if (font_picker->exec() == GUI::Dialog::ExecOK) { update_label_with_font(*m_default_font_label, *font_picker->font()); + set_modified(true); } }; @@ -42,6 +43,7 @@ FontSettingsWidget::FontSettingsWidget() auto font_picker = GUI::FontPicker::construct(window(), &m_fixed_width_font_label->font(), true); if (font_picker->exec() == GUI::Dialog::ExecOK) { update_label_with_font(*m_fixed_width_font_label, *font_picker->font()); + set_modified(true); } }; } diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index 0ab0afe31e1..ac0d5950f61 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -92,6 +92,7 @@ void MonitorSettingsWidget::create_frame() // Try to auto re-arrange things if there are overlaps or disconnected screens m_screen_layout.normalize(); selected_screen_index_or_resolution_changed(); + set_modified(true); }; m_display_scale_radio_1x = *find_descendant_of_type_named("scale_1x"); @@ -103,6 +104,7 @@ void MonitorSettingsWidget::create_frame() m_screen_layout.normalize(); m_monitor_widget->set_desktop_scale_factor(1); m_monitor_widget->update(); + set_modified(true); } }; m_display_scale_radio_2x = *find_descendant_of_type_named("scale_2x"); @@ -114,6 +116,7 @@ void MonitorSettingsWidget::create_frame() m_screen_layout.normalize(); m_monitor_widget->set_desktop_scale_factor(2); m_monitor_widget->update(); + set_modified(true); } }; @@ -209,12 +212,12 @@ void MonitorSettingsWidget::selected_screen_index_or_resolution_changed() dbgln("unexpected ScaleFactor {}, setting to 1", screen.scale_factor); screen.scale_factor = 1; } - (screen.scale_factor == 1 ? m_display_scale_radio_1x : m_display_scale_radio_2x)->set_checked(true); + (screen.scale_factor == 1 ? m_display_scale_radio_1x : m_display_scale_radio_2x)->set_checked(true, GUI::AllowCallback::No); m_monitor_widget->set_desktop_scale_factor(screen.scale_factor); // Select the current selected resolution as it may differ m_monitor_widget->set_desktop_resolution(current_resolution); - m_resolution_combo->set_selected_index(index); + m_resolution_combo->set_selected_index(index, GUI::AllowCallback::No); m_monitor_widget->update(); } diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp index bdfd64ccac0..f218da20d77 100644 --- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp @@ -44,8 +44,9 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed) m_themes_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { m_selected_theme = &m_themes.at(index.row()); m_theme_preview->set_theme(m_selected_theme->path); + set_modified(true); }; - m_themes_combo->set_selected_index(current_theme_index); + m_themes_combo->set_selected_index(current_theme_index, GUI::AllowCallback::No); } void ThemesSettingsWidget::apply_settings()