1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:27:35 +00:00

GamesSettings: Introduce a new GamesSettings application :^)

This currently has exactly one setting: The background colour for card
games. My thinking is, it's better to not have a Settings application
for each individual game we include in the system, since most will only
have a small number of settings, all Settings windows have tabs anyway,
and I don't want to flood the Settings app list unnecessarily.

As for having a single setting for all the card games: it's nice when
things match. :^)
This commit is contained in:
Sam Atkins 2022-08-20 14:14:48 +01:00 committed by Andreas Kling
parent 0737d217cb
commit a01c4c50d1
7 changed files with 134 additions and 0 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "CardSettingsWidget.h"
#include <Applications/GamesSettings/CardSettingsWidgetGML.h>
#include <LibConfig/Client.h>
CardSettingsWidget::CardSettingsWidget()
{
load_from_gml(card_settings_widget_gml);
m_background_color_input = find_descendant_of_type_named<GUI::ColorInput>("cards_background_color");
auto background_color = Gfx::Color::from_string(Config::read_string("Games"sv, "Cards"sv, "BackgroundColor"sv)).value_or(Gfx::Color::from_rgb(0x008000));
m_background_color_input->set_color(background_color, GUI::AllowCallback::No);
m_background_color_input->on_change = [&]() { set_modified(true); };
}
void CardSettingsWidget::apply_settings()
{
Config::write_string("Games"sv, "Cards"sv, "BackgroundColor"sv, m_background_color_input->text());
}
void CardSettingsWidget::reset_default_values()
{
m_background_color_input->set_color(Gfx::Color::from_rgb(0x008000));
}