aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/keygen/KeygenDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/keygen/KeygenDialog.cpp')
-rw-r--r--src/ui/keygen/KeygenDialog.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/src/ui/keygen/KeygenDialog.cpp b/src/ui/keygen/KeygenDialog.cpp
index 7991ddd1..98216dc6 100644
--- a/src/ui/keygen/KeygenDialog.cpp
+++ b/src/ui/keygen/KeygenDialog.cpp
@@ -23,6 +23,7 @@
*/
#include "ui/keygen/KeygenDialog.h"
+#include "ui/WaitingDialog.h"
KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent)
: QDialog(parent), mCtx(ctx) {
@@ -92,34 +93,28 @@ void KeyGenDialog::slotKeyGenAccept() {
genKeyInfo.setExpired(dateEdit->dateTime());
}
- kg = new KeyGenThread(&genKeyInfo, mCtx);
- connect(kg, SIGNAL(signalKeyGenerated(bool)), this, SLOT(slotKeyGenResult(bool)));
- kg->start();
-
- this->accept();
-
- auto *dialog = new QDialog(this, Qt::CustomizeWindowHint | Qt::WindowTitleHint);
- dialog->setModal(true);
- dialog->setWindowTitle(tr("Generating Key..."));
-
- auto *waitMessage = new QLabel(
- tr("Collecting random data for key generation.\n This may take a while.\n To speed up the process use your computer\n (e.g. browse the net, listen to music,...)"));
- auto *pb = new QProgressBar();
- pb->setRange(0, 0);
-
- auto *layout = new QVBoxLayout(dialog);
- layout->addWidget(waitMessage);
- layout->addWidget(pb);
- dialog->setLayout(layout);
+ gpgme_error_t error = false;
+ auto thread = QThread::create([&]() {
+ error = mCtx->generateKey(&genKeyInfo);
+ });
+ thread->start();
+ auto *dialog = new WaitingDialog("Generating", this);
dialog->show();
- while (kg->isRunning()) {
+ while (thread->isRunning()) {
QCoreApplication::processEvents();
}
dialog->close();
+ if(gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
+ QMessageBox::information(this, tr("Success"), tr("The new key pair has been generated."));
+ this->close();
+ }
+ else
+ QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error)));
+
} else {
/**
* create error message
@@ -307,13 +302,6 @@ bool KeyGenDialog::check_email_address(const QString &str) {
return re_email.match(str).hasMatch();
}
-void KeyGenDialog::slotKeyGenResult(bool success) {
- if(success)
- QMessageBox::information(nullptr, tr("Success"), tr("The new key pair has been generated."));
- else
- QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during key generation."));
-}
-
QGroupBox *KeyGenDialog::create_basic_info_group_box() {
errorLabel = new QLabel(tr(""));