mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
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.
This commit is contained in:
parent
6ba03dec35
commit
e74e320750
2 changed files with 10 additions and 9 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue