Handles GPG keypair generation.
More...
#include <keygendialog.h>
|
| static QString | applyPassphrase (const QString &batch, const QString &passphrase) |
| | Splice a passphrase into a GPG batch template.
|
| static auto | isBatchValue (const QString &value) -> bool |
| | Whether value can go into a GPG batch line as one value.
|
|
| void | on_passphrase1_textChanged (const QString &arg1) |
| | First passphrase field edited: re-evaluates whether OK may be enabled. The text itself stays out of the template box.
|
| void | on_passphrase2_textChanged (const QString &arg1) |
| | Confirmation field edited: same as on_passphrase1_textChanged().
|
| void | setNoPassphrase (bool checked) |
| | Ticking "no passphrase" clears and disables the passphrase fields and makes OK available; unticking it asks for one again.
|
| void | setExpertMode (bool checked) |
| | Enable or disable expert mode (the editable batch template).
|
| void | on_email_textChanged (const QString &arg1) |
| | Mirrors the e-mail field into the template's Name-Email: line.
|
| void | on_name_textChanged (const QString &arg1) |
| | Mirrors the name field into the template's Name-Real: line.
|
|
| void | updateOkState () |
| | OK is available when a passphrase is typed twice the same, or when no passphrase was asked for explicitly. Empty fields alone are not a choice: the key would be stored unprotected without anyone saying so.
|
| auto | passphraseChosen () const -> bool |
| | Whether the passphrase question has an answer: typed twice the same, or waived with the checkbox. Empty fields alone are neither.
|
| void | replace (const QString &key, const QString &value) |
| | Rewrites every <key>: ... line of the batch template to carry value. Values that fail isBatchValue() are ignored so a pasted line break can never become a directive of its own.
|
| void | done (int r) override |
| | On Accepted, validates the form (passphrase chosen, no line breaks, name of 5+ characters, plausible e-mail), swaps the form for the progress indicator and calls startGeneration(); the dialog only closes once the backend reports success. Any other result disconnects the backend signals and closes normally.
|
| void | startGeneration (const QString &batch) |
| | Connects to the backend's finished/failed signals for this one attempt and calls Pass::GenerateGPGKeys(). With no backend the attempt fails at once.
|
| void | generationFailed (const QString &error) |
| | Stops and hides the progress indicator, re-enables the form under the usual OK rule and shows error in the status label, so the user can correct the input and try again.
|
Handles GPG keypair generation.
The form asks for a name, an e-mail address and a passphrase typed twice (or an explicit "no passphrase"); an Expert checkbox reveals the editable GPG batch template that the name and e-mail fields are mirrored into. The passphrase is never written into that template: on OK, done() validates the fields, splices the passphrase in with applyPassphrase() and hands the batch to Pass::GenerateGPGKeys(), replacing the form with a progress indicator. The dialog owns nothing of the backend; it connects to Pass::finishedGenerateGPGKeys (accept) and Pass::generateGPGKeysFailed (show the error and give the form back) for the duration of one attempt only, so an exec() caller such as the first-run wizard sees Accepted exactly when a key exists.
Definition at line 40 of file keygendialog.h.
◆ KeygenDialog()
| KeygenDialog::KeygenDialog |
( |
const QString & | gpgExe, |
|
|
Pass * | pass, |
|
|
QWidget * | parent = nullptr ) |
|
explicit |
Construct a KeygenDialog.
- Parameters
-
| gpgExe | Path to the gpg executable (for the default template). |
| pass | Backend that runs gpg --gen-key; the dialog accepts on its finishedGenerateGPGKeys() and shows generateGPGKeysFailed(). |
| parent | Parent widget, or nullptr. |
Definition at line 24 of file keygendialog.cpp.
◆ ~KeygenDialog()
| KeygenDialog::~KeygenDialog |
( |
| ) |
|
|
overridedefault |
Destroys the dialog and its generated UI.
◆ applyPassphrase()
| QString KeygenDialog::applyPassphrase |
( |
const QString & | batch, |
|
|
const QString & | passphrase ) |
|
static |
Splice a passphrase into a GPG batch template.
Replaces no-protection (or an existing Passphrase: line) with "Passphrase: <passphrase>"; an empty passphrase yields no-protection.
- Parameters
-
| batch | GPG batch template text. |
| passphrase | Key passphrase, empty for an unprotected key. |
- Returns
- Batch text ready for gpg –gen-key –batch.
Definition at line 130 of file keygendialog.cpp.
◆ done()
| void KeygenDialog::done |
( |
int | r | ) |
|
|
overrideprivate |
On Accepted, validates the form (passphrase chosen, no line breaks, name of 5+ characters, plausible e-mail), swaps the form for the progress indicator and calls startGeneration(); the dialog only closes once the backend reports success. Any other result disconnects the backend signals and closes normally.
- Parameters
-
| r | The QDialog result code. |
Definition at line 176 of file keygendialog.cpp.
◆ generationFailed()
| void KeygenDialog::generationFailed |
( |
const QString & | error | ) |
|
|
private |
Stops and hides the progress indicator, re-enables the form under the usual OK rule and shows error in the status label, so the user can correct the input and try again.
- Parameters
-
| error | Backend error text; HTML-escaped before display. |
Definition at line 272 of file keygendialog.cpp.
◆ isBatchValue()
| auto KeygenDialog::isBatchValue |
( |
const QString & | value | ) |
-> bool |
|
staticnodiscard |
Whether value can go into a GPG batch line as one value.
The batch is line-oriented, and gpg reads a line as a C string: a line break or NUL in a name or passphrase would start a directive of its own (no-protection, a Passphrase: of the paster's choosing).
- Parameters
-
- Returns
- False when it holds a CR, LF or NUL.
Definition at line 171 of file keygendialog.cpp.
◆ on_email_textChanged
| void KeygenDialog::on_email_textChanged |
( |
const QString & | arg1 | ) |
|
|
privateslot |
Mirrors the e-mail field into the template's Name-Email: line.
- Parameters
-
Definition at line 83 of file keygendialog.cpp.
◆ on_name_textChanged
| void KeygenDialog::on_name_textChanged |
( |
const QString & | arg1 | ) |
|
|
privateslot |
Mirrors the name field into the template's Name-Real: line.
- Parameters
-
Definition at line 87 of file keygendialog.cpp.
◆ on_passphrase1_textChanged
| void KeygenDialog::on_passphrase1_textChanged |
( |
const QString & | arg1 | ) |
|
|
privateslot |
First passphrase field edited: re-evaluates whether OK may be enabled. The text itself stays out of the template box.
- Parameters
-
| arg1 | The new field text (unused). |
Definition at line 48 of file keygendialog.cpp.
◆ on_passphrase2_textChanged
| void KeygenDialog::on_passphrase2_textChanged |
( |
const QString & | arg1 | ) |
|
|
privateslot |
◆ passphraseChosen()
| auto KeygenDialog::passphraseChosen |
( |
| ) |
const -> bool |
|
private |
Whether the passphrase question has an answer: typed twice the same, or waived with the checkbox. Empty fields alone are neither.
- Returns
- true when generation may proceed as far as the passphrase goes.
Definition at line 53 of file keygendialog.cpp.
◆ replace()
| void KeygenDialog::replace |
( |
const QString & | key, |
|
|
const QString & | value ) |
|
private |
Rewrites every <key>: ... line of the batch template to carry value. Values that fail isBatchValue() are ignored so a pasted line break can never become a directive of its own.
- Parameters
-
| key | Batch parameter name, e.g. Name-Real. |
| value | New value for that parameter. |
Definition at line 91 of file keygendialog.cpp.
◆ setExpertMode
| void KeygenDialog::setExpertMode |
( |
bool | checked | ) |
|
|
privateslot |
Enable or disable expert mode (the editable batch template).
Connected explicitly to QCheckBox::toggled in the constructor; the box is two-state, so the deprecated stateChanged(int) is not needed.
- Parameters
-
| checked | true when the Expert box is checked. |
Definition at line 77 of file keygendialog.cpp.
◆ setNoPassphrase
| void KeygenDialog::setNoPassphrase |
( |
bool | checked | ) |
|
|
privateslot |
Ticking "no passphrase" clears and disables the passphrase fields and makes OK available; unticking it asks for one again.
- Parameters
-
| checked | The checkbox state. |
Definition at line 63 of file keygendialog.cpp.
◆ startGeneration()
| void KeygenDialog::startGeneration |
( |
const QString & | batch | ) |
|
|
private |
Connects to the backend's finished/failed signals for this one attempt and calls Pass::GenerateGPGKeys(). With no backend the attempt fails at once.
- Parameters
-
| batch | Complete batch text, passphrase already spliced in. |
Definition at line 249 of file keygendialog.cpp.
◆ updateOkState()
| void KeygenDialog::updateOkState |
( |
| ) |
|
|
private |
OK is available when a passphrase is typed twice the same, or when no passphrase was asked for explicitly. Empty fields alone are not a choice: the key would be stored unprotected without anyone saying so.
Definition at line 59 of file keygendialog.cpp.
◆ m_failed
| QMetaObject::Connection KeygenDialog::m_failed |
|
private |
◆ m_finished
| QMetaObject::Connection KeygenDialog::m_finished |
|
private |
◆ m_pass
| Pass* KeygenDialog::m_pass |
|
private |
Backend that runs gpg; not owned, may be nullptr.
Definition at line 164 of file keygendialog.h.
◆ m_progressIndicator
| std::unique_ptr<QProgressIndicator> KeygenDialog::m_progressIndicator |
|
private |
Spinner shown while gpg works; created lazily on the first attempt, reused (hidden) across retries.
Definition at line 173 of file keygendialog.h.
◆ ui
| QScopedPointer<Ui::KeygenDialog> KeygenDialog::ui |
|
private |
Generated form (keygendialog.ui); owned.
Definition at line 131 of file keygendialog.h.
The documentation for this class was generated from the following files: