|
QtPass 2.0.0
Developer documentation
|
Renders decrypted password-file fields into MainWindow's grid. More...
#include <passworddisplaypanel.h>
Signals | |
| void | copyRequested (const QString &text) |
| Emitted when a field's copy button is clicked. | |
| void | textCopied (const QString &text) |
| Text was selected and copied out of a field's value (Ctrl+C, the context menu, a drag, or the X11 primary selection); it is already on the clipboard and only needs tracking for autoclear. | |
| void | qrRequested (const QString &text) |
| Emitted when a field's QR button is clicked. | |
| void | editRequested () |
| Emitted on a double-click anywhere on a field row: the user wants to change what they are looking at. | |
Public Member Functions | |
| PasswordDisplayPanel (QGridLayout *grid, QBoxLayout *container, QWidget *widgetParent, QObject *parent=nullptr) | |
| Construct a panel that renders into the given layouts. | |
| void | clear () |
| Remove all field rows and collapse the container spacing. | |
| void | refreshPalette () |
| Re-derive palette-dependent styling after a runtime theme change. | |
| void | displayFields (const QString &password, const NamedValues &namedValues, const AppSettings &s, const QString &otpConfig={}) |
| Render the password and template fields of a decrypted entry. | |
| auto | currentOtpCode () const -> QString |
| The one-time password currently on display, if there is one. | |
| void | setMarkedSecrets (const QStringList &names) |
| Set the field names a template marks as secret. | |
| auto | isSecret (const QString &field, const AppSettings &s) const -> bool |
| Whether a field is a secret "Hide password" hides: one a template marks (setMarkedSecrets()), or, with "Also hide other
secrets", one whose name holds a secret word. Not the password itself, nor every field under "Hide every field". False with "Hide password" off. | |
Protected Member Functions | |
| auto | eventFilter (QObject *watched, QEvent *event) -> bool override |
| Turn a left double-click on a field row into editRequested(). | |
Private Member Functions | |
| void | addField (int position, const QString &field, const QString &value, const AppSettings &s) |
| Render one name: value row: action buttons, then the value either behind the eye button (see hides()) or in a read-only browser that links http(s) URLs, then the name label. | |
| void | addRow (int position, QLabel *label, QFrame *frame) |
| Put a row's label and value frame into the grid, listening for a double-click on either (and on the frame's children, which swallow mouse events first). | |
| void | addOtpField (int position, const QString &otpConfig, const AppSettings &s) |
| Render the live OTP row: an OtpCodeWidget in a field frame under an "OTP code" label. A configuration Totp::parse() rejects becomes an inert message row with no copy or QR button. The code is never hidden and never offered as a QR code. | |
| auto | createFieldFrame () -> QFrame * |
| New bordered frame with a tight horizontal layout, styled by applyFrameStyle(); shared by addField() and addOtpField() so the rows cannot drift apart. | |
| void | addActionButtons (QLayout *layout, const QString &field, const QString &value, const AppSettings &s) |
| Add the copy, QR and open-in-browser buttons a field gets, per the settings. | |
| void | addHiddenPassword (QLayout *layout, const QString &field, const QString &value, const QString &lineStyle) |
| Add the password, hidden, with a button that shows it. | |
| void | applyFrameStyle (QFrame *frame) const |
| Give a field frame its rounded border in the current QPalette::Mid colour. The colour is baked into the stylesheet, so refreshPalette() re-runs this after a theme change. | |
| auto | hides (const QString &field, const AppSettings &s) const -> bool |
| Whether a field is shown behind the eye button: the password, a field a template marks, every field with "Hide every field", or one whose name holds a secret word with "Also hide other secrets". Only with "Hide password" on. | |
Private Attributes | |
| QStringList | m_markedSecrets |
| Field names the current template marks as secret, compared case-insensitively in isSecret(); set by setMarkedSecrets(). | |
| QGridLayout * | m_grid |
| The grid the rows go into; owned by MainWindow's .ui. | |
| QBoxLayout * | m_container |
| Layout around the grid whose spacing is 0 while empty and 6 once rows are shown; owned by MainWindow's .ui. | |
| QWidget * | m_widgetParent |
| Parent for the buttons the panel creates and source of the palette used by applyFrameStyle(); not owned. | |
Renders decrypted password-file fields into MainWindow's grid.
Extracted from MainWindow, where the field-rendering and grid-clearing logic was spread across addToGridLayout(), clearTemplateWidgets() and passShowHandler()/otpFromFileToClipboard(). It builds the per-field row (optional copy / QR / open-in-browser buttons plus a value widget with password echo handling) and owns the show/hide spacing of the surrounding container.
It does not own the grid or container widgets (those live in MainWindow's .ui); it renders into the ones it is given. Copy and QR actions are surfaced as signals rather than wired to QtPass directly, so the panel has no dependency on the application object and is unit-testable on its own.
Definition at line 43 of file passworddisplaypanel.h.
| PasswordDisplayPanel::PasswordDisplayPanel | ( | QGridLayout * | grid, |
| QBoxLayout * | container, | ||
| QWidget * | widgetParent, | ||
| QObject * | parent = nullptr ) |
Construct a panel that renders into the given layouts.
| grid | Grid layout that receives the field rows. |
| container | Surrounding box layout whose spacing is toggled. |
| widgetParent | Parent widget for the created field widgets. |
| parent | QObject parent. |
Definition at line 36 of file passworddisplaypanel.cpp.
|
private |
Add the copy, QR and open-in-browser buttons a field gets, per the settings.
| layout | The field's frame layout. |
| field | The field's name, trimmed. |
| value | Its value, trimmed. |
| s | Clipboard and qrencode settings. |
Definition at line 219 of file passworddisplaypanel.cpp.
|
private |
Render one name: value row: action buttons, then the value either behind the eye button (see hides()) or in a read-only browser that links http(s) URLs, then the name label.
The password row keeps its value verbatim (only a trailing CR is dropped); every other value is trimmed.
| position | Grid row to fill. |
| field | The field's name; trimmed here. |
| value | The raw value. |
| s | Display settings (clipboard, qrencode, monospace, hiding). |
Definition at line 270 of file passworddisplaypanel.cpp.
|
private |
Add the password, hidden, with a button that shows it.
| layout | The field's frame layout. |
| field | The field's name, trimmed. |
| value | The password. |
| lineStyle | The style for the value widget. |
Definition at line 247 of file passworddisplaypanel.cpp.
|
private |
Render the live OTP row: an OtpCodeWidget in a field frame under an "OTP code" label. A configuration Totp::parse() rejects becomes an inert message row with no copy or QR button. The code is never hidden and never offered as a QR code.
| position | Grid row to fill. |
| otpConfig | Raw OTP configuration from the entry. |
| s | Display settings (clipboard, monospace). |
Definition at line 371 of file passworddisplaypanel.cpp.
|
private |
Put a row's label and value frame into the grid, listening for a double-click on either (and on the frame's children, which swallow mouse events first).
| position | Grid row. |
| label | The name label for column 0. |
| frame | The value frame for column 1. |
Definition at line 316 of file passworddisplaypanel.cpp.
|
private |
Give a field frame its rounded border in the current QPalette::Mid colour. The colour is baked into the stylesheet, so refreshPalette() re-runs this after a theme change.
| frame | The frame to style. |
Definition at line 339 of file passworddisplaypanel.cpp.
| void PasswordDisplayPanel::clear | ( | ) |
Remove all field rows and collapse the container spacing.
Definition at line 43 of file passworddisplaypanel.cpp.
|
signal |
Emitted when a field's copy button is clicked.
| text | Value to copy to the clipboard. |
|
private |
New bordered frame with a tight horizontal layout, styled by applyFrameStyle(); shared by addField() and addOtpField() so the rows cannot drift apart.
Definition at line 357 of file passworddisplaypanel.cpp.
|
nodiscard |
The one-time password currently on display, if there is one.
Lets callers copy the code the user can actually see instead of decrypting the entry a second time to re-derive it.
Definition at line 69 of file passworddisplaypanel.cpp.
| void PasswordDisplayPanel::displayFields | ( | const QString & | password, |
| const NamedValues & | namedValues, | ||
| const AppSettings & | s, | ||
| const QString & | otpConfig = {} ) |
Render the password and template fields of a decrypted entry.
Fields whose name satisfies FileContent::isOtpFieldName() are never rendered verbatim, because their value is a TOTP shared secret. When otpConfig is set, a live OtpCodeWidget row is rendered in that field's place instead (or appended, when the configuration came from the entry body rather than from a field).
| password | Password value (row 0); skipped when empty. |
| namedValues | Template/named fields to render below the password. |
| s | AppSettings snapshot supplying display settings (clipboard, monospace, hide-password, qrencode). |
| otpConfig | Raw OTP configuration from FileContent::getOtpUri(), or an empty string to render no OTP row at all. |
Definition at line 83 of file passworddisplaypanel.cpp.
|
signal |
Emitted on a double-click anywhere on a field row: the user wants to change what they are looking at.
|
overrideprotected |
Turn a left double-click on a field row into editRequested().
| watched | the row's label or value frame |
| event | the event to inspect |
Definition at line 327 of file passworddisplaypanel.cpp.
|
nodiscardprivate |
Whether a field is shown behind the eye button: the password, a field a template marks, every field with "Hide every field", or one whose name holds a secret word with "Also hide other secrets". Only with "Hide password" on.
| field | The field's name, trimmed. |
| s | The display settings. |
Definition at line 198 of file passworddisplaypanel.cpp.
|
nodiscard |
Whether a field is a secret "Hide password" hides: one a template marks (setMarkedSecrets()), or, with "Also hide other secrets", one whose name holds a secret word. Not the password itself, nor every field under "Hide every field". False with "Hide password" off.
| field | The field's name, trimmed. |
| s | The display settings. |
Definition at line 205 of file passworddisplaypanel.cpp.
|
signal |
Emitted when a field's QR button is clicked.
| text | Value to render as a QR code. |
| void PasswordDisplayPanel::refreshPalette | ( | ) |
Re-derive palette-dependent styling after a runtime theme change.
Field frames bake the current QPalette::Mid colour into a stylesheet; call this on QEvent::PaletteChange so an entry that is already on screen picks up the new theme instead of keeping the old border.
Definition at line 347 of file passworddisplaypanel.cpp.
| void PasswordDisplayPanel::setMarkedSecrets | ( | const QStringList & | names | ) |
Set the field names a template marks as secret.
With "Hide password" on, a field with one of these names, whole and in any case, is hidden like the password, whatever "Also hide other secrets" says: the template's writer asked for it. Kept until set again.
| names | The names from TemplateIO::secretFieldsIn() and TemplateIO::readSecretFields(). |
Definition at line 194 of file passworddisplaypanel.cpp.
|
signal |
Text was selected and copied out of a field's value (Ctrl+C, the context menu, a drag, or the X11 primary selection); it is already on the clipboard and only needs tracking for autoclear.
| text | The copied text. |
|
private |
Layout around the grid whose spacing is 0 while empty and 6 once rows are shown; owned by MainWindow's .ui.
Definition at line 248 of file passworddisplaypanel.h.
|
private |
The grid the rows go into; owned by MainWindow's .ui.
Definition at line 243 of file passworddisplaypanel.h.
|
private |
Field names the current template marks as secret, compared case-insensitively in isSecret(); set by setMarkedSecrets().
Definition at line 241 of file passworddisplaypanel.h.
|
private |
Parent for the buttons the panel creates and source of the palette used by applyFrameStyle(); not owned.
Definition at line 253 of file passworddisplaypanel.h.