diff --git a/Userland/Services/Taskbar/main.cpp b/Userland/Services/Taskbar/main.cpp index 5ddb9307e3..9e98cf3170 100644 --- a/Userland/Services/Taskbar/main.cpp +++ b/Userland/Services/Taskbar/main.cpp @@ -120,19 +120,42 @@ NonnullRefPtr build_system_menu() system_menu->add_separator(); // First we construct all the necessary app category submenus. - HashMap> app_category_menus; auto category_icons = Core::ConfigFile::open("/res/icons/SystemMenu.ini"); - for (const auto& category : sorted_app_categories) { + HashMap> app_category_menus; + + Function create_category_menu; + create_category_menu = [&](String const& category) { if (app_category_menus.contains(category)) - continue; - auto& category_menu = system_menu->add_submenu(category); + return; + String parent_category, child_category = category; + for (ssize_t i = category.length() - 1; i >= 0; i--) { + if (category[i] == '/') { + parent_category = category.substring(0, i); + child_category = category.substring(i + 1); + } + } + GUI::Menu* parent_menu; + if (parent_category.is_empty()) { + parent_menu = system_menu; + } else { + parent_menu = app_category_menus.get(parent_category).value(); + if (!parent_menu) { + create_category_menu(parent_category); + parent_menu = app_category_menus.get(parent_category).value(); + VERIFY(parent_menu); + } + } + auto& category_menu = parent_menu->add_submenu(child_category); auto category_icon_path = category_icons->read_entry("16x16", category); if (!category_icon_path.is_empty()) { auto icon = Gfx::Bitmap::load_from_file(category_icon_path); category_menu.set_icon(icon); } app_category_menus.set(category, category_menu); - } + }; + + for (const auto& category : sorted_app_categories) + create_category_menu(category); // Then we create and insert all the app menu items into the right place. int app_identifier = 0;