summaryrefslogtreecommitdiff
path: root/Userland/Applications/MouseSettings
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-04-29 21:06:27 +0100
committerAndreas Kling <kling@serenityos.org>2022-05-12 13:10:49 +0200
commite74e320750546ef03bc203e6efd0ef3581b184e3 (patch)
tree45818fdd15c164b27bfb8efe06f6ab954a7bef81 /Userland/Applications/MouseSettings
parent6ba03dec35959de93f7a076bb952f23397d60d83 (diff)
downloadserenity-e74e320750546ef03bc203e6efd0ef3581b184e3.zip
MouseSettings: Update the cursor theme preview when restoring defaults
Previously, if you opened MouseSettings, set the cursor theme to Dark, and then click "Defaults", the cursors list would not update. ComboBox::set_text() does not call the on_change callback, so we have to run the steps manually. I've also made `m_theme_name` into a local variable, since it can be.
Diffstat (limited to 'Userland/Applications/MouseSettings')
-rw-r--r--Userland/Applications/MouseSettings/ThemeWidget.cpp17
-rw-r--r--Userland/Applications/MouseSettings/ThemeWidget.h2
2 files changed, 10 insertions, 9 deletions
diff --git a/Userland/Applications/MouseSettings/ThemeWidget.cpp b/Userland/Applications/MouseSettings/ThemeWidget.cpp
index 22e83a6f08..0a49155838 100644
--- a/Userland/Applications/MouseSettings/ThemeWidget.cpp
+++ b/Userland/Applications/MouseSettings/ThemeWidget.cpp
@@ -106,8 +106,8 @@ ThemeWidget::ThemeWidget()
m_cursors_tableview->set_column_headers_visible(false);
m_cursors_tableview->set_highlight_key_column(false);
- auto mouse_cursor_model = MouseCursorModel::create();
- auto sorting_proxy_model = MUST(GUI::SortingProxyModel::create(mouse_cursor_model));
+ m_mouse_cursor_model = MouseCursorModel::create();
+ auto sorting_proxy_model = MUST(GUI::SortingProxyModel::create(*m_mouse_cursor_model));
sorting_proxy_model->set_sort_role(GUI::ModelRole::Display);
m_cursors_tableview->set_model(sorting_proxy_model);
@@ -115,17 +115,16 @@ ThemeWidget::ThemeWidget()
m_cursors_tableview->set_column_width(0, 25);
m_cursors_tableview->model()->invalidate();
- m_theme_name = GUI::ConnectionToWindowServer::the().get_cursor_theme();
- mouse_cursor_model->change_theme(m_theme_name);
+ auto theme_name = GUI::ConnectionToWindowServer::the().get_cursor_theme();
+ m_mouse_cursor_model->change_theme(theme_name);
m_theme_name_box = find_descendant_of_type_named<GUI::ComboBox>("theme_name_box");
- m_theme_name_box->on_change = [this, mouse_cursor_model](String const& value, GUI::ModelIndex const&) mutable {
- m_theme_name = value;
- mouse_cursor_model->change_theme(m_theme_name);
+ m_theme_name_box->on_change = [this](String const& value, GUI::ModelIndex const&) mutable {
+ m_mouse_cursor_model->change_theme(value);
};
m_theme_name_box->set_model(ThemeModel::create());
m_theme_name_box->model()->invalidate();
- m_theme_name_box->set_text(m_theme_name);
+ m_theme_name_box->set_text(theme_name);
}
void ThemeWidget::apply_settings()
@@ -136,4 +135,6 @@ void ThemeWidget::apply_settings()
void ThemeWidget::reset_default_values()
{
m_theme_name_box->set_text("Default");
+ // FIXME: ComboBox::set_text() doesn't fire the on_change callback, so we have to set the theme here manually.
+ m_mouse_cursor_model->change_theme("Default");
}
diff --git a/Userland/Applications/MouseSettings/ThemeWidget.h b/Userland/Applications/MouseSettings/ThemeWidget.h
index 74fa63fe34..27c6b5ee9a 100644
--- a/Userland/Applications/MouseSettings/ThemeWidget.h
+++ b/Userland/Applications/MouseSettings/ThemeWidget.h
@@ -75,5 +75,5 @@ private:
RefPtr<GUI::TableView> m_cursors_tableview;
RefPtr<GUI::ComboBox> m_theme_name_box;
- String m_theme_name;
+ RefPtr<MouseCursorModel> m_mouse_cursor_model;
};