* @brief Switch active group by group ID. */
| 269 | * @brief Switch active group by group ID. |
| 270 | */ |
| 271 | API::CommandResponse API::Handlers::WindowHandler::setActiveGroup(const QString& id, |
| 272 | const QJsonObject& params) |
| 273 | { |
| 274 | if (!params.contains(QStringLiteral("groupId"))) { |
| 275 | return CommandResponse::makeError( |
| 276 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: groupId")); |
| 277 | } |
| 278 | |
| 279 | auto* taskbar = UI::UISessionRegistry::instance().primaryTaskbar(); |
| 280 | if (!taskbar) |
| 281 | return noSession(id); |
| 282 | |
| 283 | const int group_id = params.value(QStringLiteral("groupId")).toInt(); |
| 284 | QMetaObject::invokeMethod(taskbar, |
| 285 | [taskbar, group_id]() { taskbar->setActiveGroupId(group_id); }); |
| 286 | |
| 287 | QJsonObject result; |
| 288 | result[QStringLiteral("groupId")] = group_id; |
| 289 | return CommandResponse::makeSuccess(id, result); |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * @brief Switch active group by index. |
nothing calls this directly
no test coverage detected