mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-29 12:49:05 +00:00
MouseSettings: Use on_change callback to resetting default cursor theme
This commit is contained in:
parent
c2e13764bc
commit
04708f11e1
Notes:
sideshowbarker
2024-07-17 04:34:25 +09:00
Author: https://github.com/lanmonster
Commit: 04708f11e1
Pull-request: https://github.com/SerenityOS/serenity/pull/23589
Reviewed-by: https://github.com/AtkinsSJ
2 changed files with 17 additions and 2 deletions
|
@ -97,6 +97,22 @@ void ThemeModel::invalidate()
|
||||||
Model::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()
|
ErrorOr<NonnullRefPtr<ThemeWidget>> ThemeWidget::try_create()
|
||||||
{
|
{
|
||||||
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ThemeWidget()));
|
auto widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ThemeWidget()));
|
||||||
|
@ -145,6 +161,4 @@ void ThemeWidget::apply_settings()
|
||||||
void ThemeWidget::reset_default_values()
|
void ThemeWidget::reset_default_values()
|
||||||
{
|
{
|
||||||
m_theme_name_box->set_text("Default");
|
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 int column_count(const GUI::ModelIndex&) const override { return 1; }
|
||||||
|
|
||||||
virtual GUI::Variant data(const GUI::ModelIndex& index, GUI::ModelRole role) const override;
|
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;
|
virtual void invalidate() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue