diff options
author | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-01-26 19:21:51 +0000 |
---|---|---|
committer | nils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-01-26 19:21:51 +0000 |
commit | d02a237cb2e55eb4aa330fd3da9309e7ecbe8768 (patch) | |
tree | b5eb7cb2cd1d837adabd8617e232653f5102af29 | |
parent | show messagebox, when key export failed. Added more comments (diff) | |
download | gpg4usb-d02a237cb2e55eb4aa330fd3da9309e7ecbe8768.tar.gz gpg4usb-d02a237cb2e55eb4aa330fd3da9309e7ecbe8768.zip |
refresh files
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@782 34ebc366-c3a9-4b3c-9f84-69acf7962910
Diffstat (limited to '')
-rw-r--r-- | keydetailsdialog.cpp | 3 | ||||
-rw-r--r-- | keydetailsdialog.h | 7 | ||||
-rw-r--r-- | keygendialog.cpp | 39 | ||||
-rw-r--r-- | keygendialog.h | 54 |
4 files changed, 61 insertions, 42 deletions
diff --git a/keydetailsdialog.cpp b/keydetailsdialog.cpp index 197c4eb..1dc3d2d 100644 --- a/keydetailsdialog.cpp +++ b/keydetailsdialog.cpp @@ -198,9 +198,10 @@ void KeyDetailsDialog::exportPrivateKey() QString fileString = QString(key->uids->name) + " " + QString(key->uids->email) + "(" + QString(key->subkeys->keyid)+ ")_pub_sec.asc"; QString fileName = QFileDialog::getSaveFileName(this, tr("Export Key To File"), fileString, tr("Key Files") + " (*.asc *.txt);;All Files (*)"); QFile file(fileName); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(0,tr("Export error"),tr("Couldn't open %1 for writing").arg(fileName)); return; + } QTextStream stream(&file); stream << *keyArray; file.close(); diff --git a/keydetailsdialog.h b/keydetailsdialog.h index e2af725..37edd43 100644 --- a/keydetailsdialog.h +++ b/keydetailsdialog.h @@ -52,7 +52,14 @@ public: static QString beautifyFingerprint(QString fingerprint); private slots: + /** + * @details Export the key to a file, which is choosen in a file dialog + */ void exportPrivateKey(); + + /** + * @details Copy the fingerprint to clipboard + */ void copyFingerprint(); private: diff --git a/keygendialog.cpp b/keygendialog.cpp index 20e08ff..981418c 100644 --- a/keygendialog.cpp +++ b/keygendialog.cpp @@ -35,15 +35,6 @@ KeyGenDialog::KeyGenDialog(GpgME::GpgContext *ctx, QWidget *parent) void KeyGenDialog::generateKeyDialog() { - nameLabel = new QLabel(tr("Name:")); - emailLabel = new QLabel(tr("E-Mailaddress::")); - commentLabel = new QLabel(tr("Comment:")); - keySizeLabel = new QLabel(tr("KeySize (in Bit):")); - dateLabel = new QLabel(tr("Expiration Date:")); - passwordLabel = new QLabel(tr("Password:")); - repeatpwLabel = new QLabel(tr("Repeat Password:")); - expireLabel = new QLabel(tr("Never Expire")); - pwStrengthLabel = new QLabel(tr("Password: Strength\nWeak -> Strong")); errorLabel = new QLabel(tr("")); nameEdit = new QLineEdit(this); emailEdit = new QLineEdit(this); @@ -78,22 +69,24 @@ void KeyGenDialog::generateKeyDialog() pwStrengthSlider->setTickPosition(QSlider::TicksBelow); QGridLayout *vbox1 = new QGridLayout; - vbox1->addWidget(nameLabel, 0, 0); + + vbox1->addWidget(new QLabel(tr("Name:")), 0, 0); + vbox1->addWidget(new QLabel(tr("E-Mailaddress:")), 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("Password:")), 5, 0); + vbox1->addWidget(new QLabel(tr("Password: Strength\nWeak -> Strong")), 5, 3); + vbox1->addWidget(new QLabel(tr("Repeat Password:")), 6, 0); + vbox1->addWidget(nameEdit, 0, 1); - vbox1->addWidget(emailLabel, 1, 0); vbox1->addWidget(emailEdit, 1, 1); - vbox1->addWidget(commentLabel, 2, 0); vbox1->addWidget(commentEdit, 2, 1); - vbox1->addWidget(dateLabel, 3, 0); vbox1->addWidget(dateEdit, 3, 1); vbox1->addWidget(expireCheckBox, 3, 2); - vbox1->addWidget(expireLabel, 3, 3); - vbox1->addWidget(keySizeLabel, 4, 0); vbox1->addWidget(keySizeSpinBox, 4, 1); - vbox1->addWidget(passwordLabel, 5, 0); vbox1->addWidget(passwordEdit, 5, 1); - vbox1->addWidget(pwStrengthLabel, 5, 3); - vbox1->addWidget(repeatpwLabel, 6, 0); vbox1->addWidget(repeatpwEdit, 6, 1); vbox1->addWidget(pwStrengthSlider, 6, 3); @@ -211,18 +204,28 @@ void KeyGenDialog::passwordEditChanged() int KeyGenDialog::checkPassWordStrength() { int strength = 0; + + // increase strength by two, if password has more than 7 characters if ((passwordEdit->text()).length() > 7) { strength = strength + 2; } + + // increase strength by one, if password contains a digit if ((passwordEdit->text()).contains(QRegExp("\\d"))) { strength++; } + + // increase strength by one, if password contains a lowercase character if ((passwordEdit->text()).contains(QRegExp("[a-z]"))) { strength++; } + + // increase strength by one, if password contains an uppercase character if ((passwordEdit->text()).contains(QRegExp("[A-Z]"))) { strength++; } + + // increase strength by one, if password contains a non-word character if ((passwordEdit->text()).contains(QRegExp("\\W"))) { strength++; } diff --git a/keygendialog.h b/keygendialog.h index 2c6292a..f2de274 100644 --- a/keygendialog.h +++ b/keygendialog.h @@ -42,35 +42,43 @@ public: private: void generateKeyDialog(); + + /** + * @details Check the password strength of the text in the passwordEdit member + * + * @return digit between 0 and 6, the higher the more secure is the password + */ int checkPassWordStrength(); - GpgME::GpgContext *mCtx; - KeyGenThread *keyGenThread; - QStringList errorMessages; - QDialogButtonBox *buttonBox; - QLabel *nameLabel; - QLabel *emailLabel; - QLabel *commentLabel; - QLabel *keySizeLabel; - QLabel *passwordLabel; - QLabel *repeatpwLabel; - QLabel *errorLabel; - QLabel *dateLabel; - QLabel *expireLabel; - QLabel *pwStrengthLabel; - QLineEdit *nameEdit; - QLineEdit *emailEdit; - QLineEdit *commentEdit; - QLineEdit *passwordEdit; - QLineEdit *repeatpwEdit; - QSpinBox *keySizeSpinBox; - QDateTimeEdit *dateEdit; - QCheckBox *expireCheckBox; - QSlider *pwStrengthSlider; + GpgME::GpgContext *mCtx; /** The current gpg context */ + KeyGenThread *keyGenThread; /** Thread for key generation */ + QStringList errorMessages; /** List of errors occuring when checking entries of lineedits */ + QDialogButtonBox *buttonBox; /** Box for standardbuttons */ + QLabel *errorLabel; /** Label containing error message */ + QLineEdit *nameEdit; /** Lineedit for the keys name */ + QLineEdit *emailEdit; /** Lineedit for the keys email */ + QLineEdit *commentEdit; /** Lineedit for the keys comment */ + QLineEdit *passwordEdit; /** Lineedit for the keys password */ + QLineEdit *repeatpwEdit; /** Lineedit for the repetition of the keys password */ + QSpinBox *keySizeSpinBox; /** Spinbox for the keys size (in bit) */ + QDateTimeEdit *dateEdit; /** Dateedit for expiration date */ + QCheckBox *expireCheckBox; /** Checkbox, if key should expire */ + QSlider *pwStrengthSlider; /** Slider showing the password strength */ private slots: + /** + * @details when expirebox was checked/unchecked, enable/disable the expiration date box + */ void expireBoxChanged(); + + /** + * @details When passwordedit changed, set new value for password strength slider + */ void passwordEditChanged(); + + /** + * @details check all lineedits for false entries. Show error, when there is one, otherwise generate the key + */ void keyGenAccept(); }; |