From f7b088b6dc5a896e02cf5fb1b4c513084bd9b750 Mon Sep 17 00:00:00 2001 From: Thomas Lindner Date: Wed, 16 Nov 2022 01:21:45 +0100 Subject: [PATCH] add progress dialog --- src/login_dialog.cc | 18 ++++++++++++++++-- src/login_dialog.hh | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/login_dialog.cc b/src/login_dialog.cc index 69b58f3..bfbf075 100644 --- a/src/login_dialog.cc +++ b/src/login_dialog.cc @@ -42,11 +42,21 @@ void LoginDialog::accept() { m_context->setConfig("addr", m_email->text()); m_context->setConfig("mail_pw", m_password->text()); m_context->configure(); + m_progress = new QProgressDialog{"Connecting ...", "Cancel", 0, 1000, + static_cast(parent())}; + connect(m_progress, &QProgressDialog::canceled, this, + &LoginDialog::configureCanceled); QDialog::accept(); } void LoginDialog::configureProgress(int permille, QString message) { - if (!permille) { + if (permille) { + m_progress->setValue(permille); + m_progress->setLabelText(message); + } else { + m_progress->close(); + configureCanceled(); + QMessageBox messagebox; messagebox.setText("Login failed."); if (message.length() > 500) { @@ -56,8 +66,12 @@ void LoginDialog::configureProgress(int permille, QString message) { } messagebox.setIcon(QMessageBox::Critical); messagebox.exec(); - show(); } } +void LoginDialog::configureCanceled() { + m_progress->deleteLater(); + show(); +} + } // namespace kappachat diff --git a/src/login_dialog.hh b/src/login_dialog.hh index 34a3d43..29338ca 100644 --- a/src/login_dialog.hh +++ b/src/login_dialog.hh @@ -3,6 +3,7 @@ #include "deltachat_context.hh" #include #include +#include namespace kappachat { @@ -15,11 +16,13 @@ class LoginDialog : public QDialog { public slots: void accept() override; void configureProgress(int permille, QString message); + void configureCanceled(); private: DeltachatContext *m_context; QLineEdit *m_email; QLineEdit *m_password; + QProgressDialog *m_progress; }; } // namespace kappachat