* @brief Loads a template body file by id. Returns empty doc when not found. */
| 5506 | * @brief Loads a template body file by id. Returns empty doc when not found. |
| 5507 | */ |
| 5508 | static QJsonDocument loadTemplateBodyById(const QString& templateId) |
| 5509 | { |
| 5510 | const auto manifest = loadTemplateManifest().object(); |
| 5511 | const auto entries = manifest.value(QStringLiteral("templates")).toArray(); |
| 5512 | for (const auto& v : entries) { |
| 5513 | const auto entry = v.toObject(); |
| 5514 | if (entry.value(QStringLiteral("id")).toString() != templateId) |
| 5515 | continue; |
| 5516 | |
| 5517 | const auto file = entry.value(QStringLiteral("file")).toString(); |
| 5518 | QFile body(QStringLiteral(":/ai/templates/") + file); |
| 5519 | if (!body.open(QIODevice::ReadOnly | QIODevice::Text)) |
| 5520 | return {}; |
| 5521 | |
| 5522 | return QJsonDocument::fromJson(body.readAll()); |
| 5523 | } |
| 5524 | return {}; |
| 5525 | } |
| 5526 | |
| 5527 | /** |
| 5528 | * @brief Register project.template.* commands. |
no test coverage detected