Replace simulated IMAP delay with real connection test using AccountService::testConnection

This commit is contained in:
2026-07-06 16:25:43 +02:00
parent e81bb0d5fe
commit 0674fe4944
+15 -6
View File
@@ -552,18 +552,27 @@ void AccountSetupDialog::submitImapAccount()
m_sslCheckbox->isChecked() ? "" : "No") m_sslCheckbox->isChecked() ? "" : "No")
); );
// Simulate connection delay, then add/update account // Disable UI during connection attempt
QTimer::singleShot(1500, this, [this, account]() mutable { m_btnBack->setEnabled(false);
m_btnNext->setEnabled(false);
m_btnCancel->setEnabled(false);
QString errorMsg;
bool success = m_accountService->testConnection(account.connectionSettings(), errorMsg);
if (success) {
if (m_isEditing) { if (m_isEditing) {
account.setId(m_editingAccountId); account.setId(m_editingAccountId);
m_accountService->updateAccount(account); m_accountService->updateAccount(account);
} else { } else {
m_accountService->addAccount(account); m_accountService->addAccount(account);
} }
}); m_btnCancel->setEnabled(true);
} else {
// Timeout for IMAP too QMessageBox::warning(this, tr("Connection failed"), tr("Could not connect to IMAP server: %1").arg(errorMsg));
m_authTimeoutTimer->start(30000); // Re-enable UI
m_btnBack->setEnabled(true);
m_btnNext->setEnabled(true);
m_btnCancel->setEnabled(true);
}
} }
// ─────────────────── Account Result ─────────────────── // ─────────────────── Account Result ───────────────────