20#include "ui_passworddialog.h"
28#include <QDialogButtonBox>
40#include <QSignalBlocker>
41#include <QTextDocument>
49constexpr const char *kOtpEditedProperty =
"qtpassOtpEdited";
52constexpr const char *kOriginalLineProperty =
"qtpassOriginalLine";
65 connect(
ui->checkBoxShow, &QCheckBox::toggled,
this,
81 const bool &isNew, QWidget *parent)
86 connect(
ui->checkBoxShow, &QCheckBox::toggled,
this,
96 setWindowTitle(isNew &&
m_file.isEmpty()
98 : this->windowTitle() +
" " +
m_file);
118 ui->statusLabel->setText(tr(
"Decrypting…"));
120 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
134 ui->lineEditPassword->setEchoMode(QLineEdit::Normal);
136 ui->lineEditPassword->setEchoMode(QLineEdit::Password);
141 ui->widget->setEnabled(
false);
142 const int currentIndex =
ui->passwordTemplateSwitch->currentIndex();
143 if (currentIndex < 0 ||
145 ui->widget->setEnabled(
true);
150 static_cast<unsigned int>(
ui->spinBox_pwdLength->value()),
153 if (!newPass.isEmpty()) {
154 ui->lineEditPassword->setText(newPass);
156 ui->widget->setEnabled(
true);
171 if (newValue.right(1) !=
"\n") {
183 !gain.names.isEmpty() && !(gain == shown);
186 const QString who = gain.
names.join(QStringLiteral(
", "));
189 ? tr(
"%1 has not been saved from this device before, and its "
190 "folder takes its recipients from a folder above it. "
191 "Saving encrypts it to: %2.\n\nIf you did not expect "
192 "this folder here, it may have been renamed or moved, and "
193 "its own recipient list removed. Save anyway?")
195 : tr(
"Saving re-encrypts %1 to its folder's recipients, and "
196 "that now includes someone who cannot read it: %2.\n\nIf "
197 "you did not change who may read this folder, its "
198 "recipient list may have been changed or the folder "
199 "moved. Save anyway?")
201 if (QMessageBox::question(
this, tr(
"Give this entry new readers?"), text,
202 QMessageBox::Save | QMessageBox::Cancel,
203 QMessageBox::Cancel) != QMessageBox::Save) {
216 const auto keepRefusal = [&refusal](
const QString &,
const QString &message) {
219 const QMetaObject::Connection refused =
228 if (
m_saving && !refusal.isEmpty()) {
240 ui->nameRow->setEnabled(!saving);
242 ui->templateBox->setEnabled(!saving);
246 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!saving);
247 ui->statusLabel->setText(saving ? tr(
"Saving…") : QString());
255 if (back ==
nullptr || !back->isEnabled() || !back->isVisible()) {
256 back =
ui->lineEditPassword;
258 back->setFocus(Qt::OtherFocusReason);
305 const QMessageBox::StandardButton answer = QMessageBox::question(
306 this, tr(
"Still saving"),
307 tr(
"The entry is still being saved. Close the dialog anyway? If "
308 "saving then fails, what you typed is lost."),
309 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
311 if (answer != QMessageBox::Yes || !
m_saving) {
324 ui->statusLabel->setText(tr(
"Not saved: %1").arg(err.trimmed()));
330 const QStringList &folders,
331 const QString ¤tFolder) {
337 ui->folderBox->setSizeAdjustPolicy(
338 QComboBox::AdjustToMinimumContentsLengthWithIcon);
339 ui->folderBox->setMinimumContentsLength(30);
340 ui->folderBox->clear();
342 for (
const QString &folder : folders) {
343 const QString rel = QDir::cleanPath(folder) == QStringLiteral(
".")
345 : QDir::cleanPath(folder);
346 if (rel == QDir::cleanPath(currentFolder) ||
348 QDir::cleanPath(currentFolder) == QStringLiteral(
"."))) {
349 current =
ui->folderBox->count();
353 constexpr qsizetype kMaxShown = 120;
354 const QString shown = rel.isEmpty() ? QStringLiteral(
"/") : rel + u
'/';
355 if (shown.size() > kMaxShown) {
357 qsizetype head = kMaxShown / 3;
358 if (shown.at(head - 1).isHighSurrogate()) {
361 qsizetype tail = kMaxShown - kMaxShown / 3 - 1;
362 if (shown.at(shown.size() - tail).isLowSurrogate()) {
365 ui->folderBox->addItem(
366 shown.left(head) + QChar(0x2026) + shown.right(tail), rel);
367 ui->folderBox->setItemData(
ui->folderBox->count() - 1,
370 ui->folderBox->addItem(shown, rel);
373 ui->folderBox->setCurrentIndex(current);
376 connect(
ui->nameEdit, &QLineEdit::textChanged,
this,
378 connect(
ui->folderBox, &QComboBox::currentIndexChanged,
this,
381 ui->nameEdit->setFocus();
385 const QString &rel)
const -> QString {
388 const QStringList parts = rel.split(u
'/');
389 if (std::any_of(parts.cbegin(), parts.cend(),
390 [](
const QString &part) { return part.startsWith(u
'.'); })) {
391 return tr(
"A name or folder that starts with a dot would be hidden "
397 return tr(
"%1 lies behind a symbolic link or junction, outside the "
401 if (QFileInfo::exists(absolute + QStringLiteral(
".gpg"))) {
402 return tr(
"An entry called %1 already exists.").arg(rel);
404 if (QFileInfo(absolute).isDir()) {
405 return tr(
"%1 is a folder.").arg(rel);
411 QString name = QDir::fromNativeSeparators(
ui->nameEdit->text().trimmed());
414 if (name.endsWith(QStringLiteral(
".gpg"), Qt::CaseInsensitive)) {
417 if (name.isEmpty()) {
418 *problem = tr(
"Give the entry a name.");
421 if (name.endsWith(u
'/')) {
422 *problem = tr(
"A name cannot end in /.");
425 const QString folder =
ui->folderBox->currentData().toString();
431 const bool fullPath =
432 QDir::isAbsolutePath(name) && !name.startsWith(QLatin1Char(
':'));
433 const QString typed = QDir::cleanPath(
434 (folder.isEmpty() || fullPath) ? name : folder + u
'/' + name);
436 if (typed.isEmpty() || typed == QStringLiteral(
".") ||
438 *problem = tr(
"That name would resolve outside the password store.");
445 QDir(QDir::cleanPath(
m_storeRoot)).relativeFilePath(absolute);
446 if (rel.isEmpty() || rel == QStringLiteral(
".")) {
447 *problem = tr(
"That name would resolve outside the password store.");
451 return problem->isEmpty() ? rel : QString();
460 const QString whole =
ui->folderBox->currentData(Qt::ToolTipRole).toString();
461 ui->folderBox->setToolTip(
462 whole.isEmpty() ? tr(
"The folder of the password store the new entry "
465 if (problem.isEmpty() && !whole.isEmpty()) {
466 problem = tr(
"The folder's path is shortened above; hold the pointer "
467 "over it to read it whole before you save.");
469 ui->statusLabel->setText(problem);
470 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!rel.isEmpty());
481 ui->statusLabel->setText(problem);
487 ui->statusLabel->setText(
488 tr(
"Could not create the folder %1.").arg(parent));
492 setWindowTitle(tr(
"Password") + QStringLiteral(
" ") +
m_file);
507 ui->lineEditPassword->setStoredText(fileContent.
getPassword());
509 .left(password.indexOf(QLatin1Char(
'\n')))
511 ? QStringLiteral(
"\r")
514 QWidget *previous =
ui->checkBoxShow;
518 if (
auto *secret = qobject_cast<SecretLineEdit *>(line)) {
519 secret->setStoredText(nv.
value);
521 line->setText(nv.
value);
523 line->setProperty(kOriginalLineProperty, nv.
originalLine);
526 line->setProperty(kOtpEditedProperty, QVariant());
531 ui->formLayout->removeRow(line);
534 for (
const NamedValue &nv : std::as_const(namedValues)) {
542 ui->plainTextEdit->setWordWrapMode(
544 ? QTextOption::WrapAnywhere
545 : QTextOption::WrapAtWordBoundaryOrAnywhere);
556 for (QLineEdit *other : std::as_const(allLines)) {
557 if (other != line && other->objectName() == to) {
558 ui->statusLabel->setText(
563 ui->statusLabel->clear();
564 line->setObjectName(to);
575 const QFormLayout::TakeRowResult row =
ui->formLayout->takeRow(line);
579 disconnect(line,
nullptr,
this,
nullptr);
583 for (QLayoutItem *item : {row.labelItem, row.fieldItem}) {
584 if (item ==
nullptr) {
587 if (QWidget *widget = item->widget()) {
589 widget->deleteLater();
599 QLineEdit *firstMatch =
nullptr;
600 for (QLineEdit *line : std::as_const(allLines)) {
607 if (!line->text().trimmed().isEmpty()) {
610 if (firstMatch ==
nullptr) {
622 if (
auto *owner = qobject_cast<QWidget *>(
m_otpWarning->parent())) {
634 disconnect(
m_otpLine, &QLineEdit::textChanged,
this,
636 disconnect(
m_otpLine, &QLineEdit::textEdited,
this,
638 disconnect(
m_otpLine, &QLineEdit::editingFinished,
this,
642 if (otp ==
nullptr) {
645 otp->setPlaceholderText(tr(
"otpauth:// URI or base32 secret"));
647 Qt::UniqueConnection);
650 connect(otp, &QLineEdit::textEdited,
this,
654 connect(otp, &QLineEdit::editingFinished,
this,
660 if (QObject *line = sender()) {
661 line->setProperty(kOtpEditedProperty,
true);
669 if (otp ==
nullptr) {
673 const QString text = otp->text().trimmed();
675 const bool bad = !text.isEmpty() && !
Totp::parse(text, &why).has_value();
680 otp->addAction(QIcon::fromTheme(QStringLiteral(
"dialog-warning")),
681 QLineEdit::TrailingPosition);
686 otp->setToolTip(reason.isEmpty() ? tr(
"Invalid OTP secret") : reason);
693 otp->setToolTip(QString());
704 if (otp ==
nullptr) {
707 const QString text = otp->text().trimmed();
708 if (text.isEmpty()) {
715 if (!otp->property(kOtpEditedProperty).toBool()) {
722 if (!canonical.isEmpty()) {
723 otp->setText(canonical);
731 for (QLineEdit *line : std::as_const(allLines)) {
732 const QString text = line->text();
733 const QString name = line->objectName();
734 const QString original = line->property(kOriginalLineProperty).toString();
740 if (!original.isEmpty()) {
741 const qsizetype colon = original.indexOf(QLatin1Char(
':'));
742 if (colon >= 0 && original.left(colon).trimmed() == name &&
743 original.right(original.length() - colon - 1).trimmed() == text) {
744 passFile += original +
"\n";
748 if (text.isEmpty()) {
751 passFile += name +
": " + text +
"\n";
758 QString notes =
ui->plainTextEdit->document()->toRawText();
759 notes.replace(QChar(QChar::ParagraphSeparator), QLatin1Char(
'\n'));
760 notes.replace(QChar(QChar::LineSeparator), QLatin1Char(
'\n'));
775 QSet<QString> otpTyped;
776 const auto holdAndRemove = [
this, &held,
777 &otpTyped](QList<QLineEdit *> &lines) {
778 for (QLineEdit *line : std::as_const(lines)) {
779 const QString original = line->property(kOriginalLineProperty).toString();
782 if (!line->text().isEmpty() || !original.isEmpty()) {
783 held.append({line->objectName(), line->text(), original});
784 if (line->property(kOtpEditedProperty).toBool()) {
785 otpTyped.insert(line->objectName());
788 ui->formLayout->removeRow(line);
795 QWidget *previous =
ui->checkBoxShow;
797 for (
const QString &field : std::as_const(
m_fields)) {
798 if (field.isEmpty()) {
806 auto *label =
new QLabel();
807 label->setTextFormat(Qt::PlainText);
809 line->setObjectName(field);
811 if (!kept.
name.isEmpty()) {
812 line->setStoredText(kept.
value);
813 line->setProperty(kOriginalLineProperty, kept.
originalLine);
814 if (otpTyped.contains(field)) {
815 line->setProperty(kOtpEditedProperty,
true);
818 ui->formLayout->addRow(label, line);
819 setTabOrder(previous, line);
824 for (
const NamedValue &field : std::as_const(held)) {
828 if (otpTyped.contains(field.name)) {
829 line->setProperty(kOtpEditedProperty,
true);
845 line->setObjectName(field.name);
846 line->setStoredText(field.value);
847 line->setProperty(kOriginalLineProperty, field.originalLine);
849 label->setBuddy(line);
850 ui->formLayout->addRow(label, line);
851 setTabOrder(previous, line);
856 [
this, line, label](
const QString &,
const QString &to) {
863 auto *remove = line->addAction(
864 QIcon::fromTheme(QStringLiteral(
"edit-delete"),
865 QIcon(QStringLiteral(
":/icons/edit-delete.svg"))),
866 QLineEdit::TrailingPosition);
867 remove->setObjectName(QStringLiteral(
"removeFieldAction"));
868 remove->setToolTip(tr(
"Remove field"));
869 connect(remove, &QAction::triggered,
this,
879 ui->spinBox_pwdLength->setValue(length);
883 ui->passwordTemplateSwitch->setCurrentIndex(templateIndex);
888 ui->passwordTemplateSwitch->setDisabled(
usePwgen);
889 ui->label_characterset->setDisabled(
usePwgen);
894 ui->label_template->hide();
895 ui->templateBox->hide();
897 ui->templateBox->setSizeAdjustPolicy(
898 QComboBox::AdjustToMinimumContentsLengthWithIcon);
899 ui->templateBox->setMinimumContentsLength(20);
900 connect(
ui->templateBox, &QComboBox::currentIndexChanged,
this, [
this] {
903 const QString name = ui->templateBox->currentData().toString();
904 if (name != m_currentTemplateName) {
911 const QHash<QString, QStringList> &templates,
912 const QString &defaultTemplate) {
914 QStringList templateNames = templates.keys();
915 if (templateNames.isEmpty()) {
918 std::sort(templateNames.begin(), templateNames.end());
920 const QSignalBlocker blocker(
ui->templateBox);
921 ui->templateBox->clear();
922 for (
const QString &name : std::as_const(templateNames)) {
924 ui->templateBox->setItemData(
ui->templateBox->count() - 1,
928 ui->label_template->show();
929 ui->templateBox->show();
934 QString selected = defaultTemplate;
935 if (!templateNames.contains(selected)) {
936 selected = templateNames.first();
948 const QSignalBlocker blocker(
ui->templateBox);
949 ui->templateBox->setCurrentIndex(
ui->templateBox->findData(templateName));
950 QString fields = it.value().join(
"\n");
960 std::sort(names.begin(), names.end());
964 if (currentIdx < 0) {
967 nextIdx = (currentIdx + 1) % names.size();
981 if (!file.isEmpty() && file !=
m_file) {
987 const auto refuse = [
this](
const QString &why) {
990 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
991 ui->statusLabel->setText(why);
1000 refuse(tr(
"This entry contains bytes QtPass cannot save unchanged, so it "
1001 "cannot be edited here."));
1013 if (
const qsizetype lines =
1014 std::count_if(output.cbegin(), output.cend(),
1016 return c == QLatin1Char(
'\n') ||
1017 Util::isOtherBlockBreak(c);
1019 output.count(QStringLiteral(
"\r\n")) +
1020 (output.isEmpty() || output.endsWith(QLatin1Char(
'\n')) ? 0 : 1);
1024 const int n =
static_cast<int>(
1025 std::min<qsizetype>(lines, std::numeric_limits<int>::max()));
1026 refuse(tr(
"This entry has %n line(s), too many to edit here.",
nullptr, n));
1033 qsizetype longest = 0;
1034 for (QStringView line : QStringView(output).tokenize(u
'\n')) {
1035 if (line.endsWith(u
'\r')) {
1038 longest = std::max(longest, line.size());
1041 const int n =
static_cast<int>(
1042 std::min<qsizetype>(longest, std::numeric_limits<int>::max()));
1043 refuse(tr(
"This entry has a line of %n character(s), too long to edit "
1058 ui->statusLabel->clear();
1060 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
true);
1070 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
1072 ui->statusLabel->setText(err);
1076 ui->lineEditPassword->setEnabled(enabled);
1077 ui->createPasswordButton->setEnabled(enabled);
1078 ui->checkBoxShow->setEnabled(enabled);
1079 ui->passwordTemplateSwitch->setEnabled(enabled);
1080 ui->label_characterset->setEnabled(enabled);
1081 ui->spinBox_pwdLength->setEnabled(enabled);
1082 ui->plainTextEdit->setEnabled(enabled);
1084 line->setEnabled(enabled);
1087 line->setEnabled(enabled);
The name of a key: value field in PasswordDialog, editable in place: double-click or the context menu...
FieldLabel(const QString &name, QWidget *parent=nullptr)
Label for the field called name.
void copied(const QString &text)
Text was copied out of the name editor, marked as a secret.
void setName(const QString &name)
Name the field name and show it.
void removeRequested()
The user chose "Remove field".
void renamed(const QString &from, const QString &to)
The user typed a different name and confirmed it.
Represents the parsed contents of a password file.
static auto isOtpFieldName(const QString &name) -> bool
Whether a field name designates the one-time password field.
static constexpr int kMaxDisplayLines
Most lines of remaining text getRemainingDataForDisplay() gives.
auto getRemainingData() const -> QString
auto getNamedValues() const -> NamedValues
static auto parse(const QString &fileContent, const QStringList &templateFields, bool allFields, const std::function< bool(const QString &)> &alsoField={}) -> FileContent
parse parses the given fileContent in a FileContent object. The password is accessible through getPas...
auto getPassword() const -> QString
The password: the first line, without the "\r" of a CRLF line end (passwordLine()).
The NamedValues class is mostly a list of NamedValue but also has a method to take a specific NamedVa...
auto takeNamedValue(const QString &name) -> NamedValue
Remove and return the named field, its original line included.
Abstract base class for password store operations.
void finishedInsert(const QString &out, const QString &err)
An Insert() succeeded: the entry is in the store and, with Git in use, committed.
virtual auto generatePassword(unsigned int length, const QString &charset) -> QString
Generate random password.
void insertFailed(const QString &err, bool written)
Emitted when an Insert() fails through a queued command, before the generic processErrorExit(): the p...
virtual void Show(QString file)=0
Show decrypted password file.
void finishedShow(const QString &out, const QString &file, bool lossless=true)
Emitted when a Show() succeeds.
virtual void Insert(QString file, QString value, bool force)=0
Insert or update password.
void processErrorExit(int exitCode, const QString &err)
An operation ended in failure: its process exited non-zero, could not be started or crashed,...
auto insertsPending() const -> int
How many inserts have started queueing but not yet reported.
void critical(const QString &title, const QString &message)
Something went wrong that the user has to be told about in a dialog, such as a refused path or a fail...
virtual auto readersAnEditWouldAdd(const QString &file) -> EditReaders
Who saving over an existing entry would let read it who may not now.
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 ...
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.
auto addFieldRow(const NamedValue &field, QWidget *previous) -> SecretLineEdit *
Adds a row for a field outside the template: a FieldLabel that can be renamed or removed,...
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.
QPointer< QWidget > m_focusBeforeSave
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 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 setPass(const QString &output, const QString &file=QString(), bool lossless=true)
Populate the dialog from a decrypted entry (Pass::finishedShow).
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.
~PasswordDialog() override
Hides the window before QDialog tears it down, so the focus-out emitted on hiding cannot reach slots ...
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.
QString m_passwordLineEnd
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...
auto whyNotSavedAs(const QString &absolute, const QString &rel) const -> QString
Why a name inside the store cannot be saved as a new entry: it would be hidden, lies behind a link,...
QString m_currentTemplateName
Name of the template currently applied; cycleTemplate() steps from it.
QPointer< QAction > m_otpWarning
static auto isPathInStore(const QString &storeRoot, const QString &candidate) -> bool
Check that a candidate path resolves inside the password store root, after following symlinks and res...
Singleton that stores QtPass settings, handles persistence and defaults.
A QLineEdit for a password that can be shown: whatever is copied out of it is marked as a secret and ...
void copied(const QString &text)
Selected text was copied out of the line edit.
SecretLineEdit(QWidget *parent=nullptr)
Constructs the line edit.
static constexpr int kMaxLength
Most characters the line edit holds (1 MiB of them): its maxLength in place of QLineEdit's 32767.
void copied(const QString &text)
Selected text was copied or cut out of the editor.
static auto fieldsIn(const QString &templateText) -> QStringList
The field names of the template in the settings: one per line, with comment lines (starting with #,...
static auto parse(const QString &config, Refusal *why=nullptr) -> std::optional< Settings >
Parse an OTP configuration string.
static auto normalize(const QString &config, const QString &label={}, const QString &issuer={}) -> QString
Normalise a user-entered value to a canonical otpauth URI.
static auto describe(Refusal why) -> QString
One sentence for the user on why a configuration gives no code.
Refusal
Why parse() gave no settings, so the user can be told more than "invalid".
@ None
Parsed: there was nothing to refuse.
static auto hasLongUnbrokenRun(QStringView text) -> bool
Whether text holds more than kMaxUnbrokenRun characters in a row without white space Qt wraps at (a n...
static auto isUnderLink(const QString &path, const QString &storeRoot, bool includeSelf=true) -> bool
Whether the way from storeRoot down to path passes through a symbolic link or NTFS junction: path its...
static auto mkpathForStore(const QString &path) -> bool
Create path and any missing parents as pass would.
static auto joinPath(const QString &dir, const QString &name) -> QString
name in dir, as the file system means it.
static auto plainToolTip(const QString &text) -> QString
text as a tooltip that shows it as written.
static auto shownName(const QString &name, qsizetype max=kMaxShownName) -> QString
A name or path from the store, as a label or list shows it: one line, at most max characters.
FieldLabel: the in-place renamable, removable name label of a key: value field in PasswordDialog.
Parser for a decrypted password entry: password line, key: value fields, remaining text and the OTP c...
Pass, the abstract password-store backend that RealPass and ImitatePass implement,...
Value object for the password generator: chosen character set, its alphabets and the length.
Dialog for creating or editing one password entry, including the generator, template fields,...
PathValidator: is a path inside the password store, and how is it spelled relative to the store root.
The "qtpass" logging category.
QtPassSettings, the QSettings singleton behind every saved setting, the profiles and the Pass backend...
QLineEdit whose copies, cuts and primary-selection fills carry the secret clipboard hints and are rep...
QPlainTextEdit for editing decrypted entry text that marks everything copied out of it as a secret.
Plain value-object holding all flat QtPass configuration.
QString passTemplate
Newline-separated template field names.
bool templateAllFields
Treat every key: line as a field.
bool useTemplate
Use the password template.
PasswordConfiguration passwordConfiguration
Length/charset/custom chars.
A name/value pair parsed from a password file field.
QString name
Field name (the part before the colon in "name: value").
QString originalLine
The field's verbatim source line, colon and spacing intact.
QString value
Field value (the part after the colon in "name: value").
What saving over an existing entry would change about who reads it (readersAnEditWouldAdd()).
QStringList names
Who would read the entry after the save and the question is about, as "name (key ID)"; empty for no q...
Holds the password generator settings: which character set is selected, the alphabet of every set,...
int length
Length of the generated password, in characters.
CharacterSet selected
Currently active character set selection.
CharacterSet
Character set options for password generation; also the index into Characters.
std::array< QString, CHARSETS_COUNT > Characters
The alphabet of each character set, indexed by CharacterSet. Only the CUSTOM entry is meant to be cha...
TemplateIO: the store's .templates and .default_template files and the # secret: marker in template t...
RFC 6238 TOTP: otpauth URI parsing, code generation and canonical re-serialisation.
Util: static helpers for the process environment, binary discovery, store paths, URL safety and the l...