diff --git a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp index 4913c17317..d7a4da600f 100644 --- a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp @@ -15,15 +15,16 @@ namespace DisplaySettings { -DesktopSettingsWidget::DesktopSettingsWidget() -{ - create_frame(); - load_current_settings(); +ErrorOr> DesktopSettingsWidget::try_create() { + auto desktop_settings_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DesktopSettingsWidget())); + TRY(desktop_settings_widget->create_frame()); + desktop_settings_widget->load_current_settings(); + return desktop_settings_widget; } -void DesktopSettingsWidget::create_frame() +ErrorOr DesktopSettingsWidget::create_frame() { - load_from_gml(desktop_settings_gml).release_value_but_fixme_should_propagate_errors(); + TRY(load_from_gml(desktop_settings_gml)); m_workspace_rows_spinbox = *find_descendant_of_type_named("workspace_rows_spinbox"); m_workspace_rows_spinbox->on_change = [&](auto) { @@ -36,6 +37,8 @@ void DesktopSettingsWidget::create_frame() auto& keyboard_shortcuts_label = *find_descendant_of_type_named("keyboard_shortcuts_label"); keyboard_shortcuts_label.set_text("\xE2\x84\xB9\tCtrl+Alt+{Shift}+Arrows moves between workspaces"); + + return {}; } void DesktopSettingsWidget::load_current_settings() diff --git a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.h b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.h index 9f9d7c12db..4114862f54 100644 --- a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.h +++ b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.h @@ -13,17 +13,18 @@ namespace DisplaySettings { class DesktopSettingsWidget : public GUI::SettingsWindow::Tab { - C_OBJECT(DesktopSettingsWidget); + C_OBJECT_ABSTRACT(DesktopSettingsWidget); public: + static ErrorOr> try_create(); virtual ~DesktopSettingsWidget() override = default; virtual void apply_settings() override; private: - DesktopSettingsWidget(); + DesktopSettingsWidget() = default; - void create_frame(); + ErrorOr create_frame(); void load_current_settings(); RefPtr m_workspace_rows_spinbox;