| 135 | |
| 136 | |
| 137 | void AddEffectMenuItemGroup( |
| 138 | MenuHelper::Group &table, |
| 139 | const TranslatableStrings & names, |
| 140 | const PluginIDs & plugs, |
| 141 | const std::vector<CommandFlag> & flags, |
| 142 | void (*onMenuCommand)(const CommandContext&)) |
| 143 | { |
| 144 | const int namesCnt = (int) names.size(); |
| 145 | |
| 146 | int groupCnt = namesCnt; |
| 147 | for (int i = 0; i < namesCnt; i++) |
| 148 | { |
| 149 | // compare full translations not msgids! |
| 150 | while (i + 1 < namesCnt && names[i].Translation() == names[i + 1].Translation()) |
| 151 | { |
| 152 | i++; |
| 153 | groupCnt--; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | using namespace MenuRegistry; |
| 158 | |
| 159 | for (int i = 0; i < namesCnt; i++) |
| 160 | { |
| 161 | // compare full translations not msgids! |
| 162 | if (i + 1 < namesCnt && names[i].Translation() == names[i + 1].Translation()) |
| 163 | { |
| 164 | // collect a sub-menu for like-named items |
| 165 | const auto name = names[i]; |
| 166 | const auto translation = name.Translation(); |
| 167 | auto subMenu = Menu("", name); |
| 168 | // compare full translations not msgids! |
| 169 | while (i < namesCnt && names[i].Translation() == translation) |
| 170 | { |
| 171 | const PluginDescriptor *plug = |
| 172 | PluginManager::Get().GetPlugin(plugs[i]); |
| 173 | if( plug->GetPluginType() == PluginTypeEffect ) |
| 174 | subMenu->push_back( Command( plug->GetID(), |
| 175 | Verbatim( plug->GetPath() ), |
| 176 | onMenuCommand, |
| 177 | flags[i], |
| 178 | Options{} |
| 179 | .IsEffect() |
| 180 | .AllowInMacros() |
| 181 | .Parameter( plugs[i] ) ) ); |
| 182 | |
| 183 | i++; |
| 184 | } |
| 185 | table.push_back(move(subMenu)); |
| 186 | i--; |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | // collect one item |
| 191 | const PluginDescriptor *plug = |
| 192 | PluginManager::Get().GetPlugin(plugs[i]); |
| 193 | if( plug->GetPluginType() == PluginTypeEffect ) |
| 194 | table.push_back( Command( |
no test coverage detected