summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-01-06 16:48:37 +0000
committerAndrew Kaster <andrewdkaster@gmail.com>2023-01-06 13:36:02 -0700
commit0c24522635ec7f07e1fb69d9e1cd350d81e2248f (patch)
tree391782374bada7ee7a986674229551c2ec21f75a /Userland/Libraries/LibGUI
parentd223477bc650e271008ccc339fc1e2c0fcc079e7 (diff)
downloadserenity-0c24522635ec7f07e1fb69d9e1cd350d81e2248f.zip
LibGUI+Everywhere: Use fallible Window::set_main_widget() everywhere :^)
Rip that bandaid off! This does the following, in one big, awkward jump: - Replace all uses of `set_main_widget<Foo>()` with the `try` version. - Remove `set_main_widget<Foo>()`. - Rename the `try` version to just be `set_main_widget` because it's now the only one. The majority of places that call `set_main_widget<Foo>()` are inside constructors, so this unfortunately gives us a big batch of new `release_value_but_fixme_should_propagate_errors()` calls.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AboutDialog.cpp12
-rw-r--r--Userland/Libraries/LibGUI/Application.cpp2
-rw-r--r--Userland/Libraries/LibGUI/AutocompleteProvider.cpp10
-rw-r--r--Userland/Libraries/LibGUI/ColorPicker.cpp12
-rw-r--r--Userland/Libraries/LibGUI/ComboBox.cpp2
-rw-r--r--Userland/Libraries/LibGUI/CommandPalette.cpp12
-rw-r--r--Userland/Libraries/LibGUI/EmojiInputDialog.cpp12
-rw-r--r--Userland/Libraries/LibGUI/FilePicker.cpp18
-rw-r--r--Userland/Libraries/LibGUI/FontPicker.cpp18
-rw-r--r--Userland/Libraries/LibGUI/InputBox.cpp22
-rw-r--r--Userland/Libraries/LibGUI/MessageBox.cpp18
-rw-r--r--Userland/Libraries/LibGUI/PasswordInputDialog.cpp16
-rw-r--r--Userland/Libraries/LibGUI/ProcessChooser.cpp10
-rw-r--r--Userland/Libraries/LibGUI/SettingsWindow.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Window.h10
-rw-r--r--Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp14
16 files changed, 91 insertions, 99 deletions
diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp
index d75d3e0cec..692736e7ae 100644
--- a/Userland/Libraries/LibGUI/AboutDialog.cpp
+++ b/Userland/Libraries/LibGUI/AboutDialog.cpp
@@ -30,15 +30,15 @@ AboutDialog::AboutDialog(StringView name, StringView version, Gfx::Bitmap const*
if (parent_window)
set_icon(parent_window->icon());
- auto& widget = set_main_widget<Widget>();
- widget.set_fill_with_background_color(true);
- widget.set_layout<VerticalBoxLayout>();
- widget.layout()->set_spacing(0);
+ auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
+ widget->set_fill_with_background_color(true);
+ widget->set_layout<VerticalBoxLayout>();
+ widget->layout()->set_spacing(0);
- auto& banner_image = widget.add<GUI::ImageWidget>();
+ auto& banner_image = widget->add<GUI::ImageWidget>();
banner_image.load_from_file("/res/graphics/brand-banner.png"sv);
- auto& content_container = widget.add<Widget>();
+ auto& content_container = widget->add<Widget>();
content_container.set_layout<HorizontalBoxLayout>();
auto& left_container = content_container.add<Widget>();
diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp
index 1d78929107..9b38932d66 100644
--- a/Userland/Libraries/LibGUI/Application.cpp
+++ b/Userland/Libraries/LibGUI/Application.cpp
@@ -44,7 +44,7 @@ private:
{
set_window_type(WindowType::Tooltip);
set_obey_widget_min_size(false);
- m_label = set_main_widget<Label>();
+ m_label = set_main_widget<Label>().release_value_but_fixme_should_propagate_errors();
m_label->set_background_role(Gfx::ColorRole::Tooltip);
m_label->set_foreground_role(Gfx::ColorRole::TooltipText);
m_label->set_fill_with_background_color(true);
diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
index b71fb4fc1b..fb450d9ae7 100644
--- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
+++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
@@ -92,11 +92,11 @@ AutocompleteBox::AutocompleteBox(TextEditor& editor)
m_popup_window->set_obey_widget_min_size(false);
m_popup_window->set_rect(0, 0, 175, 25);
- auto& main_widget = m_popup_window->set_main_widget<GUI::Widget>();
- main_widget.set_fill_with_background_color(true);
- main_widget.set_layout<GUI::VerticalBoxLayout>();
+ auto main_widget = m_popup_window->set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
+ main_widget->set_fill_with_background_color(true);
+ main_widget->set_layout<GUI::VerticalBoxLayout>();
- m_suggestion_view = main_widget.add<GUI::TableView>();
+ m_suggestion_view = main_widget->add<GUI::TableView>();
m_suggestion_view->set_frame_shadow(Gfx::FrameShadow::Plain);
m_suggestion_view->set_frame_thickness(1);
m_suggestion_view->set_column_headers_visible(false);
@@ -109,7 +109,7 @@ AutocompleteBox::AutocompleteBox(TextEditor& editor)
apply_suggestion();
};
- m_no_suggestions_view = main_widget.add<GUI::Label>("No suggestions");
+ m_no_suggestions_view = main_widget->add<GUI::Label>("No suggestions");
}
void AutocompleteBox::update_suggestions(Vector<CodeComprehension::AutocompleteResultEntry>&& suggestions)
diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp
index f8a640fdcc..7dac2fe557 100644
--- a/Userland/Libraries/LibGUI/ColorPicker.cpp
+++ b/Userland/Libraries/LibGUI/ColorPicker.cpp
@@ -206,12 +206,12 @@ void ColorPicker::set_color_has_alpha_channel(bool has_alpha)
void ColorPicker::build_ui()
{
- auto& root_container = set_main_widget<Widget>();
- root_container.set_layout<VerticalBoxLayout>();
- root_container.layout()->set_margins(4);
- root_container.set_fill_with_background_color(true);
+ auto root_container = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
+ root_container->set_layout<VerticalBoxLayout>();
+ root_container->layout()->set_margins(4);
+ root_container->set_fill_with_background_color(true);
- auto& tab_widget = root_container.add<GUI::TabWidget>();
+ auto& tab_widget = root_container->add<GUI::TabWidget>();
auto& tab_palette = tab_widget.add_tab<Widget>("Palette");
tab_palette.set_layout<VerticalBoxLayout>();
@@ -227,7 +227,7 @@ void ColorPicker::build_ui()
build_ui_custom(tab_custom_color);
- auto& button_container = root_container.add<Widget>();
+ auto& button_container = root_container->add<Widget>();
button_container.set_preferred_height(GUI::SpecialDimension::Fit);
button_container.set_layout<HorizontalBoxLayout>();
button_container.layout()->set_spacing(4);
diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp
index 7d95f2e26b..88eba5a0de 100644
--- a/Userland/Libraries/LibGUI/ComboBox.cpp
+++ b/Userland/Libraries/LibGUI/ComboBox.cpp
@@ -116,7 +116,7 @@ ComboBox::ComboBox()
m_list_window = add<Window>(window());
m_list_window->set_window_type(GUI::WindowType::Popup);
- m_list_view = m_list_window->set_main_widget<ListView>();
+ m_list_view = m_list_window->set_main_widget<ListView>().release_value_but_fixme_should_propagate_errors();
m_list_view->set_should_hide_unnecessary_scrollbars(true);
m_list_view->set_alternating_row_colors(false);
m_list_view->set_hover_highlighting(true);
diff --git a/Userland/Libraries/LibGUI/CommandPalette.cpp b/Userland/Libraries/LibGUI/CommandPalette.cpp
index 52a4501d69..2d2ad31f7d 100644
--- a/Userland/Libraries/LibGUI/CommandPalette.cpp
+++ b/Userland/Libraries/LibGUI/CommandPalette.cpp
@@ -182,15 +182,15 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen
collect_actions(parent_window);
- auto& main_widget = set_main_widget<GUI::Frame>();
- main_widget.set_frame_shape(Gfx::FrameShape::Window);
- main_widget.set_fill_with_background_color(true);
+ auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
+ main_widget->set_frame_shape(Gfx::FrameShape::Window);
+ main_widget->set_fill_with_background_color(true);
- auto& layout = main_widget.set_layout<GUI::VerticalBoxLayout>();
+ auto& layout = main_widget->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins(4);
- m_text_box = main_widget.add<GUI::TextBox>();
- m_table_view = main_widget.add<GUI::TableView>();
+ m_text_box = main_widget->add<GUI::TextBox>();
+ m_table_view = main_widget->add<GUI::TableView>();
m_model = adopt_ref(*new ActionModel(m_actions));
m_table_view->set_column_headers_visible(false);
diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
index 1cc0dff127..f4d99562d5 100644
--- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
+++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp
@@ -92,8 +92,8 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
: Dialog(parent_window)
, m_category_action_group(make<ActionGroup>())
{
- auto& main_widget = set_main_widget<Frame>();
- if (!main_widget.load_from_gml(emoji_input_dialog_gml))
+ auto main_widget = set_main_widget<Frame>().release_value_but_fixme_should_propagate_errors();
+ if (!main_widget->load_from_gml(emoji_input_dialog_gml))
VERIFY_NOT_REACHED();
set_window_type(GUI::WindowType::Popup);
@@ -101,10 +101,10 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
set_blocks_emoji_input(true);
resize(400, 300);
- auto& scrollable_container = *main_widget.find_descendant_of_type_named<GUI::ScrollableContainerWidget>("scrollable_container"sv);
- m_search_box = main_widget.find_descendant_of_type_named<GUI::TextBox>("search_box"sv);
- m_toolbar = main_widget.find_descendant_of_type_named<GUI::Toolbar>("toolbar"sv);
- m_emojis_widget = main_widget.find_descendant_of_type_named<GUI::Widget>("emojis"sv);
+ auto& scrollable_container = *main_widget->find_descendant_of_type_named<GUI::ScrollableContainerWidget>("scrollable_container"sv);
+ m_search_box = main_widget->find_descendant_of_type_named<GUI::TextBox>("search_box"sv);
+ m_toolbar = main_widget->find_descendant_of_type_named<GUI::Toolbar>("toolbar"sv);
+ m_emojis_widget = main_widget->find_descendant_of_type_named<GUI::Widget>("emojis"sv);
m_emojis = supported_emoji();
m_category_action_group->set_exclusive(true);
diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp
index 0998ecdf79..93cbc3d2d8 100644
--- a/Userland/Libraries/LibGUI/FilePicker.cpp
+++ b/Userland/Libraries/LibGUI/FilePicker.cpp
@@ -84,16 +84,16 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
}
resize(560, 320);
- auto& widget = set_main_widget<GUI::Widget>();
- if (!widget.load_from_gml(file_picker_dialog_gml))
+ auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
+ if (!widget->load_from_gml(file_picker_dialog_gml))
VERIFY_NOT_REACHED();
- auto& toolbar = *widget.find_descendant_of_type_named<GUI::Toolbar>("toolbar");
+ auto& toolbar = *widget->find_descendant_of_type_named<GUI::Toolbar>("toolbar");
- m_location_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("location_textbox");
+ m_location_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("location_textbox");
m_location_textbox->set_text(path);
- m_view = *widget.find_descendant_of_type_named<GUI::MultiView>("view");
+ m_view = *widget->find_descendant_of_type_named<GUI::MultiView>("view");
m_view->set_selection_mode(m_mode == Mode::OpenMultiple ? GUI::AbstractView::SelectionMode::MultiSelection : GUI::AbstractView::SelectionMode::SingleSelection);
m_view->set_model(MUST(SortingProxyModel::create(*m_model)));
m_view->set_model_column(FileSystemModel::Column::Name);
@@ -150,7 +150,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
toolbar.add_action(m_view->view_as_table_action());
toolbar.add_action(m_view->view_as_columns_action());
- m_filename_textbox = *widget.find_descendant_of_type_named<GUI::TextBox>("filename_textbox");
+ m_filename_textbox = *widget->find_descendant_of_type_named<GUI::TextBox>("filename_textbox");
m_filename_textbox->set_focus(true);
if (m_mode == Mode::Save) {
LexicalPath lexical_filename { filename };
@@ -183,14 +183,14 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
}
};
- auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
+ auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.set_text(ok_button_name(m_mode));
ok_button.on_click = [this](auto) {
on_file_return();
};
ok_button.set_enabled(m_mode == Mode::OpenFolder || !m_filename_textbox->text().is_empty());
- auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
+ auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.set_text("Cancel");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
@@ -237,7 +237,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
m_view->view_as_columns_action().set_enabled(false);
};
- auto& common_locations_tray = *widget.find_descendant_of_type_named<GUI::Tray>("common_locations_tray");
+ auto& common_locations_tray = *widget->find_descendant_of_type_named<GUI::Tray>("common_locations_tray");
m_model->on_complete = [&] {
m_view->set_active_widget(&m_view->current_view());
for (auto& location_button : m_common_location_buttons)
diff --git a/Userland/Libraries/LibGUI/FontPicker.cpp b/Userland/Libraries/LibGUI/FontPicker.cpp
index 78479bba22..0ba0b36600 100644
--- a/Userland/Libraries/LibGUI/FontPicker.cpp
+++ b/Userland/Libraries/LibGUI/FontPicker.cpp
@@ -26,26 +26,26 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo
resize(430, 280);
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors());
- auto& widget = set_main_widget<GUI::Widget>();
- if (!widget.load_from_gml(font_picker_dialog_gml))
+ auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
+ if (!widget->load_from_gml(font_picker_dialog_gml))
VERIFY_NOT_REACHED();
- m_family_list_view = *widget.find_descendant_of_type_named<ListView>("family_list_view");
+ m_family_list_view = *widget->find_descendant_of_type_named<ListView>("family_list_view");
m_family_list_view->set_model(ItemListModel<DeprecatedString>::create(m_families));
m_family_list_view->horizontal_scrollbar().set_visible(false);
- m_variant_list_view = *widget.find_descendant_of_type_named<ListView>("variant_list_view");
+ m_variant_list_view = *widget->find_descendant_of_type_named<ListView>("variant_list_view");
m_variant_list_view->set_model(ItemListModel<DeprecatedString>::create(m_variants));
m_variant_list_view->horizontal_scrollbar().set_visible(false);
- m_size_spin_box = *widget.find_descendant_of_type_named<SpinBox>("size_spin_box");
+ m_size_spin_box = *widget->find_descendant_of_type_named<SpinBox>("size_spin_box");
m_size_spin_box->set_range(1, 255);
- m_size_list_view = *widget.find_descendant_of_type_named<ListView>("size_list_view");
+ m_size_list_view = *widget->find_descendant_of_type_named<ListView>("size_list_view");
m_size_list_view->set_model(ItemListModel<int>::create(m_sizes));
m_size_list_view->horizontal_scrollbar().set_visible(false);
- m_sample_text_label = *widget.find_descendant_of_type_named<Label>("sample_text_label");
+ m_sample_text_label = *widget->find_descendant_of_type_named<Label>("sample_text_label");
m_families.clear();
Gfx::FontDatabase::the().for_each_typeface([&](auto& typeface) {
@@ -157,13 +157,13 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo
update_font();
};
- auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
+ auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.on_click = [this](auto) {
done(ExecResult::OK);
};
ok_button.set_default(true);
- auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
+ auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.on_click = [this](auto) {
done(ExecResult::Cancel);
};
diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp
index d107c1a908..aae71d07b6 100644
--- a/Userland/Libraries/LibGUI/InputBox.cpp
+++ b/Userland/Libraries/LibGUI/InputBox.cpp
@@ -49,20 +49,20 @@ void InputBox::on_done(ExecResult result)
void InputBox::build(InputType input_type)
{
- auto& widget = set_main_widget<Widget>();
+ auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
- int text_width = widget.font().width(m_prompt);
- int title_width = widget.font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
+ int text_width = widget->font().width(m_prompt);
+ int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
int max_width = max(text_width, title_width);
- widget.set_layout<VerticalBoxLayout>();
- widget.set_fill_with_background_color(true);
- widget.set_preferred_height(SpecialDimension::Fit);
+ widget->set_layout<VerticalBoxLayout>();
+ widget->set_fill_with_background_color(true);
+ widget->set_preferred_height(SpecialDimension::Fit);
- widget.layout()->set_margins(6);
- widget.layout()->set_spacing(6);
+ widget->layout()->set_margins(6);
+ widget->layout()->set_spacing(6);
- auto& label_editor_container = widget.add<Widget>();
+ auto& label_editor_container = widget->add<Widget>();
label_editor_container.set_layout<HorizontalBoxLayout>();
label_editor_container.set_preferred_height(SpecialDimension::Fit);
@@ -83,7 +83,7 @@ void InputBox::build(InputType input_type)
if (!m_placeholder.is_null())
m_text_editor->set_placeholder(m_placeholder);
- auto& button_container_outer = widget.add<Widget>();
+ auto& button_container_outer = widget->add<Widget>();
button_container_outer.set_preferred_height(SpecialDimension::Fit);
button_container_outer.set_layout<VerticalBoxLayout>();
@@ -113,7 +113,7 @@ void InputBox::build(InputType input_type)
};
m_text_editor->set_focus(true);
- set_rect(x(), y(), max_width + 140, widget.effective_preferred_size().height().as_int());
+ set_rect(x(), y(), max_width + 140, widget->effective_preferred_size().height().as_int());
}
}
diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp
index 518af0a350..8f6ab7a3d9 100644
--- a/Userland/Libraries/LibGUI/MessageBox.cpp
+++ b/Userland/Libraries/LibGUI/MessageBox.cpp
@@ -110,21 +110,21 @@ bool MessageBox::should_include_no_button() const
void MessageBox::build()
{
- auto& widget = set_main_widget<Widget>();
+ auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
- int text_width = widget.font().width(m_text);
+ int text_width = widget->font().width(m_text);
auto number_of_lines = m_text.split('\n').size();
- int padded_text_height = widget.font().glyph_height() * 1.6;
+ int padded_text_height = widget->font().glyph_height() * 1.6;
int total_text_height = number_of_lines * padded_text_height;
int icon_width = 0;
- widget.set_layout<VerticalBoxLayout>();
- widget.set_fill_with_background_color(true);
+ widget->set_layout<VerticalBoxLayout>();
+ widget->set_fill_with_background_color(true);
- widget.layout()->set_margins(8);
- widget.layout()->set_spacing(6);
+ widget->layout()->set_margins(8);
+ widget->layout()->set_spacing(6);
- auto& message_container = widget.add<Widget>();
+ auto& message_container = widget->add<Widget>();
message_container.set_layout<HorizontalBoxLayout>();
message_container.layout()->set_spacing(8);
@@ -143,7 +143,7 @@ void MessageBox::build()
if (m_type != Type::None)
label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
- auto& button_container = widget.add<Widget>();
+ auto& button_container = widget->add<Widget>();
button_container.set_layout<HorizontalBoxLayout>();
button_container.set_fixed_height(24);
button_container.layout()->set_spacing(8);
diff --git a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp
index 80e30910a1..7be9cc9d00 100644
--- a/Userland/Libraries/LibGUI/PasswordInputDialog.cpp
+++ b/Userland/Libraries/LibGUI/PasswordInputDialog.cpp
@@ -22,30 +22,30 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, DeprecatedString
resize(340, 122);
set_title(move(title));
- auto& widget = set_main_widget<Widget>();
+ auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
- widget.load_from_gml(password_input_dialog_gml);
+ widget->load_from_gml(password_input_dialog_gml);
- auto& key_icon_label = *widget.find_descendant_of_type_named<GUI::Label>("key_icon_label");
+ auto& key_icon_label = *widget->find_descendant_of_type_named<GUI::Label>("key_icon_label");
key_icon_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/key.png"sv).release_value_but_fixme_should_propagate_errors());
- auto& server_label = *widget.find_descendant_of_type_named<GUI::Label>("server_label");
+ auto& server_label = *widget->find_descendant_of_type_named<GUI::Label>("server_label");
server_label.set_text(move(server));
- auto& username_label = *widget.find_descendant_of_type_named<GUI::Label>("username_label");
+ auto& username_label = *widget->find_descendant_of_type_named<GUI::Label>("username_label");
username_label.set_text(move(username));
- auto& password_box = *widget.find_descendant_of_type_named<GUI::PasswordBox>("password_box");
+ auto& password_box = *widget->find_descendant_of_type_named<GUI::PasswordBox>("password_box");
- auto& ok_button = *widget.find_descendant_of_type_named<GUI::Button>("ok_button");
+ auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button");
ok_button.on_click = [&](auto) {
dbgln("GUI::PasswordInputDialog: OK button clicked");
m_password = password_box.text();
done(ExecResult::OK);
};
- auto& cancel_button = *widget.find_descendant_of_type_named<GUI::Button>("cancel_button");
+ auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button");
cancel_button.on_click = [this](auto) {
dbgln("GUI::PasswordInputDialog: Cancel button clicked");
done(ExecResult::Cancel);
diff --git a/Userland/Libraries/LibGUI/ProcessChooser.cpp b/Userland/Libraries/LibGUI/ProcessChooser.cpp
index 246f507eca..82922fb9d9 100644
--- a/Userland/Libraries/LibGUI/ProcessChooser.cpp
+++ b/Userland/Libraries/LibGUI/ProcessChooser.cpp
@@ -31,11 +31,11 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label,
resize(300, 340);
center_on_screen();
- auto& widget = set_main_widget<GUI::Widget>();
- widget.set_fill_with_background_color(true);
- widget.set_layout<GUI::VerticalBoxLayout>();
+ auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
+ widget->set_fill_with_background_color(true);
+ widget->set_layout<GUI::VerticalBoxLayout>();
- m_table_view = widget.add<GUI::TableView>();
+ m_table_view = widget->add<GUI::TableView>();
auto process_model = RunningProcessesModel::create();
auto sorting_model = MUST(GUI::SortingProxyModel::create(process_model));
sorting_model->set_sort_role(GUI::ModelRole::Display);
@@ -46,7 +46,7 @@ ProcessChooser::ProcessChooser(StringView window_title, StringView button_label,
m_table_view->on_activation = [this](ModelIndex const& index) { set_pid_from_index_and_close(index); };
- auto& button_container = widget.add<GUI::Widget>();
+ auto& button_container = widget->add<GUI::Widget>();
button_container.set_fixed_height(30);
button_container.set_layout<GUI::HorizontalBoxLayout>();
button_container.layout()->set_margins({ 0, 4, 0 });
diff --git a/Userland/Libraries/LibGUI/SettingsWindow.cpp b/Userland/Libraries/LibGUI/SettingsWindow.cpp
index 007312fc32..55d827f24c 100644
--- a/Userland/Libraries/LibGUI/SettingsWindow.cpp
+++ b/Userland/Libraries/LibGUI/SettingsWindow.cpp
@@ -32,7 +32,7 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(DeprecatedString t
window->set_resizable(false);
window->set_minimizable(false);
- auto main_widget = TRY(window->try_set_main_widget<GUI::Widget>());
+ auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
main_widget->set_fill_with_background_color(true);
(void)TRY(main_widget->try_set_layout<GUI::VerticalBoxLayout>());
main_widget->layout()->set_margins(4);
diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h
index 03a4bece7c..43652891b8 100644
--- a/Userland/Libraries/LibGUI/Window.h
+++ b/Userland/Libraries/LibGUI/Window.h
@@ -143,21 +143,13 @@ public:
void set_main_widget(Widget*);
template<class T, class... Args>
- inline ErrorOr<NonnullRefPtr<T>> try_set_main_widget(Args&&... args)
+ inline ErrorOr<NonnullRefPtr<T>> set_main_widget(Args&&... args)
{
auto widget = TRY(T::try_create(forward<Args>(args)...));
set_main_widget(widget.ptr());
return widget;
}
- template<class T, class... Args>
- inline T& set_main_widget(Args&&... args)
- {
- auto widget = T::construct(forward<Args>(args)...);
- set_main_widget(widget.ptr());
- return *widget;
- }
-
Widget* default_return_key_widget() { return m_default_return_key_widget; }
Widget const* default_return_key_widget() const { return m_default_return_key_widget; }
void set_default_return_key_widget(Widget*);
diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
index f41cd9e2ca..4654af9f4d 100644
--- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
+++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp
@@ -27,19 +27,19 @@ WizardDialog::WizardDialog(Window* parent_window)
if (parent_window)
set_icon(parent_window->icon());
- auto& main_widget = set_main_widget<Widget>();
- main_widget.set_fill_with_background_color(true);
- main_widget.set_layout<VerticalBoxLayout>();
- main_widget.layout()->set_spacing(0);
+ auto main_widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
+ main_widget->set_fill_with_background_color(true);
+ main_widget->set_layout<VerticalBoxLayout>();
+ main_widget->layout()->set_spacing(0);
- m_page_container_widget = main_widget.add<Widget>();
+ m_page_container_widget = main_widget->add<Widget>();
m_page_container_widget->set_fixed_size(500, 315);
m_page_container_widget->set_layout<VerticalBoxLayout>();
- auto& separator = main_widget.add<SeparatorWidget>(Gfx::Orientation::Horizontal);
+ auto& separator = main_widget->add<SeparatorWidget>(Gfx::Orientation::Horizontal);
separator.set_fixed_height(2);
- auto& nav_container_widget = main_widget.add<Widget>();
+ auto& nav_container_widget = main_widget->add<Widget>();
nav_container_widget.set_layout<HorizontalBoxLayout>();
nav_container_widget.set_fixed_height(42);
nav_container_widget.layout()->set_margins({ 0, 10 });