From c670a2b52eeccee183ec558685f7acabcf72de3e Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Thu, 24 Dec 2020 16:11:27 +0100 Subject: [PATCH] SystemMenu: Use GUI::FileIconProvider for app icons --- Services/SystemMenu/main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Services/SystemMenu/main.cpp b/Services/SystemMenu/main.cpp index 05e0eed0f2..174feec844 100644 --- a/Services/SystemMenu/main.cpp +++ b/Services/SystemMenu/main.cpp @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include #include @@ -44,7 +46,6 @@ struct AppMetadata { String executable; String name; - String icon_path; String category; }; Vector g_apps; @@ -111,8 +112,7 @@ Vector discover_apps_and_categories() auto app_name = af->read_entry("App", "Name"); auto app_executable = af->read_entry("App", "Executable"); auto app_category = af->read_entry("App", "Category"); - auto app_icon_path = af->read_entry("Icons", "16x16"); - g_apps.append({ app_executable, app_name, app_icon_path, app_category }); + g_apps.append({ app_executable, app_name, app_category }); seen_app_categories.set(app_category); } quick_sort(g_apps, [](auto& a, auto& b) { return a.name < b.name; }); @@ -149,9 +149,7 @@ NonnullRefPtr build_system_menu() // Then we create and insert all the app menu items into the right place. int app_identifier = 0; for (const auto& app : g_apps) { - RefPtr icon; - if (!app.icon_path.is_empty()) - icon = Gfx::Bitmap::load_from_file(app.icon_path); + auto icon = GUI::FileIconProvider::icon_for_path(app.executable).bitmap_for_size(16); #ifdef SYSTEM_MENU_DEBUG if (icon) @@ -159,7 +157,7 @@ NonnullRefPtr build_system_menu() #endif auto parent_menu = app_category_menus.get(app.category).value_or(*system_menu); - parent_menu->add_action(GUI::Action::create(app.name, icon.ptr(), [app_identifier](auto&) { + parent_menu->add_action(GUI::Action::create(app.name, icon, [app_identifier](auto&) { dbg() << "Activated app with ID " << app_identifier; const auto& bin = g_apps[app_identifier].executable; pid_t child_pid;