|
@@ -74,6 +74,11 @@ void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
|
|
|
}
|
|
|
|
|
|
Icon Icon::default_icon(StringView name)
|
|
|
+{
|
|
|
+ return MUST(try_create_default_icon(name));
|
|
|
+}
|
|
|
+
|
|
|
+ErrorOr<Icon> Icon::try_create_default_icon(StringView name)
|
|
|
{
|
|
|
RefPtr<Gfx::Bitmap> bitmap16;
|
|
|
RefPtr<Gfx::Bitmap> bitmap32;
|
|
@@ -81,13 +86,9 @@ Icon Icon::default_icon(StringView name)
|
|
|
bitmap16 = bitmap_or_error.release_value();
|
|
|
if (auto bitmap_or_error = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/32x32/{}.png", name)); !bitmap_or_error.is_error())
|
|
|
bitmap32 = bitmap_or_error.release_value();
|
|
|
- return Icon(move(bitmap16), move(bitmap32));
|
|
|
-}
|
|
|
|
|
|
-ErrorOr<Icon> Icon::try_create_default_icon(StringView name)
|
|
|
-{
|
|
|
- RefPtr<Gfx::Bitmap> bitmap16 = TRY(Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/16x16/{}.png", name)));
|
|
|
- RefPtr<Gfx::Bitmap> bitmap32 = TRY(Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/32x32/{}.png", name)));
|
|
|
+ if (!bitmap16 && !bitmap32)
|
|
|
+ return Error::from_string_literal("Default icon not found"sv);
|
|
|
|
|
|
return Icon(move(bitmap16), move(bitmap32));
|
|
|
}
|