diff options
author | implicitfield <114500360+implicitfield@users.noreply.github.com> | 2023-02-11 18:41:34 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-21 10:06:41 +0100 |
commit | c95ec6092b36bc0b27b9e3da42fda99397307c40 (patch) | |
tree | e77849205bd1847179400be72fcb2763cead5120 /Userland/Applications | |
parent | 9c7dfd4fd4df211127f846fc3e5dcccacfa527d2 (diff) | |
download | serenity-c95ec6092b36bc0b27b9e3da42fda99397307c40.zip |
DisplaySettings: Propagate errors in DesktopSettingsWidget
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp | 15 | ||||
-rw-r--r-- | Userland/Applications/DisplaySettings/DesktopSettingsWidget.h | 7 |
2 files changed, 13 insertions, 9 deletions
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<NonnullRefPtr<DesktopSettingsWidget>> 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<void> 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<GUI::SpinBox>("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<GUI::Label>("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<NonnullRefPtr<DesktopSettingsWidget>> try_create(); virtual ~DesktopSettingsWidget() override = default; virtual void apply_settings() override; private: - DesktopSettingsWidget(); + DesktopSettingsWidget() = default; - void create_frame(); + ErrorOr<void> create_frame(); void load_current_settings(); RefPtr<GUI::SpinBox> m_workspace_rows_spinbox; |