Dialog for importing GPG keys from file or clipboard.
More...
#include <importkeydialog.h>
|
| static auto | parseGpgImportOutput (const QString &output) -> QString |
| | Parse GPG import output to extract a key id or fingerprint.
|
|
| void | on_fileButton_clicked () |
| | "From file" button: picks a file, reads it as a regular file of at most 16 MiB, requires the -----BEGIN PGP armor header and loads the text into the input field. Binary keyrings are refused with a hint to gpg --armor --export first.
|
| void | on_pasteButton_clicked () |
| | "From clipboard" button: replaces the input field with the clipboard text, unless the clipboard is empty.
|
| void | on_importButton_clicked () |
| | "Import" button: runs importFromString() on the trimmed input and closes the dialog with accept() on success.
|
| void | on_inputTextEdit_textChanged () |
| | Enables the Import button only while the input field holds non-blank text.
|
|
| auto | importFromString (const QString &input) -> bool |
| | Feeds input to gpg --status-fd 1 --import --batch --yes via Executor::executeBlocking() and records the imported key id.
|
| void | showError (const QString &message) |
| | Shows message in a plain-text warning box (gpg's stderr quotes user IDs, which must not be read as markup).
|
| void | showSuccess (const QString &keyId) |
| | Shows the "imported, now verify the fingerprint" information box.
|
|
| QScopedPointer< Ui::ImportKeyDialog > | ui |
| | Generated form (importkeydialog.ui); owned.
|
| QString | m_importedKeyId |
| | Key id or fingerprint of the last successful import; empty until then. Read back through importedKeyId().
|
| QString | m_gpgExe |
| | Path of the gpg binary to run; empty means plain gpg on PATH.
|
Dialog for importing GPG keys from file or clipboard.
Allows users to import GPG public keys without leaving QtPass. Offers two import paths: from file or from clipboard text.
Definition at line 27 of file importkeydialog.h.
◆ ImportKeyDialog()
| ImportKeyDialog::ImportKeyDialog |
( |
const QString & | gpgExe, |
|
|
QWidget * | parent = nullptr ) |
|
explicit |
Construct an ImportKeyDialog.
- Parameters
-
| gpgExe | Path to the gpg executable (falls back to "gpg" if empty). |
| parent | Optional parent widget. |
Definition at line 44 of file importkeydialog.cpp.
◆ ~ImportKeyDialog()
| ImportKeyDialog::~ImportKeyDialog |
( |
| ) |
|
|
overridedefault |
Destroys the dialog and its generated UI.
◆ importedKeyId()
| auto ImportKeyDialog::importedKeyId |
( |
| ) |
const -> QString |
Get the imported key id on success.
- Returns
- The imported key id (or fingerprint when GnuPG status output provides one), or empty if import failed.
Definition at line 52 of file importkeydialog.cpp.
◆ importFromString()
| bool ImportKeyDialog::importFromString |
( |
const QString & | input | ) |
-> bool |
|
private |
Feeds input to gpg --status-fd 1 --import --batch --yes via Executor::executeBlocking() and records the imported key id.
- Parameters
-
| input | Armored key text, trimmed. |
- Returns
- true when gpg exited with 0 and a key id could be parsed from its output; false after showError() otherwise.
Definition at line 138 of file importkeydialog.cpp.
◆ on_fileButton_clicked
| void ImportKeyDialog::on_fileButton_clicked |
( |
| ) |
|
|
privateslot |
"From file" button: picks a file, reads it as a regular file of at most 16 MiB, requires the -----BEGIN PGP armor header and loads the text into the input field. Binary keyrings are refused with a hint to gpg --armor --export first.
Definition at line 56 of file importkeydialog.cpp.
◆ on_importButton_clicked
| void ImportKeyDialog::on_importButton_clicked |
( |
| ) |
|
|
privateslot |
◆ on_inputTextEdit_textChanged
| void ImportKeyDialog::on_inputTextEdit_textChanged |
( |
| ) |
|
|
privateslot |
Enables the Import button only while the input field holds non-blank text.
Definition at line 133 of file importkeydialog.cpp.
◆ on_pasteButton_clicked
| void ImportKeyDialog::on_pasteButton_clicked |
( |
| ) |
|
|
privateslot |
"From clipboard" button: replaces the input field with the clipboard text, unless the clipboard is empty.
Definition at line 111 of file importkeydialog.cpp.
◆ parseGpgImportOutput()
| auto ImportKeyDialog::parseGpgImportOutput |
( |
const QString & | output | ) |
-> QString |
|
static |
Parse GPG import output to extract a key id or fingerprint.
Prefers locale-independent status lines ([GNUPG:] IMPORT_OK and [GNUPG:] IMPORTED) when present, then falls back to the human-readable "gpg: key ...: imported" line (English locale only).
- Parameters
-
| output | Combined stdout/stderr from gpg --import --status-fd 1. |
- Returns
- The imported key id or fingerprint, or empty if not found.
Definition at line 167 of file importkeydialog.cpp.
◆ showError()
| void ImportKeyDialog::showError |
( |
const QString & | message | ) |
|
|
private |
Shows message in a plain-text warning box (gpg's stderr quotes user IDs, which must not be read as markup).
- Parameters
-
Definition at line 197 of file importkeydialog.cpp.
◆ showSuccess()
| void ImportKeyDialog::showSuccess |
( |
const QString & | keyId | ) |
|
|
private |
Shows the "imported, now verify the fingerprint" information box.
- Parameters
-
| keyId | The imported key id or fingerprint. |
Definition at line 203 of file importkeydialog.cpp.
◆ m_gpgExe
| QString ImportKeyDialog::m_gpgExe |
|
private |
Path of the gpg binary to run; empty means plain gpg on PATH.
Definition at line 93 of file importkeydialog.h.
◆ m_importedKeyId
| QString ImportKeyDialog::m_importedKeyId |
|
private |
◆ ui
| QScopedPointer<Ui::ImportKeyDialog> ImportKeyDialog::ui |
|
private |
The documentation for this class was generated from the following files: