From 75ec461eeaa851cb5c53f4cfffc434e3e529ed1d Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Mon, 22 Jun 2020 21:10:04 +0200 Subject: Restructures the project source and cleans up a bit --- src/dialogs/newidentitiydialog.cpp | 81 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/dialogs/newidentitiydialog.cpp (limited to 'src/dialogs/newidentitiydialog.cpp') diff --git a/src/dialogs/newidentitiydialog.cpp b/src/dialogs/newidentitiydialog.cpp new file mode 100644 index 0000000..af2a97e --- /dev/null +++ b/src/dialogs/newidentitiydialog.cpp @@ -0,0 +1,81 @@ +#include "newidentitiydialog.hpp" +#include "ui_newidentitiydialog.h" + +#include "certificatehelper.hpp" +#include "kristall.hpp" + +#include +#include + +NewIdentitiyDialog::NewIdentitiyDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NewIdentitiyDialog) +{ + ui->setupUi(this); + + ui->display_name->setText("Unnamed"); + ui->common_name->setText("Unnamed"); + ui->expiration_date->setDate(QDate::currentDate().addYears(1)); + ui->expiration_date->setTime(QTime(12, 00)); + + ui->group->clear(); + for(auto group_name : global_identities.groups()) + { + ui->group->addItem(group_name); + } +} + +NewIdentitiyDialog::~NewIdentitiyDialog() +{ + delete ui; +} + +CryptoIdentity NewIdentitiyDialog::createIdentity() const +{ + auto id = CertificateHelper::createNewIdentity( + this->ui->common_name->text(), + this->ui->expiration_date->dateTime() + ); + id.display_name = this->ui->display_name->text(); + return id; +} + +QString NewIdentitiyDialog::groupName() const +{ + return this->ui->group->currentText(); +} + +void NewIdentitiyDialog::setGroupName(const QString &name) +{ + this->ui->group->setCurrentText(name); +} + +void NewIdentitiyDialog::updateUI() +{ + bool is_ok = true; + + is_ok &= (not this->ui->group->currentText().isEmpty()); + is_ok &= (not this->ui->common_name->text().isEmpty()); + is_ok &= (not this->ui->display_name->text().isEmpty()); + is_ok &= (this->ui->expiration_date->dateTime() > QDateTime::currentDateTime()); + + this->ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(is_ok); +} + +void NewIdentitiyDialog::on_group_editTextChanged(const QString &arg1) +{ + Q_UNUSED(arg1); + this->updateUI(); +} + +void NewIdentitiyDialog::on_display_name_textChanged(const QString &arg1) +{ + Q_UNUSED(arg1); + this->updateUI(); +} + +void NewIdentitiyDialog::on_common_name_textChanged(const QString &arg1) +{ + Q_UNUSED(arg1); + this->updateUI(); +} -- cgit v1.2.3