|
QtPass 2.0.0
Developer documentation
|
Dialog for selecting GPG recipients for password encryption. More...
#include <usersdialog.h>
Public Types | |
| enum class | Preselect { FromList , Nothing } |
| Whether the recipients on disk are ticked when it opens. More... | |
Public Slots | |
| void | accept () override |
| Handle dialog acceptance. | |
Public Member Functions | |
| UsersDialog (Pass *pass, const AppSettings &s, QString dir, QWidget *parent=nullptr) | |
| Construct users dialog. | |
| UsersDialog (Pass *pass, const AppSettings &s, QString dir, Preselect preselect, QWidget *parent=nullptr) | |
| Construct users dialog, saying what to preselect. | |
| ~UsersDialog () override | |
| Destroys the dialog and its generated form. | |
| void | setInitOnAccept (bool initOnAccept) |
| Choose whether OK runs Pass::Init on the folder. | |
| auto | selectedUsers () const -> QList< UserInfo > |
| The key list with the user's choice in each entry's enabled flag. | |
| auto | hasSelection () const -> bool |
| Whether at least one key is ticked. | |
Protected Member Functions | |
| void | keyPressEvent (QKeyEvent *event) override |
| Handle key press. | |
Private Slots | |
| void | itemChange (QListWidgetItem *item) |
| Handle user selection change. | |
| void | on_lineEdit_textChanged (const QString &filter) |
| Filter user list. | |
| void | on_checkBox_clicked () |
| Handle select all checkbox. | |
| void | on_importKeyButton_clicked () |
| Import a GPG key and refresh the list. | |
| void | selectImportedKey (const QString &importedKey) |
| Make the key gpg just imported the current row. gpg reports a 16-character long ID (IMPORTED) or a 40-character fingerprint (IMPORT_OK), so the two are compared both ways, by suffix. | |
Private Member Functions | |
| void | updateOkButton () |
| Enable OK only while at least one key is ticked (hasSelection()). | |
| void | restoreDialogState () |
| void | connectSignals () |
| Connect dialog signals. | |
| auto | loadGpgKeys () -> bool |
| Load GPG keys and determine secret key status. | |
| void | markSecretKeys (QList< UserInfo > &users) |
| Mark which keys have secret counterparts. | |
| void | loadRecipients () |
| Load recipients and handle missing keys. | |
| auto | listChangedSinceRead () const -> bool |
| Whether the folder's recipient list reads differently now from when loadRecipients() read it: a pull, a sync or another program changed it while the dialog was open. | |
| void | showRecipientWarning (const QString &text, const QString &name=QStringLiteral("recipientWarning")) |
Show text above the key list in bold red, for a recipient list that could not be verified. | |
| void | showNestedLists () |
| Name the folders below this one that have a recipient list of their own: saving here does not change theirs, so someone removed here can still read what is in them. Folders below that cannot be read are named too, since whether they have one is unknown. | |
| void | selectRecipients (const QStringList &listed) |
| Tick the keys the folder is encrypted to, and list recipients no key in the keyring answers to, so saving does not drop them silently. A line that names a key by a subkey or a secondary user ID ticks that key, so unticking it removes the line too. | |
| void | keepAsWritten (const QString &line, const QString &why) |
List line as a ticked row of its own, named by why, so OK writes it back as it was. | |
| auto | tickReached (const QStringList &ids, const QStringList &lines) -> bool |
Tick the rows of the keys ids, which a probe of lines reached. A key on more than one row (a shared subkey) is ticked only by a line naming its own primary key; other lines are kept as written. | |
| auto | setAsideHeldTwice (QStringList *recipients) -> bool |
Keep as written, and warn about, the lines a key ID or fingerprint names that two key blocks hold, or every line when the keyring cannot be listed; those lines leave recipients. | |
| auto | probeEachLine (QStringList *recipients) -> bool |
| After gpg refused the list as a whole, probe each line on its own (address and name lines first, at most ten), tick what each reaches, and keep the lines gpg cannot encrypt to as written. | |
| void | searchKeyring (const QStringList &recipients) |
Tick the keys a keyring search resolves recipients to, and list the lines no key answers to, or that were not looked up, as rows of their own. | |
| void | populateList (const QString &filter=QString()) |
| Populate user list. | |
| bool | passesFilter (const UserInfo &user, const QString &filter, const QRegularExpression &nameFilter) const |
| Check if user passes filter. | |
| auto | isUserExpired (const UserInfo &user) const -> bool |
| Check if GPG key is expired. | |
| QString | buildUserText (const UserInfo &user) const |
| Build display text for user: the user ID and key ID on a line each, each cut to 256 characters (the row only shows them). | |
| void | applyUserStyling (QListWidgetItem *item, const UserInfo &user) const |
| Apply visual styling to user item. | |
Private Attributes | |
| QScopedPointer< Ui::UsersDialog > | ui |
| The widgets from usersdialog.ui. | |
| Pass * | m_pass |
| QString | m_passStore |
| QString | m_gpgExe |
| QList< UserInfo > | m_userList |
| bool | m_initOnAccept {true} |
| QString | m_dir |
| Preselect | m_preselect = Preselect::FromList |
| bool | m_listRead = false |
| int | m_readState = 0 |
| QStringList | m_readRecipients |
| The recipients the list named when the dialog read it. | |
| QString | m_lastFilter |
| QSet< QString > | m_notLookedUp |
| .gpg-id lines selectRecipients() listed unticked without asking gpg. They are shown without "Show unusable keys", so OK does not drop them unseen. | |
| QString | m_cachedPatternString |
| QRegularExpression | m_cachedNameFilter |
| QDateTime | m_cachedCurrentDateTime |
| bool | m_cachedDateTimeValid |
Dialog for selecting GPG recipients for password encryption.
UsersDialog allows users to select which GPG keys to encrypt passwords to. It displays available keys, supports filtering, and shows key expiration status.
Definition at line 36 of file usersdialog.h.
|
strong |
Whether the recipients on disk are ticked when it opens.
| Enumerator | |
|---|---|
| FromList | The folder's recipient list, as the backend reads it. |
| Nothing | None: for a store that had no list when it was chosen. |
Definition at line 41 of file usersdialog.h.
|
explicit |
Construct users dialog.
| pass | Active Pass backend. |
| s | Application settings snapshot. |
| dir | Password store directory path. |
| parent | Parent widget. |
Definition at line 40 of file usersdialog.cpp.
| UsersDialog::UsersDialog | ( | Pass * | pass, |
| const AppSettings & | s, | ||
| QString | dir, | ||
| Preselect | preselect, | ||
| QWidget * | parent = nullptr ) |
Construct users dialog, saying what to preselect.
| pass | Active Pass backend. |
| s | Application settings snapshot. |
| dir | Password store directory path. |
| preselect | What is ticked when it opens. |
| parent | Parent widget. |
Definition at line 44 of file usersdialog.cpp.
|
overrideslot |
Handle dialog acceptance.
Definition at line 594 of file usersdialog.cpp.
|
private |
Apply visual styling to user item.
| item | List item. |
| user | User info. |
Definition at line 799 of file usersdialog.cpp.
|
private |
Build display text for user: the user ID and key ID on a line each, each cut to 256 characters (the row only shows them).
| user | User info. |
Definition at line 781 of file usersdialog.cpp.
|
private |
Connect dialog signals.
Definition at line 65 of file usersdialog.cpp.
|
nodiscard |
Whether at least one key is ticked.
Definition at line 642 of file usersdialog.cpp.
|
private |
Check if GPG key is expired.
| user | User to check. |
Definition at line 746 of file usersdialog.cpp.
|
privateslot |
Handle user selection change.
| item | Changed list item. |
Definition at line 663 of file usersdialog.cpp.
|
private |
List line as a ticked row of its own, named by why, so OK writes it back as it was.
| line | The .gpg-id line. |
| why | Why it is kept as written, shown after " ?? ". |
Definition at line 362 of file usersdialog.cpp.
|
overrideprotected |
|
nodiscardprivate |
Whether the folder's recipient list reads differently now from when loadRecipients() read it: a pull, a sync or another program changed it while the dialog was open.
Definition at line 587 of file usersdialog.cpp.
|
private |
Load GPG keys and determine secret key status.
Definition at line 81 of file usersdialog.cpp.
|
private |
Load recipients and handle missing keys.
Definition at line 560 of file usersdialog.cpp.
|
private |
Mark which keys have secret counterparts.
| users | List of users to mark. |
Definition at line 96 of file usersdialog.cpp.
|
privateslot |
Handle select all checkbox.
Definition at line 839 of file usersdialog.cpp.
|
privateslot |
Import a GPG key and refresh the list.
Definition at line 856 of file usersdialog.cpp.
|
privateslot |
Filter user list.
| filter | Filter text. |
Definition at line 835 of file usersdialog.cpp.
|
private |
Check if user passes filter.
| user | User to check. |
| filter | Text filter. |
| nameFilter | Regex filter. |
Definition at line 730 of file usersdialog.cpp.
|
private |
Populate user list.
| filter | Optional filter text. |
Definition at line 684 of file usersdialog.cpp.
|
private |
After gpg refused the list as a whole, probe each line on its own (address and name lines first, at most ten), tick what each reaches, and keep the lines gpg cannot encrypt to as written.
| recipients | The lines still to settle; left holding the ones a probe could not settle. |
Definition at line 451 of file usersdialog.cpp.
|
private |
Attach WindowStateStore, which restores the dialog's saved geometry now and saves it under "usersDialog" when the dialog closes.
Definition at line 77 of file usersdialog.cpp.
|
private |
Tick the keys a keyring search resolves recipients to, and list the lines no key answers to, or that were not looked up, as rows of their own.
| recipients | The lines a probe could not settle. |
Definition at line 484 of file usersdialog.cpp.
|
inlinenodiscard |
The key list with the user's choice in each entry's enabled flag.
Definition at line 84 of file usersdialog.h.
|
privateslot |
Make the key gpg just imported the current row. gpg reports a 16-character long ID (IMPORTED) or a 40-character fingerprint (IMPORT_OK), so the two are compared both ways, by suffix.
| importedKey | What gpg reported. |
Definition at line 841 of file usersdialog.cpp.
|
private |
Tick the keys the folder is encrypted to, and list recipients no key in the keyring answers to, so saving does not drop them silently. A line that names a key by a subkey or a secondary user ID ticks that key, so unticking it removes the line too.
| listed | The folder's recipients, as listed in its .gpg-id. |
Definition at line 330 of file usersdialog.cpp.
|
private |
Keep as written, and warn about, the lines a key ID or fingerprint names that two key blocks hold, or every line when the keyring cannot be listed; those lines leave recipients.
| recipients | The lines still to settle; updated. |
Definition at line 427 of file usersdialog.cpp.
|
inline |
Choose whether OK runs Pass::Init on the folder.
On by default. Off, the dialog only collects the selection; the caller reads selectedUsers() and initialises the folder itself (new profiles, which must not go through the backend of the active store).
| initOnAccept | false to skip Pass::Init. |
Definition at line 78 of file usersdialog.h.
|
private |
Name the folders below this one that have a recipient list of their own: saving here does not change theirs, so someone removed here can still read what is in them. Folders below that cannot be read are named too, since whether they have one is unknown.
Definition at line 143 of file usersdialog.cpp.
|
private |
Show text above the key list in bold red, for a recipient list that could not be verified.
| text | The warning, plain text. |
| name | The banner's object name. |
Definition at line 109 of file usersdialog.cpp.
|
private |
Tick the rows of the keys ids, which a probe of lines reached. A key on more than one row (a shared subkey) is ticked only by a line naming its own primary key; other lines are kept as written.
| ids | The key IDs the probe reached. |
| lines | The lines that were probed. |
ids has no row. Definition at line 379 of file usersdialog.cpp.
|
private |
Enable OK only while at least one key is ticked (hasSelection()).
Definition at line 647 of file usersdialog.cpp.
|
mutableprivate |
Cached current date/time for expiry checks
Definition at line 164 of file usersdialog.h.
|
mutableprivate |
Whether cached date/time is valid
Definition at line 166 of file usersdialog.h.
|
private |
Cached regex filter
Definition at line 163 of file usersdialog.h.
|
private |
Cached pattern string
Definition at line 162 of file usersdialog.h.
|
private |
Password store directory
Definition at line 144 of file usersdialog.h.
|
private |
GPG executable path
Definition at line 139 of file usersdialog.h.
|
private |
Whether accept() runs Pass::Init.
Definition at line 141 of file usersdialog.h.
|
private |
Last filter text for caching
Definition at line 155 of file usersdialog.h.
|
private |
Whether loadRecipients() read the folder's list, so accept() has something to compare the list on disk with.
Definition at line 148 of file usersdialog.h.
|
private |
.gpg-id lines selectRecipients() listed unticked without asking gpg. They are shown without "Show unusable keys", so OK does not drop them unseen.
Definition at line 161 of file usersdialog.h.
|
private |
Active Pass backend
Definition at line 137 of file usersdialog.h.
|
private |
Password store root path
Definition at line 138 of file usersdialog.h.
|
private |
What opens ticked
Definition at line 145 of file usersdialog.h.
|
private |
The recipients the list named when the dialog read it.
Definition at line 154 of file usersdialog.h.
|
private |
How the list stood up when the dialog read it: a Pass::RecipientsForEditing::State, kept as its value since Pass is only declared here.
Definition at line 152 of file usersdialog.h.
|
private |
List of available GPG users
Definition at line 140 of file usersdialog.h.
|
private |
The widgets from usersdialog.ui.
Definition at line 136 of file usersdialog.h.