add progress dialog

This commit is contained in:
Thomas Lindner 2022-11-16 01:21:45 +01:00
parent c4a75d35df
commit f7b088b6dc
2 changed files with 19 additions and 2 deletions

View file

@ -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<QWidget *>(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

View file

@ -3,6 +3,7 @@
#include "deltachat_context.hh"
#include <QDialog>
#include <QLineEdit>
#include <QProgressDialog>
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