QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
keygendialog.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#ifndef SRC_KEYGENDIALOG_H_
9#define SRC_KEYGENDIALOG_H_
10
11#include <QDialog>
12#include <QScopedPointer>
13#include <memory>
14
15#include "qprogressindicator.h"
16
17namespace Ui {
18class KeygenDialog;
19}
20
21class Pass;
22
40class KeygenDialog : public QDialog {
41 Q_OBJECT
42
43public:
51 explicit KeygenDialog(const QString &gpgExe, Pass *pass,
52 QWidget *parent = nullptr);
54 ~KeygenDialog() override;
55
65 static QString applyPassphrase(const QString &batch,
66 const QString &passphrase);
67
77 [[nodiscard]] static auto isBatchValue(const QString &value) -> bool;
78
79protected:
80private slots:
86 void on_passphrase1_textChanged(const QString &arg1);
91 void on_passphrase2_textChanged(const QString &arg1);
97 void setNoPassphrase(bool checked);
105 void setExpertMode(bool checked);
110 void on_email_textChanged(const QString &arg1);
115 void on_name_textChanged(const QString &arg1);
116
117private:
123 void updateOkState();
129 auto passphraseChosen() const -> bool;
131 QScopedPointer<Ui::KeygenDialog> ui;
139 void replace(const QString &key, const QString &value);
148 void done(int r) override;
155 void startGeneration(const QString &batch);
162 void generationFailed(const QString &error);
167 QMetaObject::Connection m_finished;
170 QMetaObject::Connection m_failed;
173 std::unique_ptr<QProgressIndicator> m_progressIndicator;
174};
175
176#endif // SRC_KEYGENDIALOG_H_
static QString applyPassphrase(const QString &batch, const QString &passphrase)
Splice a passphrase into a GPG batch template.
void replace(const QString &key, const QString &value)
Rewrites every <key>: ... line of the batch template to carry value. Values that fail isBatchValue() ...
std::unique_ptr< QProgressIndicator > m_progressIndicator
Spinner shown while gpg works; created lazily on the first attempt, reused (hidden) across retries.
KeygenDialog(const QString &gpgExe, Pass *pass, QWidget *parent=nullptr)
Construct a KeygenDialog.
void setExpertMode(bool checked)
Enable or disable expert mode (the editable batch template).
void setNoPassphrase(bool checked)
Ticking "no passphrase" clears and disables the passphrase fields and makes OK available; unticking i...
void on_passphrase1_textChanged(const QString &arg1)
First passphrase field edited: re-evaluates whether OK may be enabled. The text itself stays out of t...
void generationFailed(const QString &error)
Stops and hides the progress indicator, re-enables the form under the usual OK rule and shows error i...
void done(int r) override
On Accepted, validates the form (passphrase chosen, no line breaks, name of 5+ characters,...
QMetaObject::Connection m_failed
Connection to Pass::generateGPGKeysFailed, live only during an attempt.
void startGeneration(const QString &batch)
Connects to the backend's finished/failed signals for this one attempt and calls Pass::GenerateGPGKey...
void on_email_textChanged(const QString &arg1)
Mirrors the e-mail field into the template's Name-Email: line.
QScopedPointer< Ui::KeygenDialog > ui
Generated form (keygendialog.ui); owned.
~KeygenDialog() override
Destroys the dialog and its generated UI.
void updateOkState()
OK is available when a passphrase is typed twice the same, or when no passphrase was asked for explic...
Pass * m_pass
Backend that runs gpg; not owned, may be nullptr.
void on_name_textChanged(const QString &arg1)
Mirrors the name field into the template's Name-Real: line.
QMetaObject::Connection m_finished
Connection to Pass::finishedGenerateGPGKeys, live only during an attempt.
auto passphraseChosen() const -> bool
Whether the passphrase question has an answer: typed twice the same, or waived with the checkbox....
void on_passphrase2_textChanged(const QString &arg1)
Confirmation field edited: same as on_passphrase1_textChanged().
static auto isBatchValue(const QString &value) -> bool
Whether value can go into a GPG batch line as one value.
Abstract base class for password store operations.
Definition pass.h:75