diff --git a/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.cpp b/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.cpp index 1d6f8f9b39..e0f2f7146d 100644 --- a/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.cpp @@ -29,47 +29,46 @@ void AutoplayAllowlistModel::reset_default_values() namespace BrowserSettings { -ErrorOr> AutoplaySettingsWidget::create() +ErrorOr AutoplaySettingsWidget::initialize() { auto allowlist_model = TRY(try_make_ref_counted()); TRY(allowlist_model->load()); - auto widget = TRY(AutoplaySettingsWidget::try_create()); - widget->set_allowlist_model(move(allowlist_model)); + set_allowlist_model(move(allowlist_model)); - widget->m_allow_autoplay_on_all_websites_checkbox = widget->find_descendant_of_type_named("allow_autoplay_on_all_websites_checkbox"); - widget->m_allow_autoplay_on_all_websites_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "AllowAutoplayOnAllWebsites"sv, Browser::default_allow_autoplay_on_all_websites), GUI::AllowCallback::No); - widget->m_allow_autoplay_on_all_websites_checkbox->on_checked = [widget](auto) { - widget->set_modified(true); + m_allow_autoplay_on_all_websites_checkbox = find_descendant_of_type_named("allow_autoplay_on_all_websites_checkbox"); + m_allow_autoplay_on_all_websites_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "AllowAutoplayOnAllWebsites"sv, Browser::default_allow_autoplay_on_all_websites), GUI::AllowCallback::No); + m_allow_autoplay_on_all_websites_checkbox->on_checked = [this](auto) { + set_modified(true); }; - widget->m_allowlist_view = widget->find_descendant_of_type_named("allowlist_view"); - widget->m_allowlist_view->set_model(widget->m_allowlist_model); - widget->m_allowlist_view->on_context_menu_request = [widget](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) { - widget->m_allowlist_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); - widget->m_entry_context_menu->popup(event.screen_position()); + m_allowlist_view = find_descendant_of_type_named("allowlist_view"); + m_allowlist_view->set_model(m_allowlist_model); + m_allowlist_view->on_context_menu_request = [this](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) { + m_allowlist_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); + m_entry_context_menu->popup(event.screen_position()); }; - widget->m_add_website_button = widget->find_descendant_of_type_named("add_website_button"); - widget->m_add_website_button->on_click = [widget](unsigned) { + m_add_website_button = find_descendant_of_type_named("add_website_button"); + m_add_website_button->on_click = [this](unsigned) { String text; - if (GUI::InputBox::show(widget->window(), text, "Enter a website:"sv, "Add Autoplay Entry"sv, GUI::InputType::NonemptyText) == GUI::Dialog::ExecResult::OK) { - widget->m_allowlist_model->add_domain(move(text)); - widget->set_modified(true); + if (GUI::InputBox::show(window(), text, "Enter a website:"sv, "Add Autoplay Entry"sv, GUI::InputType::NonemptyText) == GUI::Dialog::ExecResult::OK) { + m_allowlist_model->add_domain(move(text)); + set_modified(true); } }; - auto delete_action = GUI::CommonActions::make_delete_action([widget](GUI::Action const&) { - if (!widget->m_allowlist_view->selection().is_empty()) { - widget->m_allowlist_model->delete_domain(widget->m_allowlist_view->selection().first().row()); - widget->set_modified(true); + auto delete_action = GUI::CommonActions::make_delete_action([this](GUI::Action const&) { + if (!m_allowlist_view->selection().is_empty()) { + m_allowlist_model->delete_domain(m_allowlist_view->selection().first().row()); + set_modified(true); } }); - widget->m_entry_context_menu = GUI::Menu::construct(); - widget->m_entry_context_menu->add_action(move(delete_action)); + m_entry_context_menu = GUI::Menu::construct(); + m_entry_context_menu->add_action(move(delete_action)); - return widget; + return {}; } void AutoplaySettingsWidget::set_allowlist_model(NonnullRefPtr model) diff --git a/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.h b/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.h index ff12294aa3..7ae506fa83 100644 --- a/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.h +++ b/Userland/Applications/BrowserSettings/AutoplaySettingsWidget.h @@ -27,13 +27,13 @@ class AutoplaySettingsWidget : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(AutoplaySettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override; virtual void reset_default_values() override; private: - static ErrorOr> try_create(); AutoplaySettingsWidget() = default; void set_allowlist_model(NonnullRefPtr model); diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index 64d13ebe73..42929210dd 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -95,16 +95,7 @@ private: Vector m_search_engines; }; -ErrorOr> BrowserSettingsWidget::create() -{ - auto widget = TRY(BrowserSettingsWidget::try_create()); - - TRY(widget->setup()); - - return widget; -} - -ErrorOr BrowserSettingsWidget::setup() +ErrorOr BrowserSettingsWidget::initialize() { m_homepage_url_textbox = find_descendant_of_type_named("homepage_url_textbox"); m_homepage_url_textbox->set_text(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, Browser::default_homepage_url), GUI::AllowCallback::No); diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h index 56b9b662fb..3bde08e24d 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.h @@ -17,17 +17,15 @@ namespace BrowserSettings { class BrowserSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(BrowserSettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); virtual ~BrowserSettingsWidget() override = default; virtual void apply_settings() override; virtual void reset_default_values() override; + ErrorOr initialize(); + private: - static ErrorOr> try_create(); - - ErrorOr setup(); - RefPtr m_homepage_url_textbox; RefPtr m_new_tab_url_textbox; void set_color_scheme(StringView); diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 2118b75677..bcf7c9e80c 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -117,47 +117,46 @@ void DomainListModel::reset_default_values() namespace BrowserSettings { -ErrorOr> ContentFilterSettingsWidget::create() +ErrorOr ContentFilterSettingsWidget::initialize() { auto domain_list_model = TRY(try_make_ref_counted()); TRY(domain_list_model->load()); - auto widget = TRY(ContentFilterSettingsWidget::try_create()); - widget->set_domain_list_model(move(domain_list_model)); + set_domain_list_model(move(domain_list_model)); - widget->m_enable_content_filtering_checkbox = widget->find_descendant_of_type_named("enable_content_filtering_checkbox"); - widget->m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, Browser::default_enable_content_filters), GUI::AllowCallback::No); - widget->m_enable_content_filtering_checkbox->on_checked = [widget](auto) { - widget->set_modified(true); + m_enable_content_filtering_checkbox = find_descendant_of_type_named("enable_content_filtering_checkbox"); + m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, Browser::default_enable_content_filters), GUI::AllowCallback::No); + m_enable_content_filtering_checkbox->on_checked = [this](auto) { + set_modified(true); }; - widget->m_domain_list_view = widget->find_descendant_of_type_named("domain_list_view"); - widget->m_domain_list_view->set_model(widget->m_domain_list_model); - widget->m_domain_list_view->on_context_menu_request = [widget](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) { - widget->m_domain_list_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); - widget->m_entry_context_menu->popup(event.screen_position()); + m_domain_list_view = find_descendant_of_type_named("domain_list_view"); + m_domain_list_view->set_model(m_domain_list_model); + m_domain_list_view->on_context_menu_request = [this](GUI::ModelIndex const& index, GUI::ContextMenuEvent const& event) { + m_domain_list_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); + m_entry_context_menu->popup(event.screen_position()); }; - widget->m_add_new_domain_button = widget->find_descendant_of_type_named("add_new_domain_button"); - widget->m_add_new_domain_button->on_click = [widget](unsigned) { + m_add_new_domain_button = find_descendant_of_type_named("add_new_domain_button"); + m_add_new_domain_button->on_click = [this](unsigned) { String text; - if (GUI::InputBox::show(widget->window(), text, "Enter a domain:"sv, "Add Content Filter"sv, GUI::InputType::NonemptyText) == GUI::Dialog::ExecResult::OK) { - widget->m_domain_list_model->add_domain(move(text)); - widget->set_modified(true); + if (GUI::InputBox::show(window(), text, "Enter a domain:"sv, "Add Content Filter"sv, GUI::InputType::NonemptyText) == GUI::Dialog::ExecResult::OK) { + m_domain_list_model->add_domain(move(text)); + set_modified(true); } }; - auto delete_action = GUI::CommonActions::make_delete_action([widget](GUI::Action const&) { - if (!widget->m_domain_list_view->selection().is_empty()) { - widget->m_domain_list_model->delete_domain(widget->m_domain_list_view->selection().first().row()); - widget->set_modified(true); + auto delete_action = GUI::CommonActions::make_delete_action([this](GUI::Action const&) { + if (!m_domain_list_view->selection().is_empty()) { + m_domain_list_model->delete_domain(m_domain_list_view->selection().first().row()); + set_modified(true); } }); - widget->m_entry_context_menu = GUI::Menu::construct(); - widget->m_entry_context_menu->add_action(delete_action); + m_entry_context_menu = GUI::Menu::construct(); + m_entry_context_menu->add_action(delete_action); - return widget; + return {}; } void ContentFilterSettingsWidget::set_domain_list_model(NonnullRefPtr domain_list_model) diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.h b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.h index 008429eb2f..85a3a6b3db 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.h +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.h @@ -37,13 +37,13 @@ class ContentFilterSettingsWidget : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(ContentFilterSettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override; virtual void reset_default_values() override; private: - static ErrorOr> try_create(); ContentFilterSettingsWidget() = default; void set_domain_list_model(NonnullRefPtr); diff --git a/Userland/Applications/BrowserSettings/main.cpp b/Userland/Applications/BrowserSettings/main.cpp index ad69d586bf..4a8e3ec0f9 100644 --- a/Userland/Applications/BrowserSettings/main.cpp +++ b/Userland/Applications/BrowserSettings/main.cpp @@ -37,9 +37,9 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::SettingsWindow::create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); window->set_icon(app_icon.bitmap_for_size(16)); - (void)TRY(window->add_tab(TRY(BrowserSettings::BrowserSettingsWidget::create()), "Browser"_string, "browser"sv)); - (void)TRY(window->add_tab(TRY(BrowserSettings::ContentFilterSettingsWidget::create()), "Content Filtering"_string, "content-filtering"sv)); - (void)TRY(window->add_tab(TRY(BrowserSettings::AutoplaySettingsWidget::create()), "Autoplay"_string, "autoplay"sv)); + (void)TRY(window->add_tab("Browser"_string, "browser"sv)); + (void)TRY(window->add_tab("Content Filtering"_string, "content-filtering"sv)); + (void)TRY(window->add_tab("Autoplay"_string, "autoplay"sv)); window->set_active_tab(selected_tab); window->show(); diff --git a/Userland/Applications/Calculator/CalculatorWidget.cpp b/Userland/Applications/Calculator/CalculatorWidget.cpp index cf9dc79373..6fd8933c1e 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.cpp +++ b/Userland/Applications/Calculator/CalculatorWidget.cpp @@ -17,89 +17,87 @@ namespace Calculator { -ErrorOr> CalculatorWidget::create() +ErrorOr CalculatorWidget::initialize() { - auto widget = TRY(CalculatorWidget::try_create()); - - widget->m_entry = *widget->find_descendant_of_type_named("entry_textbox"); + m_entry = *find_descendant_of_type_named("entry_textbox"); // FIXME: Use GML for this. - widget->m_entry->set_relative_rect(5, 5, 244, 26); - widget->m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); + m_entry->set_relative_rect(5, 5, 244, 26); + m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); // FIXME: Use GML for this. - widget->m_label = *widget->find_descendant_of_type_named("label"); - widget->m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer); + m_label = *find_descendant_of_type_named("label"); + m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer); for (int i = 0; i < 10; i++) { - widget->m_digit_button[i] = *widget->find_descendant_of_type_named(TRY(String::formatted("{}_button", i))); - widget->add_digit_button(*widget->m_digit_button[i], i); + m_digit_button[i] = *find_descendant_of_type_named(TRY(String::formatted("{}_button", i))); + add_digit_button(*m_digit_button[i], i); } - widget->m_mem_add_button = *widget->find_descendant_of_type_named("mem_add_button"); - widget->add_operation_button(*widget->m_mem_add_button, Calculator::Operation::MemAdd); + m_mem_add_button = *find_descendant_of_type_named("mem_add_button"); + add_operation_button(*m_mem_add_button, Calculator::Operation::MemAdd); - widget->m_mem_save_button = *widget->find_descendant_of_type_named("mem_save_button"); - widget->add_operation_button(*widget->m_mem_save_button, Calculator::Operation::MemSave); + m_mem_save_button = *find_descendant_of_type_named("mem_save_button"); + add_operation_button(*m_mem_save_button, Calculator::Operation::MemSave); - widget->m_mem_recall_button = *widget->find_descendant_of_type_named("mem_recall_button"); - widget->add_operation_button(*widget->m_mem_recall_button, Calculator::Operation::MemRecall); + m_mem_recall_button = *find_descendant_of_type_named("mem_recall_button"); + add_operation_button(*m_mem_recall_button, Calculator::Operation::MemRecall); - widget->m_mem_clear_button = *widget->find_descendant_of_type_named("mem_clear_button"); - widget->add_operation_button(*widget->m_mem_clear_button, Calculator::Operation::MemClear); + m_mem_clear_button = *find_descendant_of_type_named("mem_clear_button"); + add_operation_button(*m_mem_clear_button, Calculator::Operation::MemClear); - widget->m_clear_button = *widget->find_descendant_of_type_named("clear_button"); - widget->m_clear_button->on_click = [self = NonnullRefPtr(widget)](auto) { - self->m_keypad.set_to_0(); - self->m_calculator.clear_operation(); - self->update_display(); + m_clear_button = *find_descendant_of_type_named("clear_button"); + m_clear_button->on_click = [this](auto) { + m_keypad.set_to_0(); + m_calculator.clear_operation(); + update_display(); }; - widget->m_clear_error_button = *widget->find_descendant_of_type_named("clear_error_button"); - widget->m_clear_error_button->on_click = [self = NonnullRefPtr(widget)](auto) { - self->m_keypad.set_to_0(); - self->update_display(); + m_clear_error_button = *find_descendant_of_type_named("clear_error_button"); + m_clear_error_button->on_click = [this](auto) { + m_keypad.set_to_0(); + update_display(); }; - widget->m_backspace_button = *widget->find_descendant_of_type_named("backspace_button"); - widget->m_backspace_button->on_click = [self = NonnullRefPtr(widget)](auto) { - self->m_keypad.type_backspace(); - self->update_display(); + m_backspace_button = *find_descendant_of_type_named("backspace_button"); + m_backspace_button->on_click = [this](auto) { + m_keypad.type_backspace(); + update_display(); }; - widget->m_decimal_point_button = *widget->find_descendant_of_type_named("decimal_button"); - widget->m_decimal_point_button->on_click = [self = NonnullRefPtr(widget)](auto) { - self->m_keypad.type_decimal_point(); - self->update_display(); + m_decimal_point_button = *find_descendant_of_type_named("decimal_button"); + m_decimal_point_button->on_click = [this](auto) { + m_keypad.type_decimal_point(); + update_display(); }; - widget->m_sign_button = *widget->find_descendant_of_type_named("sign_button"); - widget->add_operation_button(*widget->m_sign_button, Calculator::Operation::ToggleSign); + m_sign_button = *find_descendant_of_type_named("sign_button"); + add_operation_button(*m_sign_button, Calculator::Operation::ToggleSign); - widget->m_add_button = *widget->find_descendant_of_type_named("add_button"); - widget->add_operation_button(*widget->m_add_button, Calculator::Operation::Add); + m_add_button = *find_descendant_of_type_named("add_button"); + add_operation_button(*m_add_button, Calculator::Operation::Add); - widget->m_subtract_button = *widget->find_descendant_of_type_named("subtract_button"); - widget->add_operation_button(*widget->m_subtract_button, Calculator::Operation::Subtract); + m_subtract_button = *find_descendant_of_type_named("subtract_button"); + add_operation_button(*m_subtract_button, Calculator::Operation::Subtract); - widget->m_multiply_button = *widget->find_descendant_of_type_named("multiply_button"); - widget->add_operation_button(*widget->m_multiply_button, Calculator::Operation::Multiply); + m_multiply_button = *find_descendant_of_type_named("multiply_button"); + add_operation_button(*m_multiply_button, Calculator::Operation::Multiply); - widget->m_divide_button = *widget->find_descendant_of_type_named("divide_button"); - widget->add_operation_button(*widget->m_divide_button, Calculator::Operation::Divide); + m_divide_button = *find_descendant_of_type_named("divide_button"); + add_operation_button(*m_divide_button, Calculator::Operation::Divide); - widget->m_sqrt_button = *widget->find_descendant_of_type_named("sqrt_button"); - widget->add_operation_button(*widget->m_sqrt_button, Calculator::Operation::Sqrt); + m_sqrt_button = *find_descendant_of_type_named("sqrt_button"); + add_operation_button(*m_sqrt_button, Calculator::Operation::Sqrt); - widget->m_inverse_button = *widget->find_descendant_of_type_named("inverse_button"); - widget->add_operation_button(*widget->m_inverse_button, Calculator::Operation::Inverse); + m_inverse_button = *find_descendant_of_type_named("inverse_button"); + add_operation_button(*m_inverse_button, Calculator::Operation::Inverse); - widget->m_percent_button = *widget->find_descendant_of_type_named("mod_button"); - widget->add_operation_button(*widget->m_percent_button, Calculator::Operation::Percent); + m_percent_button = *find_descendant_of_type_named("mod_button"); + add_operation_button(*m_percent_button, Calculator::Operation::Percent); - widget->m_equals_button = *widget->find_descendant_of_type_named("equal_button"); - widget->add_operation_button(*widget->m_equals_button, Calculator::Operation::Equals); + m_equals_button = *find_descendant_of_type_named("equal_button"); + add_operation_button(*m_equals_button, Calculator::Operation::Equals); - return widget; + return {}; } void CalculatorWidget::perform_operation(Calculator::Operation operation) diff --git a/Userland/Applications/Calculator/CalculatorWidget.h b/Userland/Applications/Calculator/CalculatorWidget.h index fc7d2152fc..bb21050a37 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.h +++ b/Userland/Applications/Calculator/CalculatorWidget.h @@ -20,7 +20,8 @@ namespace Calculator { class CalculatorWidget final : public GUI::Widget { C_OBJECT(CalculatorWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual ~CalculatorWidget() override = default; String get_entry(); @@ -34,7 +35,6 @@ public: void set_rounding_custom(GUI::Action& action, StringView); private: - static ErrorOr> try_create(); CalculatorWidget() = default; void add_operation_button(GUI::Button&, Calculator::Operation); diff --git a/Userland/Applications/Calculator/main.cpp b/Userland/Applications/Calculator/main.cpp index 508d95c959..3f36601072 100644 --- a/Userland/Applications/Calculator/main.cpp +++ b/Userland/Applications/Calculator/main.cpp @@ -42,7 +42,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_resizable(false); window->resize(250, 215); - auto widget = TRY(Calculator::CalculatorWidget::create()); + auto widget = TRY(Calculator::CalculatorWidget::try_create()); window->set_main_widget(widget.ptr()); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp index a76beebb9b..4513cfbf6b 100644 --- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp +++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.cpp @@ -30,14 +30,7 @@ void CalendarSettingsWidget::reset_default_values() m_default_view_combobox->set_text("Month"); } -ErrorOr> CalendarSettingsWidget::create() -{ - auto widget = TRY(try_create()); - TRY(widget->setup()); - return widget; -} - -ErrorOr CalendarSettingsWidget::setup() +ErrorOr CalendarSettingsWidget::initialize() { m_first_day_of_week_combobox = *find_descendant_of_type_named("first_day_of_week"); m_first_day_of_week_combobox->set_text(Config::read_string("Calendar"sv, "View"sv, "FirstDayOfWeek"sv, "Sunday"sv)); diff --git a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h index 9a8d90e10f..f49c12b2cf 100644 --- a/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h +++ b/Userland/Applications/CalendarSettings/CalendarSettingsWidget.h @@ -15,16 +15,15 @@ class CalendarSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(CalendarSettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override; virtual void reset_default_values() override; private: CalendarSettingsWidget() = default; - static ErrorOr> try_create(); - ErrorOr setup(); static constexpr Array const m_view_modes = { "Month"sv, "Year"sv }; RefPtr m_first_day_of_week_combobox; diff --git a/Userland/Applications/CalendarSettings/main.cpp b/Userland/Applications/CalendarSettings/main.cpp index 31f735b6a7..0bada88e60 100644 --- a/Userland/Applications/CalendarSettings/main.cpp +++ b/Userland/Applications/CalendarSettings/main.cpp @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app_icon = GUI::Icon::default_icon("app-calendar"sv); auto window = TRY(GUI::SettingsWindow::create("Calendar Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); - (void)TRY(window->add_tab(TRY(CalendarSettings::CalendarSettingsWidget::create()), "Calendar"_string, "Calendar"sv)); + (void)TRY(window->add_tab("Calendar"_string, "Calendar"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->set_active_tab(selected_tab); diff --git a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp index ecb8d9f0c6..388f1ea8be 100644 --- a/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp +++ b/Userland/Applications/CertificateSettings/CertificateStoreWidget.cpp @@ -151,13 +151,6 @@ ErrorOr CertificateStoreWidget::export_pem() return {}; } -ErrorOr> CertificateStoreWidget::create() -{ - auto widget = TRY(CertificateStoreWidget::try_create()); - TRY(widget->initialize()); - return widget; -} - ErrorOr CertificateStoreWidget::initialize() { m_root_ca_tableview = find_descendant_of_type_named("root_ca_tableview"); diff --git a/Userland/Applications/CertificateSettings/CertificateStoreWidget.h b/Userland/Applications/CertificateSettings/CertificateStoreWidget.h index e05b20e874..b952783793 100644 --- a/Userland/Applications/CertificateSettings/CertificateStoreWidget.h +++ b/Userland/Applications/CertificateSettings/CertificateStoreWidget.h @@ -58,14 +58,13 @@ class CertificateStoreWidget : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(CertStoreWidget) public: virtual ~CertificateStoreWidget() override = default; - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override {}; private: - static ErrorOr> try_create(); CertificateStoreWidget() = default; - ErrorOr initialize(); ErrorOr import_pem(); ErrorOr export_pem(); diff --git a/Userland/Applications/CertificateSettings/main.cpp b/Userland/Applications/CertificateSettings/main.cpp index df2d225248..7d0cd6084a 100644 --- a/Userland/Applications/CertificateSettings/main.cpp +++ b/Userland/Applications/CertificateSettings/main.cpp @@ -28,7 +28,7 @@ ErrorOr serenity_main(Main::Arguments args) auto app_icon = GUI::Icon::default_icon("certificate"sv); auto window = TRY(GUI::SettingsWindow::create("Certificate Settings", GUI::SettingsWindow::ShowDefaultsButton::No)); - TRY(window->add_tab(TRY(CertificateSettings::CertificateStoreWidget::create()), "Certificate Store"_string, "certificate"sv)); + (void)TRY(window->add_tab("Certificate Store"_string, "certificate"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->show(); diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp index fda40fcc06..5f2fac201f 100644 --- a/Userland/Applications/GamesSettings/CardSettingsWidget.cpp +++ b/Userland/Applications/GamesSettings/CardSettingsWidget.cpp @@ -61,13 +61,6 @@ void CardGamePreview::paint_event(GUI::PaintEvent& event) stack->paint(painter, background_color); } -ErrorOr> CardSettingsWidget::create() -{ - auto card_settings_widget = TRY(try_create()); - TRY(card_settings_widget->initialize()); - return card_settings_widget; -} - ErrorOr CardSettingsWidget::initialize() { auto background_color = Gfx::Color::from_string(Config::read_string("Games"sv, "Cards"sv, "BackgroundColor"sv)).value_or(Gfx::Color::from_rgb(0x008000)); diff --git a/Userland/Applications/GamesSettings/CardSettingsWidget.h b/Userland/Applications/GamesSettings/CardSettingsWidget.h index e75dcb4615..d7231fa80f 100644 --- a/Userland/Applications/GamesSettings/CardSettingsWidget.h +++ b/Userland/Applications/GamesSettings/CardSettingsWidget.h @@ -21,7 +21,7 @@ class CardSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(CardSettingsWidget) public: static ErrorOr> try_create(); - static ErrorOr> create(); + ErrorOr initialize(); virtual ~CardSettingsWidget() override = default; virtual void apply_settings() override; @@ -29,7 +29,6 @@ public: private: CardSettingsWidget() = default; - ErrorOr initialize(); bool set_card_back_image_path(StringView); String card_back_image_path() const; diff --git a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp index 19a63a477d..e5766e6916 100644 --- a/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp +++ b/Userland/Applications/GamesSettings/ChessSettingsWidget.cpp @@ -231,13 +231,6 @@ void ChessGamePreview::paint_event(GUI::PaintEvent& event) } } -ErrorOr> ChessSettingsWidget::create() -{ - auto chess_settings_widget = TRY(try_create()); - TRY(chess_settings_widget->initialize()); - return chess_settings_widget; -} - ErrorOr ChessSettingsWidget::initialize() { auto piece_set_name = Config::read_string("Games"sv, "Chess"sv, "PieceSet"sv, "Classic"sv); diff --git a/Userland/Applications/GamesSettings/ChessSettingsWidget.h b/Userland/Applications/GamesSettings/ChessSettingsWidget.h index 26b743dbe3..9f7de5c652 100644 --- a/Userland/Applications/GamesSettings/ChessSettingsWidget.h +++ b/Userland/Applications/GamesSettings/ChessSettingsWidget.h @@ -18,7 +18,7 @@ class ChessSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(ChessSettingsWidget) public: static ErrorOr> try_create(); - static ErrorOr> create(); + ErrorOr initialize(); virtual ~ChessSettingsWidget() override = default; virtual void apply_settings() override; @@ -26,7 +26,6 @@ public: private: ChessSettingsWidget() = default; - ErrorOr initialize(); Vector m_piece_sets; diff --git a/Userland/Applications/GamesSettings/main.cpp b/Userland/Applications/GamesSettings/main.cpp index 2b84e785b5..7f4cb56d6d 100644 --- a/Userland/Applications/GamesSettings/main.cpp +++ b/Userland/Applications/GamesSettings/main.cpp @@ -35,10 +35,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::SettingsWindow::create("Games Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); window->set_icon(app_icon.bitmap_for_size(16)); - auto widget_cards = TRY(GamesSettings::CardSettingsWidget::create()); - auto widget_chess = TRY(GamesSettings::ChessSettingsWidget::create()); - (void)TRY(window->add_tab(widget_cards, "Cards"_string, "cards"sv)); - (void)TRY(window->add_tab(widget_chess, "Chess"_string, "chess"sv)); + (void)TRY(window->add_tab("Cards"_string, "cards"sv)); + (void)TRY(window->add_tab("Chess"_string, "chess"sv)); window->set_active_tab(selected_tab); window->show(); diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index 11db33708f..de19b10497 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -61,7 +61,7 @@ ErrorOr MainWidget::set_start_page(Vector query_parameters) return {}; } -ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) +ErrorOr MainWidget::initialize(GUI::Window& window) { m_toolbar = find_descendant_of_type_named("toolbar"); m_tab_widget = find_descendant_of_type_named("tab_widget"); diff --git a/Userland/Applications/Help/MainWidget.h b/Userland/Applications/Help/MainWidget.h index f004a2d494..f56c0c2c0e 100644 --- a/Userland/Applications/Help/MainWidget.h +++ b/Userland/Applications/Help/MainWidget.h @@ -21,7 +21,7 @@ public: static ErrorOr> try_create(); - ErrorOr initialize_fallibles(GUI::Window&); + ErrorOr initialize(GUI::Window&); ErrorOr set_start_page(Vector query_parameters); private: diff --git a/Userland/Applications/Help/main.cpp b/Userland/Applications/Help/main.cpp index d4ab1fe696..0afc99cd0f 100644 --- a/Userland/Applications/Help/main.cpp +++ b/Userland/Applications/Help/main.cpp @@ -63,7 +63,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto main_widget = TRY(MainWidget::try_create()); window->set_main_widget(main_widget); - TRY(main_widget->initialize_fallibles(window)); + TRY(main_widget->initialize(window)); TRY(main_widget->set_start_page(query_parameters)); window->show(); diff --git a/Userland/Applications/Maps/FavoritesPanel.cpp b/Userland/Applications/Maps/FavoritesPanel.cpp index 7700ff14ac..6bca950a34 100644 --- a/Userland/Applications/Maps/FavoritesPanel.cpp +++ b/Userland/Applications/Maps/FavoritesPanel.cpp @@ -15,14 +15,7 @@ namespace Maps { -ErrorOr> FavoritesPanel::create() -{ - auto widget = TRY(try_create()); - TRY(widget->setup()); - return widget; -} - -ErrorOr FavoritesPanel::setup() +ErrorOr FavoritesPanel::initialize() { m_empty_container = *find_descendant_of_type_named("empty_container"); m_favorites_list = *find_descendant_of_type_named("favorites_list"); diff --git a/Userland/Applications/Maps/FavoritesPanel.h b/Userland/Applications/Maps/FavoritesPanel.h index bda6718779..dc4c183d06 100644 --- a/Userland/Applications/Maps/FavoritesPanel.h +++ b/Userland/Applications/Maps/FavoritesPanel.h @@ -22,7 +22,8 @@ public: MapWidget::LatLng latlng; int zoom; }; - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); void load_favorites(); void reset(); @@ -34,10 +35,6 @@ public: protected: FavoritesPanel() = default; - static ErrorOr> try_create(); - - ErrorOr setup(); - private: ErrorOr edit_favorite(int row); void favorites_changed(); diff --git a/Userland/Applications/Maps/SearchPanel.cpp b/Userland/Applications/Maps/SearchPanel.cpp index 6ec5ca27e9..b5ec9410d2 100644 --- a/Userland/Applications/Maps/SearchPanel.cpp +++ b/Userland/Applications/Maps/SearchPanel.cpp @@ -9,14 +9,7 @@ namespace Maps { -ErrorOr> SearchPanel::create() -{ - auto widget = TRY(try_create()); - TRY(widget->setup()); - return widget; -} - -ErrorOr SearchPanel::setup() +ErrorOr SearchPanel::initialize() { m_request_client = TRY(Protocol::RequestClient::try_create()); diff --git a/Userland/Applications/Maps/SearchPanel.h b/Userland/Applications/Maps/SearchPanel.h index 1e9337f007..7f32f8109b 100644 --- a/Userland/Applications/Maps/SearchPanel.h +++ b/Userland/Applications/Maps/SearchPanel.h @@ -21,7 +21,8 @@ class SearchPanel final : public GUI::Widget { C_OBJECT(SearchPanel) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); void search(StringView query); void reset(); @@ -37,10 +38,6 @@ public: private: SearchPanel() = default; - static ErrorOr> try_create(); - - ErrorOr setup(); - RefPtr m_request_client; RefPtr m_request; RefPtr m_search_textbox; diff --git a/Userland/Applications/Maps/main.cpp b/Userland/Applications/Maps/main.cpp index d409aed446..eeed1c9304 100644 --- a/Userland/Applications/Maps/main.cpp +++ b/Userland/Applications/Maps/main.cpp @@ -72,7 +72,7 @@ ErrorOr serenity_main(Main::Arguments arguments) int panel_width = Config::read_i32("Maps"sv, "Panel"sv, "Width"sv, INT_MIN); // Search panel - auto search_panel = TRY(Maps::SearchPanel::create()); + auto search_panel = TRY(Maps::SearchPanel::try_create()); search_panel->on_places_change = [&map_widget](auto) { map_widget.remove_markers_with_name("search"sv); }; search_panel->on_selected_place_change = [&map_widget](auto const& place) { // Remove old search marker @@ -105,7 +105,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // Favorites panel auto marker_red_image = TRY(Gfx::Bitmap::load_from_file("/res/graphics/maps/marker-red.png"sv)); - auto favorites_panel = TRY(Maps::FavoritesPanel::create()); + auto favorites_panel = TRY(Maps::FavoritesPanel::try_create()); favorites_panel->on_favorites_change = [&map_widget, marker_red_image](auto const& favorites) { // Sync all favorites markers map_widget.remove_markers_with_name("favorites"sv); diff --git a/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp b/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp index 9d94d26a0b..247ace46f0 100644 --- a/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp +++ b/Userland/Applications/MapsSettings/MapsSettingsWidget.cpp @@ -14,13 +14,6 @@ namespace MapsSettings { -ErrorOr> MapsSettingsWidget::create() -{ - auto widget = TRY(try_create()); - TRY(widget->setup()); - return widget; -} - void MapsSettingsWidget::apply_settings() { // Tile Provider @@ -43,7 +36,7 @@ void MapsSettingsWidget::reset_default_values() set_tile_provider(Maps::default_tile_provider_url_format); } -ErrorOr MapsSettingsWidget::setup() +ErrorOr MapsSettingsWidget::initialize() { // Tile Provider Vector tile_provider_fields; diff --git a/Userland/Applications/MapsSettings/MapsSettingsWidget.h b/Userland/Applications/MapsSettings/MapsSettingsWidget.h index 78ca46ec3f..f25dd3e7ac 100644 --- a/Userland/Applications/MapsSettings/MapsSettingsWidget.h +++ b/Userland/Applications/MapsSettings/MapsSettingsWidget.h @@ -14,16 +14,15 @@ class MapsSettingsWidget final : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(MapsSettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override; virtual void reset_default_values() override; private: MapsSettingsWidget() = default; - static ErrorOr> try_create(); - ErrorOr setup(); void set_tile_provider(StringView url); RefPtr m_tile_provider_combobox; diff --git a/Userland/Applications/MapsSettings/main.cpp b/Userland/Applications/MapsSettings/main.cpp index 1fd1aeebaf..0e8f370d78 100644 --- a/Userland/Applications/MapsSettings/main.cpp +++ b/Userland/Applications/MapsSettings/main.cpp @@ -27,7 +27,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::SettingsWindow::create("Maps Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); window->set_icon(app_icon.bitmap_for_size(16)); - (void)TRY(window->add_tab(TRY(MapsSettings::MapsSettingsWidget::create()), "Maps"_string, "maps"sv)); + (void)TRY(window->add_tab("Maps"_string, "maps"sv)); window->show(); return app->exec(); diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp index b6d284f4e4..e45a3fe4b4 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp @@ -29,14 +29,7 @@ static int netmask_to_cidr(IPv4Address const& address) return 32 - count_trailing_zeroes_safe(address_in_host_representation); } -ErrorOr> NetworkSettingsWidget::create() -{ - auto widget = TRY(try_create()); - TRY(widget->setup()); - return widget; -} - -ErrorOr NetworkSettingsWidget::setup() +ErrorOr NetworkSettingsWidget::initialize() { m_adapters_combobox = *find_descendant_of_type_named("adapters_combobox"); m_enabled_checkbox = *find_descendant_of_type_named("enabled_checkbox"); diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h index 7b739e30db..7f47de017b 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.h @@ -16,17 +16,14 @@ class NetworkSettingsWidget : public GUI::SettingsWindow::Tab { C_OBJECT_ABSTRACT(NetworkSettingsWidget) public: - static ErrorOr> create(); + static ErrorOr> try_create(); + ErrorOr initialize(); virtual void apply_settings() override; void switch_adapter(ByteString const& adapter); -protected: - static ErrorOr> try_create(); - private: NetworkSettingsWidget() = default; - ErrorOr setup(); struct NetworkAdapterData { bool enabled = false; diff --git a/Userland/Applications/NetworkSettings/main.cpp b/Userland/Applications/NetworkSettings/main.cpp index 889dd8e38d..eb6f58d830 100644 --- a/Userland/Applications/NetworkSettings/main.cpp +++ b/Userland/Applications/NetworkSettings/main.cpp @@ -37,7 +37,7 @@ ErrorOr serenity_main(Main::Arguments args) auto app_icon = GUI::Icon::default_icon("network"sv); auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No)); - auto network_settings_widget = TRY(NetworkSettings::NetworkSettingsWidget::create()); + auto network_settings_widget = TRY(NetworkSettings::NetworkSettingsWidget::try_create()); TRY(window->add_tab(network_settings_widget, "Network"_string, "network"sv)); if (!adapter.is_null()) { network_settings_widget->switch_adapter(adapter); diff --git a/Userland/Applications/Piano/ExportProgressWindow.cpp b/Userland/Applications/Piano/ExportProgressWindow.cpp index 8b40e28660..a109d90a6d 100644 --- a/Userland/Applications/Piano/ExportProgressWindow.cpp +++ b/Userland/Applications/Piano/ExportProgressWindow.cpp @@ -18,7 +18,7 @@ ExportProgressWindow::ExportProgressWindow(GUI::Window& parent_window, Atomic ExportProgressWindow::initialize_fallibles() +ErrorOr ExportProgressWindow::initialize() { auto main_widget = set_main_widget(); TRY(main_widget->load_from_gml(export_progress_widget)); diff --git a/Userland/Applications/Piano/ExportProgressWindow.h b/Userland/Applications/Piano/ExportProgressWindow.h index d5a0e6a0d5..afb885fefd 100644 --- a/Userland/Applications/Piano/ExportProgressWindow.h +++ b/Userland/Applications/Piano/ExportProgressWindow.h @@ -17,7 +17,7 @@ class ExportProgressWindow : public GUI::Dialog { public: virtual ~ExportProgressWindow() override = default; - ErrorOr initialize_fallibles(); + ErrorOr initialize(); virtual void timer_event(Core::TimerEvent&) override; diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 4131c0259b..970193b752 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -52,7 +52,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_icon(app_icon.bitmap_for_size(16)); auto wav_progress_window = ExportProgressWindow::construct(*window, wav_percent_written); - TRY(wav_progress_window->initialize_fallibles()); + TRY(wav_progress_window->initialize()); auto main_widget_updater = TRY(Core::Timer::create_repeating(static_cast((1 / 30.0) * 1000), [&] { if (window->is_active()) diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 7862fbed18..72c4ef4eab 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -24,16 +24,7 @@ namespace VideoPlayer { -ErrorOr> VideoPlayerWidget::create() -{ - auto main_widget = TRY(try_create()); - - TRY(main_widget->setup_interface()); - - return main_widget; -} - -ErrorOr VideoPlayerWidget::setup_interface() +ErrorOr VideoPlayerWidget::initialize() { m_video_display = find_descendant_of_type_named("video_frame"); m_video_display->on_click = [&]() { toggle_pause(); }; diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h index 3275bc5155..e51ae33634 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h @@ -25,7 +25,7 @@ class VideoPlayerWidget final : public GUI::Widget { public: static ErrorOr> try_create(); - static ErrorOr> create(); + ErrorOr initialize(); virtual ~VideoPlayerWidget() override = default; void close_file(); void open_file(FileSystemAccessClient::File filename); @@ -43,7 +43,6 @@ public: private: VideoPlayerWidget() = default; - ErrorOr setup_interface(); void update_play_pause_icon(); void update_seek_slider_max(); void set_current_timestamp(Duration); diff --git a/Userland/Applications/VideoPlayer/main.cpp b/Userland/Applications/VideoPlayer/main.cpp index 58166dad1a..97d485548d 100644 --- a/Userland/Applications/VideoPlayer/main.cpp +++ b/Userland/Applications/VideoPlayer/main.cpp @@ -34,7 +34,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto main_widget = TRY(VideoPlayer::VideoPlayerWidget::create()); + auto main_widget = TRY(VideoPlayer::VideoPlayerWidget::try_create()); window->set_main_widget(main_widget); main_widget->update_title(); TRY(main_widget->initialize_menubar(window));