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

Chess: Move ChessWidget to the create pattern

This commit is contained in:
Lucas CHOLLET 2023-01-07 11:06:32 -05:00 committed by Sam Atkins
parent f66098ab6f
commit e7377c6d60
2 changed files with 9 additions and 4 deletions

View file

@ -19,9 +19,12 @@
#include <LibGfx/Path.h>
#include <unistd.h>
ChessWidget::ChessWidget()
ErrorOr<NonnullRefPtr<ChessWidget>> ChessWidget::try_create()
{
set_piece_set("stelar7"sv);
auto widget = TRY(AK::adopt_nonnull_ref_or_enomem(new (nothrow) ChessWidget));
widget->set_piece_set("stelar7"sv);
return widget;
}
void ChessWidget::paint_event(GUI::PaintEvent& event)

View file

@ -19,9 +19,11 @@
class ChessWidget final
: public GUI::Frame
, public Config::Listener {
C_OBJECT(ChessWidget);
C_OBJECT_ABSTRACT(ChessWidget);
public:
static ErrorOr<NonnullRefPtr<ChessWidget>> try_create();
virtual ~ChessWidget() override = default;
virtual void paint_event(GUI::PaintEvent&) override;
@ -109,7 +111,7 @@ public:
};
private:
ChessWidget();
ChessWidget() = default;
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
virtual void config_bool_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value) override;