diff options
| author | Osmium Sorcerer <os@sof.beauty> | 2026-03-22 18:51:12 +0000 |
|---|---|---|
| committer | Osmium Sorcerer <os@sof.beauty> | 2026-03-29 22:22:25 +0000 |
| commit | b1ad938c37f4e175e5509f727d1033b074b134d4 (patch) | |
| tree | 702b41a851550c14104599905907fa659c0d39b7 /src/widgets/key_generate_dialog.cpp | |
| parent | 4274f5036004ae6d3db0e88c8e28eb78c6e37d27 (diff) | |
Integrate the keyring into UI
Add "Keyring" tab to the options dialog. The tab displays the keys from
the table model (notes and certificates) and lets users create and
delete keys.
Key generation dialog includes passphare confirmation and a note.
Diffstat (limited to 'src/widgets/key_generate_dialog.cpp')
| -rw-r--r-- | src/widgets/key_generate_dialog.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/widgets/key_generate_dialog.cpp b/src/widgets/key_generate_dialog.cpp new file mode 100644 index 0000000..1e9790e --- /dev/null +++ b/src/widgets/key_generate_dialog.cpp @@ -0,0 +1,53 @@ +#include "key_generate_dialog.h" + +#include <QFile> +#include <QPushButton> +#include <QUiLoader> +#include <QVBoxLayout> + +#include "options.h" + +KeyGenerateDialog::KeyGenerateDialog(QWidget *parent) + : QDialog(parent) +{ + QUiLoader l_loader(this); + QFile l_uiFile(Options::getInstance().getUIAsset("key_generate_dialog.ui")); + if (!l_uiFile.open(QFile::ReadOnly)) + { + qCritical() << "Unable to open file " << l_uiFile.fileName(); + return; + } + ui_widget = l_loader.load(&l_uiFile, this); + auto l_layout = new QVBoxLayout(this); + l_layout->addWidget(ui_widget); + setWindowTitle("Generate key"); + + FROM_UI(QLineEdit, key_name); + FROM_UI(QLineEdit, key_password); + ui_key_password->setEchoMode(QLineEdit::Password); + connect(ui_key_password, &QLineEdit::textChanged, this, &KeyGenerateDialog::validate); + FROM_UI(QLineEdit, key_password_confirm); + ui_key_password_confirm->setEchoMode(QLineEdit::Password); + connect(ui_key_password_confirm, &QLineEdit::textChanged, this, &KeyGenerateDialog::validate); + FROM_UI(QDialogButtonBox, key_gen_buttons); + connect(ui_key_gen_buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(ui_key_gen_buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); + + validate(); +} + +// Empty passwords should be also checked. +void KeyGenerateDialog::validate() +{ + ui_key_gen_buttons->button(QDialogButtonBox::Ok)->setEnabled(!ui_key_password->text().isEmpty() && (ui_key_password->text() == ui_key_password_confirm->text())); +} + +QStringView KeyGenerateDialog::key_name() +{ + return ui_key_name->text(); +} + +QByteArray KeyGenerateDialog::key_password() +{ + return ui_key_password->text().toUtf8(); +} |
