mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:17:35 +00:00
LibGUI: Add ErrorOr wrapper for default icon creation
This commit is contained in:
parent
42b06d5f7d
commit
61fed26400
2 changed files with 11 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Julius Heijmen <julius.heijmen@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -83,4 +84,12 @@ Icon Icon::default_icon(StringView name)
|
||||||
return Icon(move(bitmap16), move(bitmap32));
|
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)));
|
||||||
|
|
||||||
|
return Icon(move(bitmap16), move(bitmap32));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Julius Heijmen <julius.heijmen@gmail.com>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +45,7 @@ public:
|
||||||
~Icon() { }
|
~Icon() { }
|
||||||
|
|
||||||
static Icon default_icon(StringView);
|
static Icon default_icon(StringView);
|
||||||
|
static ErrorOr<Icon> try_create_default_icon(StringView);
|
||||||
|
|
||||||
Icon& operator=(const Icon& other)
|
Icon& operator=(const Icon& other)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue