| 324 | } |
| 325 | |
| 326 | void UserInterfaceModule::registerControl(IUserControlCreator::Ptr control) |
| 327 | { |
| 328 | if (!_userControls.emplace(control->getControlName(), control).second) |
| 329 | { |
| 330 | throw std::logic_error("The Control with name " + control->getControlName() + " has already been registered"); |
| 331 | } |
| 332 | |
| 333 | // Check the name for validity |
| 334 | if (!string::isAlphaNumeric(control->getControlName())) |
| 335 | { |
| 336 | throw std::invalid_argument("Control name " + control->getControlName() + " contains invalid characters, only alphanumerics are allowed"); |
| 337 | } |
| 338 | |
| 339 | // Add a command shortcut toggling this control |
| 340 | GlobalCommandSystem().addStatement(fmt::format("{0}{1}", TOGGLE_CONTROL_STATEMENT_PREFIX, control->getControlName()), |
| 341 | fmt::format("{0} \"{1}\"", TOGGLE_CONTROL_COMMAND, control->getControlName()), false); |
| 342 | |
| 343 | // Add a command shortcut for making this the main control |
| 344 | GlobalCommandSystem().addStatement(fmt::format("{0}{1}", TOGGLE_MAIN_CONTROL_STATEMENT_PREFIX, control->getControlName()), |
| 345 | fmt::format("{0} \"{1}\"", TOGGLE_MAIN_CONTROL_COMMAND, control->getControlName()), false); |
| 346 | } |
| 347 | |
| 348 | IUserControlCreator::Ptr UserInterfaceModule::findControl(const std::string& name) |
| 349 | { |
no test coverage detected