mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
LibGUI: Add GIcon::default_icon(name).
This is a convenience helper to instantiate a GIcon like so: auto icon = GIcon::default_icon("filetype-image"); This will give you the "filetype-image" icon in both 16x16 and 32x32 sizes.
This commit is contained in:
parent
43bb7aad4c
commit
be604652ae
13 changed files with 16 additions and 7 deletions
|
@ -61,3 +61,10 @@ void GIconImpl::set_bitmap_for_size(int size, RetainPtr<GraphicsBitmap>&& bitmap
|
|||
}
|
||||
m_bitmaps.set(size, move(bitmap));
|
||||
}
|
||||
|
||||
GIcon GIcon::default_icon(const String& name)
|
||||
{
|
||||
auto bitmap16 = GraphicsBitmap::load_from_file(String::format("/res/icons/16x16/%s.png", name.characters()));
|
||||
auto bitmap32 = GraphicsBitmap::load_from_file(String::format("/res/icons/32x32/%s.png", name.characters()));
|
||||
return GIcon(move(bitmap16), move(bitmap32));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public:
|
|||
GIcon(const GIcon&);
|
||||
~GIcon() { }
|
||||
|
||||
static GIcon default_icon(const String&);
|
||||
|
||||
GIcon& operator=(const GIcon& other)
|
||||
{
|
||||
m_impl = other.m_impl.copy_ref();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue