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("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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue