diff options
author | Saturneric <[email protected]> | 2021-05-27 19:51:18 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2021-05-27 19:51:18 +0000 |
commit | ad4c0c1e140de2ffdd2f803a643bdfe4c0fb07bc (patch) | |
tree | f01ad3ec20f85a17d433502e169eab99f2719b92 /src/ui/KeygenDialog.cpp | |
parent | Fix the wrong use of the signing key interface. (diff) | |
download | GpgFrontend-ad4c0c1e140de2ffdd2f803a643bdfe4c0fb07bc.tar.gz GpgFrontend-ad4c0c1e140de2ffdd2f803a643bdfe4c0fb07bc.zip |
Adjust part of the text of the UI interface of the UID operation tab.
Write an interface to increase UID.
Write logic to adapt and increase UID.
Adjust the UI of KeygenDialog.
Delete the Close button of KeyDetailTab and its logic.
Adjust the KeyDetailTab fingerprint and its copy button UI.
Fix the problem of refreshing the order of the KeyPairUIDTab list.
Signed-off-by: Saturneric <[email protected]>
Diffstat (limited to 'src/ui/KeygenDialog.cpp')
-rw-r--r-- | src/ui/KeygenDialog.cpp | 112 |
1 files changed, 61 insertions, 51 deletions
diff --git a/src/ui/KeygenDialog.cpp b/src/ui/KeygenDialog.cpp index ef07dc14..d930fffe 100644 --- a/src/ui/KeygenDialog.cpp +++ b/src/ui/KeygenDialog.cpp @@ -26,6 +26,7 @@ KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent) : QDialog(parent), mCtx(ctx) { + buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); this->setWindowTitle(tr("Generate Key")); @@ -37,57 +38,8 @@ void KeyGenDialog::generateKeyDialog() { keyUsageGroupBox = create_key_usage_group_box(); - errorLabel = new QLabel(tr("")); - nameEdit = new QLineEdit(this); - emailEdit = new QLineEdit(this); - commentEdit = new QLineEdit(this); - keySizeSpinBox = new QSpinBox(this); - keyTypeComboBox = new QComboBox(this); - - for(auto &algo : GenKeyInfo::SupportedKeyAlgo) { - keyTypeComboBox->addItem(algo); - } - if(!GenKeyInfo::SupportedKeyAlgo.isEmpty()) { - keyTypeComboBox->setCurrentIndex(0); - } - - QDateTime maxDateTime = QDateTime::currentDateTime().addYears(2); - - dateEdit = new QDateTimeEdit(maxDateTime, this); - dateEdit->setMinimumDateTime(QDateTime::currentDateTime()); - dateEdit->setMaximumDateTime(maxDateTime); - dateEdit->setDisplayFormat("dd/MM/yyyy hh:mm:ss"); - dateEdit->setCalendarPopup(true); - dateEdit->setEnabled(true); - - expireCheckBox = new QCheckBox(this); - expireCheckBox->setCheckState(Qt::Unchecked); - - noPassPhraseCheckBox = new QCheckBox(this); - noPassPhraseCheckBox->setCheckState(Qt::Unchecked); - - auto *vbox1 = new QGridLayout; - - vbox1->addWidget(new QLabel(tr("Name:")), 0, 0); - vbox1->addWidget(new QLabel(tr("Email Address:")), 1, 0); - vbox1->addWidget(new QLabel(tr("Comment:")), 2, 0); - vbox1->addWidget(new QLabel(tr("Expiration Date:")), 3, 0); - vbox1->addWidget(new QLabel(tr("Never Expire")), 3, 3); - vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 4, 0); - vbox1->addWidget(new QLabel(tr("Key Type:")), 5, 0); - vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 0); - - vbox1->addWidget(nameEdit, 0, 1, 1, 3); - vbox1->addWidget(emailEdit, 1, 1, 1, 3); - vbox1->addWidget(commentEdit, 2, 1, 1, 3); - vbox1->addWidget(dateEdit, 3, 1); - vbox1->addWidget(expireCheckBox, 3, 2); - vbox1->addWidget(keySizeSpinBox, 4, 1); - vbox1->addWidget(keyTypeComboBox, 5, 1); - vbox1->addWidget(noPassPhraseCheckBox, 6, 1); - auto *groupGrid = new QGridLayout(this); - groupGrid->addLayout(vbox1, 0, 0); + groupGrid->addWidget(create_basic_info_group_box(), 0, 0); groupGrid->addWidget(keyUsageGroupBox, 1, 0); auto *nameList = new QWidget(this); @@ -131,7 +83,7 @@ void KeyGenDialog::slotKeyGenAccept() { * create the string for key generation */ - genKeyInfo.setUserid(QString("%1 <%2>").arg(nameEdit->text(), emailEdit->text())); + genKeyInfo.setUserid(QString("%1 (%3) <%2>").arg(nameEdit->text(), emailEdit->text(), commentEdit->text())); genKeyInfo.setKeySize(keySizeSpinBox->value()); @@ -362,3 +314,61 @@ void KeyGenDialog::slotKeyGenResult(bool success) { else QMessageBox::critical(nullptr, tr("Failure"), tr("An error occurred during key generation.")); } + +QGroupBox *KeyGenDialog::create_basic_info_group_box() { + + errorLabel = new QLabel(tr("")); + nameEdit = new QLineEdit(this); + emailEdit = new QLineEdit(this); + commentEdit = new QLineEdit(this); + keySizeSpinBox = new QSpinBox(this); + keyTypeComboBox = new QComboBox(this); + + for(auto &algo : GenKeyInfo::SupportedKeyAlgo) { + keyTypeComboBox->addItem(algo); + } + if(!GenKeyInfo::SupportedKeyAlgo.isEmpty()) { + keyTypeComboBox->setCurrentIndex(0); + } + + QDateTime maxDateTime = QDateTime::currentDateTime().addYears(2); + + dateEdit = new QDateTimeEdit(maxDateTime, this); + dateEdit->setMinimumDateTime(QDateTime::currentDateTime()); + dateEdit->setMaximumDateTime(maxDateTime); + dateEdit->setDisplayFormat("dd/MM/yyyy hh:mm:ss"); + dateEdit->setCalendarPopup(true); + dateEdit->setEnabled(true); + + expireCheckBox = new QCheckBox(this); + expireCheckBox->setCheckState(Qt::Unchecked); + + noPassPhraseCheckBox = new QCheckBox(this); + noPassPhraseCheckBox->setCheckState(Qt::Unchecked); + + auto *vbox1 = new QGridLayout; + + vbox1->addWidget(new QLabel(tr("Name:")), 0, 0); + vbox1->addWidget(new QLabel(tr("Email Address:")), 1, 0); + vbox1->addWidget(new QLabel(tr("Comment:")), 2, 0); + vbox1->addWidget(new QLabel(tr("Expiration Date:")), 3, 0); + vbox1->addWidget(new QLabel(tr("Never Expire")), 3, 3); + vbox1->addWidget(new QLabel(tr("KeySize (in Bit):")), 4, 0); + vbox1->addWidget(new QLabel(tr("Key Type:")), 5, 0); + vbox1->addWidget(new QLabel(tr("Non Pass Phrase")), 6, 0); + + vbox1->addWidget(nameEdit, 0, 1, 1, 3); + vbox1->addWidget(emailEdit, 1, 1, 1, 3); + vbox1->addWidget(commentEdit, 2, 1, 1, 3); + vbox1->addWidget(dateEdit, 3, 1); + vbox1->addWidget(expireCheckBox, 3, 2); + vbox1->addWidget(keySizeSpinBox, 4, 1); + vbox1->addWidget(keyTypeComboBox, 5, 1); + vbox1->addWidget(noPassPhraseCheckBox, 6, 1); + + auto basicInfoGroupBox = new QGroupBox(); + basicInfoGroupBox->setLayout(vbox1); + basicInfoGroupBox->setTitle(tr("Basic Information")); + + return basicInfoGroupBox; +} |