* @brief Returns the workspace list with id, title, icon, and widget count. */
| 717 | * @brief Returns the workspace list with id, title, icon, and widget count. |
| 718 | */ |
| 719 | API::CommandResponse API::Handlers::WorkspacesHandler::list(const QString& id, |
| 720 | const QJsonObject& params) |
| 721 | { |
| 722 | Q_UNUSED(params) |
| 723 | |
| 724 | const auto& pm = DataModel::ProjectModel::instance(); |
| 725 | const auto& workspaces = pm.activeWorkspaces(); |
| 726 | |
| 727 | QJsonArray arr; |
| 728 | for (const auto& ws : workspaces) { |
| 729 | QJsonObject entry; |
| 730 | entry[QStringLiteral("id")] = ws.workspaceId; |
| 731 | entry[QStringLiteral("title")] = ws.title; |
| 732 | entry[QStringLiteral("icon")] = SerialStudio::normalizeIconPath(ws.icon); |
| 733 | entry[QStringLiteral("description")] = ws.description; |
| 734 | entry[QStringLiteral("widgetCount")] = static_cast<int>(ws.widgetRefs.size()); |
| 735 | arr.append(entry); |
| 736 | } |
| 737 | |
| 738 | QJsonObject result; |
| 739 | result[QStringLiteral("workspaces")] = arr; |
| 740 | result[QStringLiteral("count")] = static_cast<int>(workspaces.size()); |
| 741 | result[QStringLiteral("customizeEnabled")] = pm.customizeWorkspaces(); |
| 742 | return CommandResponse::makeSuccess(id, result); |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * @brief Returns widget refs for a single workspace. |
nothing calls this directly
no test coverage detected