blob: dc22e5f0204c1b04476809d00adde7e3d7c9dfd4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#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);
connect( // connect with "this" as context, so the connection will die when the window is destroyed
kristall::globals().localization.get(), &Localization::translationChanged,
this, [this]() { this->ui->retranslateUi(this); },
Qt::DirectConnection
);
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(const auto &group_name : kristall::globals().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();
}
|