GamesSettings: Use on_change callback for resetting chess defaults
This commit is contained in:
parent
8b4e2e2099
commit
1d243ef3e3
Notes:
sideshowbarker
2024-07-16 22:54:10 +09:00
Author: https://github.com/lanmonster Commit: https://github.com/SerenityOS/serenity/commit/1d243ef3e3 Pull-request: https://github.com/SerenityOS/serenity/pull/23589 Reviewed-by: https://github.com/AtkinsSJ
1 changed files with 19 additions and 8 deletions
|
@ -69,6 +69,23 @@ public:
|
|||
return s_board_themes.at(index.row()).name;
|
||||
}
|
||||
|
||||
virtual Vector<GUI::ModelIndex> matches(StringView needle, unsigned flags = MatchesFlag::AllMatching, GUI::ModelIndex const& parent = GUI::ModelIndex()) override
|
||||
{
|
||||
Vector<GUI::ModelIndex> found = {};
|
||||
|
||||
for (size_t i = 0; i < s_board_themes.size(); ++i) {
|
||||
auto theme = s_board_themes[i];
|
||||
if (!string_matches(theme.name, needle, flags))
|
||||
continue;
|
||||
|
||||
found.append(index(i, 0, parent));
|
||||
if (flags & FirstMatchOnly)
|
||||
break;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private:
|
||||
BoardThemeModel()
|
||||
{
|
||||
|
@ -294,14 +311,8 @@ void ChessSettingsWidget::apply_settings()
|
|||
|
||||
void ChessSettingsWidget::reset_default_values()
|
||||
{
|
||||
// FIXME: `set_text()` on a combobox doesn't trigger the `on_change` callback, but it probably should!
|
||||
// Until then, we have to manually tell the preview to update.
|
||||
m_piece_set_combobox->set_text("Classic");
|
||||
m_preview->set_piece_set_name("Classic"_string);
|
||||
auto& board_theme = get_board_theme("Beige"sv);
|
||||
m_board_theme_combobox->set_text(board_theme.name);
|
||||
m_preview->set_dark_square_color(board_theme.dark_square_color);
|
||||
m_preview->set_light_square_color(board_theme.light_square_color);
|
||||
m_piece_set_combobox->set_text("Classic"sv);
|
||||
m_board_theme_combobox->set_text("Beige"sv);
|
||||
m_show_coordinates_checkbox->set_checked(true);
|
||||
m_highlight_checks_checkbox->set_checked(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue