* @brief Apply a layout to the WindowManager. */
| 480 | * @brief Apply a layout to the WindowManager. |
| 481 | */ |
| 482 | API::CommandResponse API::Handlers::WindowHandler::setLayout(const QString& id, |
| 483 | const QJsonObject& params) |
| 484 | { |
| 485 | if (!params.contains(QStringLiteral("layout"))) { |
| 486 | return CommandResponse::makeError( |
| 487 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: layout")); |
| 488 | } |
| 489 | |
| 490 | auto* wm = UI::UISessionRegistry::instance().primaryWindowManager(); |
| 491 | if (!wm) |
| 492 | return noSession(id); |
| 493 | |
| 494 | const QJsonObject layout = params.value(QStringLiteral("layout")).toObject(); |
| 495 | QMetaObject::invokeMethod(wm, [wm, layout]() { (void)wm->restoreLayout(layout); }); |
| 496 | |
| 497 | return CommandResponse::makeSuccess(id); |
| 498 | } |
| 499 | |
| 500 | //-------------------------------------------------------------------------------------------------- |
| 501 | // Widget settings |
no test coverage detected