| 317 | } |
| 318 | |
| 319 | void AddGroupedEffectMenuItems( |
| 320 | MenuHelper::Group& table, |
| 321 | std::vector<const PluginDescriptor*>& plugs, |
| 322 | CommandFlag batchflags, |
| 323 | GroupBy groupBy, |
| 324 | void (*onMenuCommand)(const CommandContext&)) |
| 325 | { |
| 326 | using namespace MenuRegistry; |
| 327 | |
| 328 | const auto UnknownGroupName = XO("Unknown"); |
| 329 | auto& effectManager = EffectManager::Get(); |
| 330 | |
| 331 | std::vector<TranslatableString> path; |
| 332 | |
| 333 | auto *parentTable = &table; |
| 334 | std::vector<TranslatableString> names; |
| 335 | PluginIDs group; |
| 336 | std::vector<CommandFlag> flags; |
| 337 | |
| 338 | auto doAddGroup = [&] |
| 339 | { |
| 340 | using namespace MenuRegistry; |
| 341 | if(names.empty()) |
| 342 | return; |
| 343 | |
| 344 | const auto inSubmenu = !path.empty() && (names.size() > 1); |
| 345 | const auto label = inSubmenu ? path.back() : TranslatableString{}; |
| 346 | if (label.empty()) { |
| 347 | auto items = Items(""); |
| 348 | AddEffectMenuItemGroup(*items, names, group, flags, onMenuCommand); |
| 349 | parentTable->push_back(move(items)); |
| 350 | } |
| 351 | else { |
| 352 | auto items = Menu("", label); |
| 353 | AddEffectMenuItemGroup(*items, names, group, flags, onMenuCommand); |
| 354 | parentTable->push_back(move(items)); |
| 355 | } |
| 356 | |
| 357 | names.clear(); |
| 358 | group.clear(); |
| 359 | flags.clear(); |
| 360 | }; |
| 361 | |
| 362 | for(auto plug : plugs) |
| 363 | { |
| 364 | if(groupBy == GroupBy::Publisher) |
| 365 | { |
| 366 | const auto vendorName = effectManager.GetVendorName(plug->GetID()); |
| 367 | if(path.empty() || path[0] != vendorName) |
| 368 | { |
| 369 | doAddGroup(); |
| 370 | path = { vendorName }; |
| 371 | } |
| 372 | } |
| 373 | else if(groupBy == GroupBy::Type) |
| 374 | { |
| 375 | const auto effectFamilyName = effectManager.GetEffectFamilyName(plug->GetID()); |
| 376 | if(path.empty() || path[0] != effectFamilyName) |
no test coverage detected