add progress dialog
This commit is contained in:
parent
c4a75d35df
commit
f7b088b6dc
|
@ -42,11 +42,21 @@ void LoginDialog::accept() {
|
||||||
m_context->setConfig("addr", m_email->text());
|
m_context->setConfig("addr", m_email->text());
|
||||||
m_context->setConfig("mail_pw", m_password->text());
|
m_context->setConfig("mail_pw", m_password->text());
|
||||||
m_context->configure();
|
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();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDialog::configureProgress(int permille, QString message) {
|
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;
|
QMessageBox messagebox;
|
||||||
messagebox.setText("Login failed.");
|
messagebox.setText("Login failed.");
|
||||||
if (message.length() > 500) {
|
if (message.length() > 500) {
|
||||||
|
@ -56,8 +66,12 @@ void LoginDialog::configureProgress(int permille, QString message) {
|
||||||
}
|
}
|
||||||
messagebox.setIcon(QMessageBox::Critical);
|
messagebox.setIcon(QMessageBox::Critical);
|
||||||
messagebox.exec();
|
messagebox.exec();
|
||||||
show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoginDialog::configureCanceled() {
|
||||||
|
m_progress->deleteLater();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace kappachat
|
} // namespace kappachat
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "deltachat_context.hh"
|
#include "deltachat_context.hh"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
namespace kappachat {
|
namespace kappachat {
|
||||||
|
|
||||||
|
@ -15,11 +16,13 @@ class LoginDialog : public QDialog {
|
||||||
public slots:
|
public slots:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void configureProgress(int permille, QString message);
|
void configureProgress(int permille, QString message);
|
||||||
|
void configureCanceled();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeltachatContext *m_context;
|
DeltachatContext *m_context;
|
||||||
QLineEdit *m_email;
|
QLineEdit *m_email;
|
||||||
QLineEdit *m_password;
|
QLineEdit *m_password;
|
||||||
|
QProgressDialog *m_progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace kappachat
|
} // namespace kappachat
|
||||||
|
|
Loading…
Reference in a new issue