summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/GamesSettings/CardSettingsWidget.cpp15
-rw-r--r--Userland/Applications/GamesSettings/CardSettingsWidget.h8
2 files changed, 17 insertions, 6 deletions
diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
index df510c21a3..f9aff7609c 100644
--- a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
+++ b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -67,9 +67,16 @@ private:
}
};
-CardSettingsWidget::CardSettingsWidget()
+ErrorOr<NonnullRefPtr<CardSettingsWidget>> CardSettingsWidget::try_create()
{
- load_from_gml(card_settings_widget_gml).release_value_but_fixme_should_propagate_errors();
+ auto card_settings_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) CardSettingsWidget));
+ TRY(card_settings_widget->initialize());
+ return card_settings_widget;
+}
+
+ErrorOr<void> CardSettingsWidget::initialize()
+{
+ TRY(load_from_gml(card_settings_widget_gml));
auto background_color = Gfx::Color::from_string(Config::read_string("Games"sv, "Cards"sv, "BackgroundColor"sv)).value_or(Gfx::Color::from_rgb(0x008000));
@@ -99,6 +106,8 @@ CardSettingsWidget::CardSettingsWidget()
};
m_last_selected_card_back = m_card_back_image_view->selection().first();
+
+ return {};
}
void CardSettingsWidget::apply_settings()
diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.h b/Userland/Applications/GamesSettings/CardSettingsWidget.h
index 001e41ca2e..4854442a49 100644
--- a/Userland/Applications/GamesSettings/CardSettingsWidget.h
+++ b/Userland/Applications/GamesSettings/CardSettingsWidget.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -18,15 +18,17 @@ namespace GamesSettings {
class CardGamePreview;
class CardSettingsWidget final : public GUI::SettingsWindow::Tab {
- C_OBJECT(CardSettingsWidget)
+ C_OBJECT_ABSTRACT(CardSettingsWidget)
public:
+ static ErrorOr<NonnullRefPtr<CardSettingsWidget>> try_create();
virtual ~CardSettingsWidget() override = default;
virtual void apply_settings() override;
virtual void reset_default_values() override;
private:
- CardSettingsWidget();
+ CardSettingsWidget() = default;
+ ErrorOr<void> initialize();
bool set_card_back_image_path(DeprecatedString const&);
DeprecatedString card_back_image_path() const;