1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:07:36 +00:00

Userland: Make Window::set_main_widget() non-fallible

This commit is contained in:
Tim Ledbetter 2023-09-19 01:13:48 +01:00 committed by Andreas Kling
parent c9297126db
commit 3aa49f268c
120 changed files with 144 additions and 133 deletions

View file

@ -24,7 +24,7 @@ NonnullRefPtr<AboutDialog> AboutDialog::create(String const& name, String versio
auto dialog = adopt_ref(*new AboutDialog(name, version, icon, parent_window));
dialog->set_title(DeprecatedString::formatted("About {}", name));
auto widget = MUST(dialog->set_main_widget<Widget>());
auto widget = dialog->set_main_widget<Widget>();
MUST(widget->load_from_gml(about_dialog_gml));
auto icon_wrapper = widget->find_descendant_of_type_named<Widget>("icon_wrapper");

View file

@ -45,7 +45,7 @@ private:
{
set_window_type(WindowType::Tooltip);
set_obey_widget_min_size(false);
m_label = set_main_widget<Label>().release_value_but_fixme_should_propagate_errors();
m_label = set_main_widget<Label>();
m_label->set_background_role(Gfx::ColorRole::Tooltip);
m_label->set_foreground_role(Gfx::ColorRole::TooltipText);
m_label->set_fill_with_background_color(true);

View file

@ -92,7 +92,7 @@ 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>().release_value_but_fixme_should_propagate_errors();
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>();

View file

@ -207,7 +207,7 @@ void ColorPicker::set_color_has_alpha_channel(bool has_alpha)
void ColorPicker::build_ui()
{
auto root_container = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
auto root_container = set_main_widget<Widget>();
root_container->set_layout<VerticalBoxLayout>(4);
root_container->set_fill_with_background_color(true);

View file

@ -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>().release_value_but_fixme_should_propagate_errors();
m_list_view = m_list_window->set_main_widget<ListView>();
m_list_view->set_should_hide_unnecessary_scrollbars(true);
m_list_view->set_alternating_row_colors(false);
m_list_view->set_hover_highlighting(true);

View file

@ -183,7 +183,7 @@ CommandPalette::CommandPalette(GUI::Window& parent_window, ScreenPosition screen
collect_actions(parent_window);
auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<GUI::Frame>();
main_widget->set_frame_style(Gfx::FrameStyle::Window);
main_widget->set_fill_with_background_color(true);

View file

@ -48,7 +48,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
: Dialog(parent_window)
, m_category_action_group(make<ActionGroup>())
{
auto main_widget = set_main_widget<Frame>().release_value_but_fixme_should_propagate_errors();
auto main_widget = set_main_widget<Frame>();
main_widget->load_from_gml(emoji_input_dialog_gml).release_value_but_fixme_should_propagate_errors();
set_window_type(GUI::WindowType::Popup);

View file

@ -109,7 +109,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St
}
resize(560, 320);
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->load_from_gml(file_picker_dialog_gml).release_value_but_fixme_should_propagate_errors();
auto& toolbar = *widget->find_descendant_of_type_named<GUI::Toolbar>("toolbar");

View file

@ -26,7 +26,7 @@ FontPicker::FontPicker(Window* parent_window, Gfx::Font const* current_font, boo
resize(430, 280);
set_icon(Gfx::Bitmap::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>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->load_from_gml(font_picker_dialog_gml).release_value_but_fixme_should_propagate_errors();
m_family_list_view = *widget->find_descendant_of_type_named<ListView>("family_list_view");

View file

@ -127,7 +127,7 @@ void InputBox::on_done(ExecResult result)
ErrorOr<void> InputBox::build()
{
auto main_widget = TRY(set_main_widget<Widget>());
auto main_widget = set_main_widget<Widget>();
main_widget->set_layout<VerticalBoxLayout>(6, 6);
main_widget->set_fill_with_background_color(true);

View file

@ -150,7 +150,7 @@ bool MessageBox::should_include_no_button() const
ErrorOr<void> MessageBox::build()
{
auto main_widget = TRY(set_main_widget<Widget>());
auto main_widget = set_main_widget<Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<VerticalBoxLayout>(8, 6);

View file

@ -23,7 +23,7 @@ PasswordInputDialog::PasswordInputDialog(Window* parent_window, DeprecatedString
resize(340, 122);
set_title(move(title));
auto widget = set_main_widget<Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<Widget>();
widget->load_from_gml(password_input_dialog_gml).release_value_but_fixme_should_propagate_errors();
auto& key_icon = *widget->find_descendant_of_type_named<GUI::ImageWidget>("key_icon");

View file

@ -31,7 +31,7 @@ ProcessChooser::ProcessChooser(StringView window_title, String button_label, Gfx
resize(300, 340);
center_on_screen();
auto widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
auto widget = set_main_widget<GUI::Widget>();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();

View file

@ -32,7 +32,7 @@ ErrorOr<NonnullRefPtr<SettingsWindow>> SettingsWindow::create(DeprecatedString t
window->set_resizable(false);
window->set_minimizable(false);
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
auto main_widget = window->set_main_widget<GUI::Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>(4, 6);

View file

@ -150,9 +150,9 @@ public:
void set_main_widget(Widget*);
template<class T, class... Args>
inline ErrorOr<NonnullRefPtr<T>> set_main_widget(Args&&... args)
inline NonnullRefPtr<T> set_main_widget(Args&&... args)
{
auto widget = TRY(T::try_create(forward<Args>(args)...));
auto widget = T::construct(forward<Args>(args)...);
set_main_widget(widget.ptr());
return widget;
}

View file

@ -25,7 +25,7 @@ ErrorOr<NonnullRefPtr<WizardDialog>> WizardDialog::create(Window* parent_window)
ErrorOr<void> WizardDialog::build()
{
auto main_widget = TRY(set_main_widget<Widget>());
auto main_widget = set_main_widget<Widget>();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<VerticalBoxLayout>(Margins {}, 0);