aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/keygen/SubkeyGenerateDialog.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2021-07-20 19:01:06 +0000
committerSaturneric <[email protected]>2021-07-20 19:01:06 +0000
commit69e33d6eeef7d77385d21c5b969df76cb0fbc0e7 (patch)
tree333861b3e1691dd720c410388639a429458c5eb5 /src/ui/keygen/SubkeyGenerateDialog.cpp
parentFix problem that macos cannot use multi-languages. (diff)
downloadGpgFrontend-69e33d6eeef7d77385d21c5b969df76cb0fbc0e7.tar.gz
GpgFrontend-69e33d6eeef7d77385d21c5b969df76cb0fbc0e7.zip
Fix Keygen Problem
Diffstat (limited to '')
-rw-r--r--src/ui/keygen/SubkeyGenerateDialog.cpp41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/ui/keygen/SubkeyGenerateDialog.cpp b/src/ui/keygen/SubkeyGenerateDialog.cpp
index c545381f..3d709d81 100644
--- a/src/ui/keygen/SubkeyGenerateDialog.cpp
+++ b/src/ui/keygen/SubkeyGenerateDialog.cpp
@@ -23,6 +23,7 @@
*/
#include "ui/keygen/SubkeyGenerateDialog.h"
+#include "ui/WaitingDialog.h"
SubkeyGenerateDialog::SubkeyGenerateDialog(GpgME::GpgContext *ctx, const GpgKey &key, QWidget *parent)
: genKeyInfo(true), mCtx(ctx), mKey(key), QDialog(parent) {
@@ -224,34 +225,27 @@ void SubkeyGenerateDialog::slotKeyGenAccept() {
genKeyInfo.setExpired(dateEdit->dateTime());
}
- kg = new SubkeyGenerateThread(mKey ,&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 Subkey..."));
-
- auto *waitMessage = new QLabel(
- tr("Collecting random data for subkey 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->generateSubkey(mKey, &genKeyInfo);
+ });
+ thread->start();
+ auto *dialog = new WaitingDialog("Generating", this);
dialog->show();
- while (!kg->isFinished() && kg->isRunning()) {
+ while (thread->isRunning()) {
QCoreApplication::processEvents();
}
dialog->close();
+ if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
+ QMessageBox::information(nullptr, tr("Success"), tr("The new subkey has been generated."));
+ this->close();
+ } else
+ QMessageBox::critical(this, tr("Failure"), tr(gpgme_strerror(error)));
+
} else {
/**
* create error message
@@ -303,10 +297,3 @@ void SubkeyGenerateDialog::slotActivatedKeyType(int index) {
genKeyInfo.setAlgo(this->keyTypeComboBox->itemText(index));
refresh_widgets_state();
}
-
-void SubkeyGenerateDialog::slotKeyGenResult(bool success) {
- if(success)
- QMessageBox::information(nullptr, tr("Success"), tr("The new subkey has been generated."));
- else
- QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during subkey generation."));
-}