* @brief Enable or disable auto layout. */
| 404 | * @brief Enable or disable auto layout. |
| 405 | */ |
| 406 | API::CommandResponse API::Handlers::WindowHandler::setAutoLayout(const QString& id, |
| 407 | const QJsonObject& params) |
| 408 | { |
| 409 | if (!params.contains(QStringLiteral("enabled"))) { |
| 410 | return CommandResponse::makeError( |
| 411 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: enabled")); |
| 412 | } |
| 413 | |
| 414 | auto* wm = UI::UISessionRegistry::instance().primaryWindowManager(); |
| 415 | if (!wm) |
| 416 | return noSession(id); |
| 417 | |
| 418 | const bool enabled = params.value(QStringLiteral("enabled")).toBool(); |
| 419 | QMetaObject::invokeMethod(wm, [wm, enabled]() { wm->setAutoLayoutEnabled(enabled); }); |
| 420 | |
| 421 | QJsonObject result; |
| 422 | result[QStringLiteral("enabled")] = enabled; |
| 423 | return CommandResponse::makeSuccess(id, result); |
| 424 | } |
| 425 | |
| 426 | /** |
| 427 | * @brief Save the current layout to the project (via Taskbar::saveLayout). |
nothing calls this directly
no test coverage detected