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
+21 -12
View File
@@ -552,18 +552,27 @@ void AccountSetupDialog::submitImapAccount()
m_sslCheckbox->isChecked() ? "" : "No")
);
// Simulate connection delay, then add/update account
QTimer::singleShot(1500, this, [this, account]() mutable {
if (m_isEditing) {
account.setId(m_editingAccountId);
m_accountService->updateAccount(account);
} else {
m_accountService->addAccount(account);
}
});
// Timeout for IMAP too
m_authTimeoutTimer->start(30000);
// Disable UI during connection attempt
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) {
account.setId(m_editingAccountId);
m_accountService->updateAccount(account);
} else {
m_accountService->addAccount(account);
}
m_btnCancel->setEnabled(true);
} else {
QMessageBox::warning(this, tr("Connection failed"), tr("Could not connect to IMAP server: %1").arg(errorMsg));
// Re-enable UI
m_btnBack->setEnabled(true);
m_btnNext->setEnabled(true);
m_btnCancel->setEnabled(true);
}
}
// ─────────────────── Account Result ───────────────────