diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-22 04:25:31 +0200 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-22 04:25:31 +0200 |
commit | b568de36a8e2fd5475894fc0cd82d4c3605d5d1f (patch) | |
tree | 9745266c7744f2cb474ecc98213ac8609c4f9fff /keygendialog.cpp | |
parent | 54862e16e1efbd9b943c95833940b637b878559a (diff) |
keygen start, dialog ideas
Diffstat (limited to 'keygendialog.cpp')
-rw-r--r-- | keygendialog.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/keygendialog.cpp b/keygendialog.cpp new file mode 100644 index 00000000..5788cafa --- /dev/null +++ b/keygendialog.cpp @@ -0,0 +1,66 @@ +#include "keygendialog.h" +#include "ui_keygendialog.h" +#include <QDebug> + +KeygenDialog::KeygenDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::KeygenDialog) +{ + ui->setupUi(this); +} + +KeygenDialog::~KeygenDialog() +{ + delete ui; +} + +void KeygenDialog::on_passphrase1_textChanged(const QString &arg1) +{ + if (ui->passphrase1->text() == ui->passphrase2->text()) { + ui->buttonBox->setEnabled(true); + replace("Passphrase", arg1); + } else { + ui->buttonBox->setEnabled(false); + } +} + +void KeygenDialog::on_passphrase2_textChanged(const QString &arg1) +{ + on_passphrase1_textChanged(arg1); +} + +void KeygenDialog::on_checkBox_stateChanged(int arg1) +{ + if (arg1) { + ui->plainTextEdit->setReadOnly(false); + } else { + ui->plainTextEdit->setReadOnly(true); + } +} + +void KeygenDialog::on_email_textChanged(const QString &arg1) +{ + replace("Name-Email", arg1); +} + +void KeygenDialog::on_name_textChanged(const QString &arg1) +{ + replace("Name-Real", arg1); +} + +/** + * @brief KeygenDialog::replace + * @param key + * @param value + */ +void KeygenDialog::replace(QString key, QString value) +{ + QStringList clear; + QString expert = ui->plainTextEdit->toPlainText(); + QStringList lines = expert.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); + foreach (QString line, lines) { + line.replace(QRegExp(key+":.*"), key + ": " + value); + clear.append(line); + } + ui->plainTextEdit->setPlainText(clear.join("\n")); +} |