mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 20:52:45 +00:00 
			
		
		
		
	LibGUI: Make AboutDialog APIs infallible
This commit is contained in:
		
							parent
							
								
									bd61e75e0b
								
							
						
					
					
						commit
						c838bb3f21
					
				
					 4 changed files with 10 additions and 12 deletions
				
			
		|  | @ -21,6 +21,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) | |||
|     TRY(Core::System::unveil(nullptr, nullptr)); | ||||
| 
 | ||||
|     auto app_icon = TRY(GUI::Icon::try_create_default_icon("ladyball"sv)); | ||||
|     TRY(GUI::AboutDialog::show("SerenityOS"_string, TRY(Core::Version::read_long_version_string()), app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16))); | ||||
|     GUI::AboutDialog::show("SerenityOS"_string, TRY(Core::Version::read_long_version_string()), app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16)); | ||||
|     return app->exec(); | ||||
| } | ||||
|  |  | |||
|  | @ -19,13 +19,13 @@ | |||
| 
 | ||||
| namespace GUI { | ||||
| 
 | ||||
| ErrorOr<NonnullRefPtr<AboutDialog>> AboutDialog::try_create(String name, String version, RefPtr<Gfx::Bitmap const> icon, Window* parent_window) | ||||
| NonnullRefPtr<AboutDialog> AboutDialog::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))); | ||||
|     auto dialog = adopt_ref(*new AboutDialog(name, version, icon, parent_window)); | ||||
|     dialog->set_title(DeprecatedString::formatted("About {}", name)); | ||||
| 
 | ||||
|     auto widget = TRY(dialog->set_main_widget<Widget>()); | ||||
|     TRY(widget->load_from_gml(about_dialog_gml)); | ||||
|     auto widget = MUST(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"); | ||||
|     if (icon) { | ||||
|  | @ -62,13 +62,12 @@ AboutDialog::AboutDialog(String name, String version, RefPtr<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) | ||||
| 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)); | ||||
|     auto dialog = AboutDialog::create(move(name), move(version), move(icon), parent_window); | ||||
|     if (window_icon) | ||||
|         dialog->set_icon(window_icon); | ||||
|     dialog->exec(); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -16,10 +16,10 @@ namespace GUI { | |||
| class AboutDialog final : public Dialog { | ||||
|     C_OBJECT_ABSTRACT(AboutDialog) | ||||
| public: | ||||
|     static ErrorOr<NonnullRefPtr<AboutDialog>> try_create(String name, String version, RefPtr<Gfx::Bitmap const> icon = nullptr, Window* parent_window = nullptr); | ||||
|     [[nodiscard]] static NonnullRefPtr<AboutDialog> create(String name, String version, RefPtr<Gfx::Bitmap const> icon = nullptr, Window* parent_window = nullptr); | ||||
|     virtual ~AboutDialog() override = default; | ||||
| 
 | ||||
|     static ErrorOr<void> show(String name, String version, RefPtr<Gfx::Bitmap const> icon = nullptr, Window* parent_window = nullptr, RefPtr<Gfx::Bitmap const> window_icon = nullptr); | ||||
|     static void show(String name, String version, RefPtr<Gfx::Bitmap const> icon = nullptr, Window* parent_window = nullptr, RefPtr<Gfx::Bitmap const> window_icon = nullptr); | ||||
| 
 | ||||
| private: | ||||
|     AboutDialog(String name, String version, RefPtr<Gfx::Bitmap const> icon = nullptr, Window* parent_window = nullptr); | ||||
|  |  | |||
|  | @ -25,8 +25,7 @@ NonnullRefPtr<Action> make_about_action(DeprecatedString const& app_name, Icon c | |||
|             String::from_deprecated_string(app_name).release_value_but_fixme_should_propagate_errors(), | ||||
|             Core::Version::read_long_version_string().release_value_but_fixme_should_propagate_errors(), | ||||
|             app_icon.bitmap_for_size(32), | ||||
|             weak_parent) | ||||
|             .release_value_but_fixme_should_propagate_errors(); | ||||
|             weak_parent); | ||||
|     }); | ||||
|     action->set_status_tip("Show application about box"_string); | ||||
|     return action; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling