| 428 | } |
| 429 | |
| 430 | void DialogAgent::onButtonSave() |
| 431 | { |
| 432 | QString configType = agentCombobox->currentText(); |
| 433 | auto configData = QString(); |
| 434 | if (ax_uis.contains(configType) && ax_uis[configType].container) |
| 435 | configData = ax_uis[configType].container->toJson(); |
| 436 | |
| 437 | QJsonObject dataJson; |
| 438 | dataJson["listener_type"] = listenerType; |
| 439 | dataJson["agent"] = configType; |
| 440 | dataJson["config"] = configData; |
| 441 | QByteArray fileContent = QJsonDocument(dataJson).toJson(); |
| 442 | |
| 443 | QString tmpFilename = QString("%1_config.json").arg(configType); |
| 444 | QString baseDir = authProfile.GetProjectDir(); |
| 445 | QString initialPath = QDir(baseDir).filePath(tmpFilename); |
| 446 | NonBlockingDialogs::getSaveFileName(this, "Save File", initialPath, "JSON files (*.json)", |
| 447 | [this, fileContent](const QString& filePath) { |
| 448 | if (filePath.isEmpty()) |
| 449 | return; |
| 450 | |
| 451 | QFile file(filePath); |
| 452 | if (!file.open(QIODevice::WriteOnly)) { |
| 453 | MessageError("Failed to open file for writing"); |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | file.write(fileContent); |
| 458 | file.close(); |
| 459 | |
| 460 | QInputDialog inputDialog; |
| 461 | inputDialog.setWindowTitle("Save config"); |
| 462 | inputDialog.setLabelText("File saved to:"); |
| 463 | inputDialog.setTextEchoMode(QLineEdit::Normal); |
| 464 | inputDialog.setTextValue(filePath); |
| 465 | inputDialog.adjustSize(); |
| 466 | inputDialog.move(QGuiApplication::primaryScreen()->geometry().center() - inputDialog.geometry().center()); |
| 467 | inputDialog.exec(); |
| 468 | }); |
| 469 | } |
| 470 | |
| 471 | void DialogAgent::changeConfig(const QString &agentName) |
| 472 | { |
nothing calls this directly
no test coverage detected