aboutsummaryrefslogtreecommitdiff
path: root/src/dialogs/newidentitiydialog.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-22 21:10:04 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-22 21:10:04 +0200
commit75ec461eeaa851cb5c53f4cfffc434e3e529ed1d (patch)
tree3944737340718ca3675381aa06636045d397e780 /src/dialogs/newidentitiydialog.cpp
parent8dbfb0890560fd1cd698d06fa05ac868c4db8576 (diff)
downloadkristall-75ec461eeaa851cb5c53f4cfffc434e3e529ed1d.tar.gz
Restructures the project source and cleans up a bit
Diffstat (limited to 'src/dialogs/newidentitiydialog.cpp')
-rw-r--r--src/dialogs/newidentitiydialog.cpp81
1 files changed, 81 insertions, 0 deletions
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 <QPushButton>
+#include <QDebug>
+
+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();
+}