1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:47:44 +00:00

Applications+Demos+LibGUI: Migrate to fallible WizardDialogs and Pages

And port page text to String. Also removes WizardDialog::show() helper
as all current implementations prefer to derive their own Dialog.
This commit is contained in:
thankyouverycool 2023-06-08 07:46:11 -04:00 committed by Andreas Kling
parent 96e60c98cf
commit caa8f43dbe
12 changed files with 178 additions and 115 deletions

View file

@ -13,36 +13,44 @@
namespace GUI {
CoverWizardPage::CoverWizardPage()
: AbstractWizardPage()
ErrorOr<NonnullRefPtr<CoverWizardPage>> CoverWizardPage::create(StringView title, StringView subtitle)
{
auto page = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) CoverWizardPage()));
TRY(page->build(TRY(String::from_utf8(title)), TRY(String::from_utf8(subtitle))));
return page;
}
ErrorOr<void> CoverWizardPage::build(String title, String subtitle)
{
set_fill_with_background_color(true);
set_background_role(Gfx::ColorRole::Base);
set_layout<HorizontalBoxLayout>();
m_banner_image_widget = add<ImageWidget>();
TRY(try_set_layout<HorizontalBoxLayout>());
m_banner_image_widget = TRY(try_add<ImageWidget>());
m_banner_image_widget->set_fixed_size(160, 315);
m_banner_image_widget->load_from_file("/res/graphics/wizard-banner-simple.png"sv);
m_content_widget = add<Widget>();
m_content_widget->set_layout<VerticalBoxLayout>(20);
m_content_widget = TRY(try_add<Widget>());
TRY(m_content_widget->try_set_layout<VerticalBoxLayout>(20));
m_header_label = m_content_widget->add<Label>();
m_header_label = TRY(m_content_widget->try_add<Label>(move(title)));
m_header_label->set_font(Gfx::FontDatabase::the().get("Pebbleton", 14, 700, Gfx::FontWidth::Normal, 0));
m_header_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
m_header_label->set_fixed_height(48);
m_body_label = m_content_widget->add<Label>();
m_body_label = TRY(m_content_widget->try_add<Label>(move(subtitle)));
m_body_label->set_text_alignment(Gfx::TextAlignment::TopLeft);
return {};
}
void CoverWizardPage::set_header_text(DeprecatedString const& text)
void CoverWizardPage::set_header_text(String text)
{
m_header_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors());
m_header_label->set_text(move(text));
}
void CoverWizardPage::set_body_text(DeprecatedString const& text)
void CoverWizardPage::set_body_text(String text)
{
m_body_label->set_text(String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors());
m_body_label->set_text(move(text));
}
}