mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 10:36:24 +00:00
MouseSettings: Use on_change callback to resetting default cursor theme
This commit is contained in:
parent
c2e13764bc
commit
04708f11e1
|
@ -97,6 +97,22 @@ void ThemeModel::invalidate()
|
|||
Model::invalidate();
|
||||
}
|
||||
|
||||
Vector<GUI::ModelIndex> ThemeModel::matches(StringView needle, unsigned flags, const GUI::ModelIndex& parent)
|
||||
{
|
||||
Vector<GUI::ModelIndex> found = {};
|
||||
|
||||
for (size_t i = 0; i < m_themes.size(); ++i) {
|
||||
auto theme = m_themes[i];
|
||||
if (!string_matches(theme, needle, flags))
|
||||
continue;
|
||||
found.append(index(i, 0, parent));
|
||||
if (flags & GUI::Model::MatchesFlag::FirstMatchOnly)
|
||||
break;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ThemeWidget>> ThemeWidget::try_create()
|
||||
{
|
||||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ThemeWidget()));
|
||||
|
@ -145,6 +161,4 @@ 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");
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
virtual int column_count(const GUI::ModelIndex&) const override { return 1; }
|
||||
|
||||
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
|
||||
virtual Vector<GUI::ModelIndex> matches(StringView, unsigned = GUI::Model::MatchesFlag::AllMatching, GUI::ModelIndex const& = GUI::ModelIndex()) override;
|
||||
virtual void invalidate() override;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue