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

LibCore+LibGUI+About: Use String in Core::Version and GUI::AboutDialog

The Core::Version API now returns ErrorOr<String>, and the
GUI::AboutDialog API was adjusted to accommodate this.
This commit is contained in:
Andreas Kling 2023-02-28 16:39:41 +01:00
parent ad4b4046f4
commit d0977ac566
7 changed files with 40 additions and 33 deletions

View file

@ -19,7 +19,7 @@
namespace GUI {
ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(StringView name, StringView version, Gfx::Bitmap const* icon, Window* parent_window)
ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(String name, String version, RefPtr<Gfx::Bitmap const> icon, Window* parent_window)
{
auto dialog = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AboutDialog(name, version, icon, parent_window)));
dialog->set_title(DeprecatedString::formatted("About {}", name));
@ -36,10 +36,10 @@ ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(StringView name, Str
icon_wrapper->set_visible(false);
}
widget->find_descendant_of_type_named<GUI::Label>("name")->set_text(name);
widget->find_descendant_of_type_named<GUI::Label>("name")->set_text(name.to_deprecated_string());
// If we are displaying a dialog for an application, insert 'SerenityOS' below the application name
widget->find_descendant_of_type_named<GUI::Label>("serenity_os")->set_visible(name != "SerenityOS");
widget->find_descendant_of_type_named<GUI::Label>("version")->set_text(version);
widget->find_descendant_of_type_named<GUI::Label>("version")->set_text(version.to_deprecated_string());
auto ok_button = widget->find_descendant_of_type_named<DialogButton>("ok_button");
ok_button->on_click = [dialog](auto) {
@ -49,11 +49,11 @@ ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(StringView name, Str
return dialog;
}
AboutDialog::AboutDialog(StringView name, StringView version, Gfx::Bitmap const* icon, Window* parent_window)
AboutDialog::AboutDialog(String name, String version, RefPtr<Gfx::Bitmap const> icon, Window* parent_window)
: Dialog(parent_window)
, m_name(name)
, m_icon(icon)
, m_version_string(version)
, m_name(move(name))
, m_version_string(move(version))
, m_icon(move(icon))
{
resize(413, 204);
set_resizable(false);
@ -62,4 +62,13 @@ AboutDialog::AboutDialog(StringView name, StringView version, Gfx::Bitmap const*
set_icon(parent_window->icon());
}
ErrorOr<void> AboutDialog::show(String name, String version, RefPtr<Gfx::Bitmap const> icon, Window* parent_window, RefPtr<Gfx::Bitmap const> window_icon)
{
auto dialog = TRY(AboutDialog::try_create(move(name), move(version), move(icon), parent_window));
if (window_icon)
dialog->set_icon(window_icon);
dialog->exec();
return {};
}
}