| 406 | } |
| 407 | |
| 408 | void GeneralSettings::showModelsNotFoundDialog(Utils::StringAspect &aspect) |
| 409 | { |
| 410 | SettingsDialog dialog(TrConstants::CONNECTION_ERROR); |
| 411 | dialog.addLabel(TrConstants::NO_MODELS_FOUND); |
| 412 | dialog.addLabel(TrConstants::CHECK_CONNECTION); |
| 413 | dialog.addSpacing(); |
| 414 | |
| 415 | ButtonAspect *providerButton = nullptr; |
| 416 | ButtonAspect *urlButton = nullptr; |
| 417 | |
| 418 | if (&aspect == &ccModel) { |
| 419 | providerButton = &ccSelectProvider; |
| 420 | urlButton = &ccSetUrl; |
| 421 | } else if (&aspect == &caModel) { |
| 422 | providerButton = &caSelectProvider; |
| 423 | urlButton = &caSetUrl; |
| 424 | } else if (&aspect == &qrModel) { |
| 425 | providerButton = &qrSelectProvider; |
| 426 | urlButton = &qrSetUrl; |
| 427 | } |
| 428 | |
| 429 | if (providerButton && urlButton) { |
| 430 | auto selectProviderBtn = new QPushButton(TrConstants::SELECT_PROVIDER); |
| 431 | auto selectUrlBtn = new QPushButton(TrConstants::SELECT_URL); |
| 432 | auto enterManuallyBtn = new QPushButton(TrConstants::ENTER_MODEL_MANUALLY); |
| 433 | auto configureApiKeyBtn = new QPushButton(TrConstants::CONFIGURE_API_KEY); |
| 434 | |
| 435 | connect(selectProviderBtn, &QPushButton::clicked, &dialog, [this, providerButton, &dialog]() { |
| 436 | dialog.close(); |
| 437 | emit providerButton->clicked(); |
| 438 | }); |
| 439 | |
| 440 | connect(selectUrlBtn, &QPushButton::clicked, &dialog, [this, urlButton, &dialog]() { |
| 441 | dialog.close(); |
| 442 | emit urlButton->clicked(); |
| 443 | }); |
| 444 | |
| 445 | connect(enterManuallyBtn, &QPushButton::clicked, &dialog, [this, &aspect, &dialog]() { |
| 446 | dialog.close(); |
| 447 | showModelsNotSupportedDialog(aspect); |
| 448 | }); |
| 449 | |
| 450 | connect(configureApiKeyBtn, &QPushButton::clicked, &dialog, [&dialog]() { |
| 451 | dialog.close(); |
| 452 | Settings::showSettings(Constants::QODE_ASSIST_PROVIDER_SETTINGS_PAGE_ID); |
| 453 | }); |
| 454 | |
| 455 | dialog.buttonLayout()->addWidget(selectProviderBtn); |
| 456 | dialog.buttonLayout()->addWidget(selectUrlBtn); |
| 457 | dialog.buttonLayout()->addWidget(enterManuallyBtn); |
| 458 | dialog.buttonLayout()->addWidget(configureApiKeyBtn); |
| 459 | } |
| 460 | |
| 461 | auto closeBtn = new QPushButton(TrConstants::CLOSE); |
| 462 | connect(closeBtn, &QPushButton::clicked, &dialog, &QDialog::close); |
| 463 | dialog.buttonLayout()->addWidget(closeBtn); |
| 464 | |
| 465 | dialog.exec(); |
no test coverage detected