8#ifndef SRC_PASSWORDDIALOG_H_
9#define SRC_PASSWORDDIALOG_H_
15#include <QScopedPointer>
53 QWidget *parent =
nullptr);
63 const bool &isNew, QWidget *parent =
nullptr);
105 const QString ¤tFolder);
133 void setTemplate(
const QString &rawFields,
bool useTemplate);
169 const QString &defaultTemplate);
194 void setPass(
const QString &output,
const QString &file = QString());
241 void onShowError(
int exitCode,
const QString &err);
254 [[nodiscard]]
auto otpLineEdit() const -> QLineEdit *;
AppSettings, the value object holding every flat QtPass setting.
The name of a key: value field in PasswordDialog, editable in place: double-click or the context menu...
Abstract base class for password store operations.
void validateOtpField()
Flag an OTP value that is neither a URI nor valid base32.
QScopedPointer< Ui::PasswordDialog > ui
Generated form (passworddialog.ui); owned.
bool m_templating
Whether template fields get widgets of their own (the "Use template" setting).
void hookOtpField()
Connect validation and normalisation to the OTP field, if present.
QList< QLineEdit * > m_otherLines
QStringList m_fields
Field names of the current template, in template order.
void onInsertFailed(const QString &err, bool written)
The insert started by accept() failed: unlock the fields, which still hold what was typed,...
void setPassword(const QString &password)
Populate the dialog's password field with the given text.
void setSaving(bool saving)
Lock or unlock the dialog while an insert is in flight.
void validateNewEntry()
Re-runs resolveNewEntry() as the user types or picks a folder: shows the problem (if any) in the stat...
Pass * m_pass
Backend for Show, Insert and generatePassword; not owned.
void cycleTemplate()
Cycle to next template (Ctrl+T).
void setAvailableTemplates(const QHash< QString, QStringList > &templates, const QString &defaultTemplate)
Set available templates from file and select default.
void setupTemplateBox()
Hides the template row until setAvailableTemplates() fills it and wires the combo box so that a user ...
auto entryPath() const -> QString
The entry the dialog writes to, relative to the store and without the .gpg suffix (for example work/v...
void normalizeOtpField()
Rewrite the OTP field as a canonical otpauth URI.
bool m_allFields
Whether every key: value line becomes a field (the "Templateall fields" setting), as given to FileCon...
void showNotSaved(const QString &err)
Say why the entry was not saved and let the user try again; the fields keep what was typed.
void accept() override
OK: for a new entry, resolve and check the name first and stay open when it is not usable; then inser...
auto otpLineEdit() const -> QLineEdit *
Locate the field that holds the one-time password configuration.
void save()
Start inserting what the dialog holds and wait for the result.
PasswordDialog(PasswordConfiguration passConfig, QWidget *parent=nullptr)
Construct a PasswordDialog for entering a new password.
bool m_isNew
True when creating an entry, false when editing one; decides whether the name row and the decrypt-bef...
void setLength(int length)
Set the desired password length shown in the dialog.
void reject() override
Cancel, Esc and the window's close button. While an insert is in flight they ask first: closing then ...
void setPasswordVisible(bool show)
Show or mask the password field.
QHash< QString, QStringList > m_availableTemplates
QString m_file
Entry path relative to the store, without .gpg; empty for a new entry until accept() resolves the typ...
bool m_saving
True from accept() starting an insert until the backend reports back.
QShortcut * m_templateShortcut
Ctrl+T, created once templates are available; owned by the dialog.
void setEditorEnabled(bool enabled)
Enabled or grey out every editable field of the dialog.
void onShowError(int exitCode, const QString &err)
Handle a process error while waiting for an entry's decrypt.
void removeField(QLineEdit *line)
Drop a key: value field and its row from the form. The widgets are deleted once control is back in th...
QString m_storeRoot
Absolute store root while a new entry is being named; empty otherwise.
void setPass(const QString &output, const QString &file=QString())
Populate the dialog from a decrypted entry (Pass::finishedShow).
void copied(const QString &text)
Text was copied out of the password, a field or the body, marked as a secret: for ClipboardManager::t...
void setNewEntryLocation(const QString &storeRoot, const QStringList &folders, const QString ¤tFolder)
Let a new entry be named inside the dialog: a folder picker over the store's folders and a name field...
void renameField(QLineEdit *line, FieldLabel *label, const QString &to)
Give a key: value field a new key (#132). Refused, with the reason in the status label,...
auto isOwnInsertReport() -> bool
Whether the insert report now arriving is this dialog's own.
PasswordConfiguration m_passConfig
Generator settings: character sets and default length.
auto resolveNewEntry(QString *problem) const -> QString
The name the user typed, resolved against the picked folder.
void usePwgen(bool usePwgen)
Enable or disable pwgen-style password generation mode.
void setPasswordCharTemplate(int templateIndex)
Set the password character template index.
void setTemplate(const QString &rawFields, bool useTemplate)
Set the template fields and whether templating is enabled.
void templateAll(bool templateAll)
Whether every key: value line becomes a field of its own.
void reportCopies(SecretLineEdit *line)
Forwards the line edit's SecretLineEdit::copied to this dialog's copied(), so every copy out of any f...
auto getPassword() -> QString
Retrieve the current text from the dialog's password field.
void markOtpFieldEdited()
Remember, on the line edit that sent textEdited(), that the user typed in it: only such a field has a...
void on_rejected()
Connected to QDialog::rejected: blanks the password and field widgets so the decrypted secret does no...
void onInsertFinished()
The insert started by accept() succeeded: close as accepted.
QList< QLineEdit * > m_templateLines
QPointer< QLineEdit > m_otpLine
void applyTemplate(const QString &templateName)
Switch to a named template: records it, selects it in the combo box and rebuilds the field rows throu...
void on_createPasswordButton_clicked()
"Generate" button: asks the backend for a password of the chosen length from the selected character s...
QString m_currentTemplateName
Name of the template currently applied; cycleTemplate() steps from it.
QPointer< QAction > m_otpWarning
A QLineEdit for a password that can be shown: whatever is copied out of it is marked as a secret and ...
Plain value-object holding all flat QtPass configuration.
Holds the password generator settings: which character set is selected, the alphabet of every set,...