From 7a3bdf3563b7363d89e7694551c92d9a3e42b326 Mon Sep 17 00:00:00 2001 From: thatlittlegit Date: Fri, 14 Feb 2020 14:51:08 -0500 Subject: [PATCH] Welcome: Add icons to welcome entries --- Applications/Welcome/main.cpp | 20 +++++++++++++++++++- Base/res/welcome.txt | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 3ef3635bbe..d6f5983e1c 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -49,6 +49,7 @@ struct ContentPage { String menu_name; String title; + String icon = String::empty(); Vector content; }; @@ -89,6 +90,10 @@ Optional> parse_welcome_file(const String& path) current = {}; current.menu_name = line.substring(2, line.length() - 2); break; + case '$': + dbg() << "icon line: \t" << line; + current.icon = line.substring(2, line.length() - 2); + break; case '>': dbg() << "title line:\t" << line; current.title = line.substring(2, line.length() - 2); @@ -203,7 +208,20 @@ int main(int argc, char** argv) content->layout()->set_spacing(8); content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - auto content_title = GUI::Label::construct(content); + auto title_box = GUI::Widget::construct(content.ptr()); + title_box->set_layout(make()); + title_box->layout()->set_spacing(4); + title_box->set_preferred_size(0, 16); + title_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); + + if (page.icon != String::empty()) { + auto icon = GUI::Label::construct(title_box); + icon->set_icon(Gfx::Bitmap::load_from_file(page.icon)); + icon->set_preferred_size(16, 16); + icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); + } + + auto content_title = GUI::Label::construct(title_box); content_title->set_font(Gfx::Font::default_bold_font()); content_title->set_text(page.title); content_title->set_text_alignment(Gfx::TextAlignment::CenterLeft); diff --git a/Base/res/welcome.txt b/Base/res/welcome.txt index d9e72ab9a1..d7469194a4 100644 --- a/Base/res/welcome.txt +++ b/Base/res/welcome.txt @@ -1,4 +1,5 @@ * Welcome +$ /res/icons/16x16/ladybug.png > Welcome to SerenityOS! Welcome to the exciting new world of Serenity, where the year is 1998 and the leading OS vendor has decided to merge their flagship product with a Unix-like @@ -10,6 +11,7 @@ screen. If you want to explore an option, just click it. * Registration +$ /res/icons/16x16/book.png > Register now! Registering your copy of Serenity opens the doors to full integration of Serenity into your life, your being, and your soul. @@ -21,6 +23,7 @@ To register, simply write your contact details on a piece of paper and hold it up to your monitor. * Internet +$ /res/icons/16x16/filetype-html.png > Connect to the Internet! On the Internet, you can correspond through electronic mail (e-mail), get the latest news and financial information, and visit Web sites around the world, @@ -32,6 +35,7 @@ chat) client, 4chan browser, telnet server, and basic utilities like ping. Come chat with us today! How bad can it be? * Fun & Games +$ /res/icons/16x16/app-snake.png > Play some games! Serenity includes several games built right into the base system. These include the classic game Snake and the anti-productivity mainstay Minesweeper.