19#include "ui_configdialog.h"
30#include <QGuiApplication>
33#include <QListWidgetItem>
36#include <QRegularExpression>
38#include <QSystemTrayIcon>
55 ui->spinBoxAutoclearSeconds->updateGeometry();
56 ui->spinBoxAutoclearPanelSeconds->updateGeometry();
59 connect(
ui->checkBoxHidePassword, &QCheckBox::toggled,
this,
60 [
this] { updateSecretFieldsEnabled(); });
61 connect(
ui->checkBoxHideSecretFields, &QCheckBox::toggled,
this,
62 [
this] { updateSecretFieldsEnabled(); });
63 connect(
ui->checkBoxHideAllFields, &QCheckBox::toggled,
this,
64 [
this] { updateSecretFieldsEnabled(); });
65 connect(
ui->buttonDefaultSecretFields, &QPushButton::clicked,
this, [
this] {
66 ui->lineEditSecretFields->setText(
67 AppSettings::defaultSecretFieldNames().join(QStringLiteral(
", ")));
71 connect(
ui->spinBoxAutoclearSeconds, &QSpinBox::valueChanged,
this,
73 ui->labelSeconds->setVisible(value > 0);
74 ui->checkBoxRestoreClipboard->setVisible(value > 0);
76 connect(
ui->spinBoxAutoclearPanelSeconds, &QSpinBox::valueChanged,
this,
77 [
this](
int value) { ui->labelPanelSeconds->setVisible(value > 0); });
79 ui->comboBoxFields, &QComboBox::currentIndexChanged,
this,
80 [
this](
int index) { ui->plainTextEditTemplate->setEnabled(index > 0); });
85 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
86 ui->checkBoxUseTrayIcon->setEnabled(
false);
87 ui->checkBoxUseTrayIcon->setToolTip(tr(
"System tray is not available"));
88 ui->checkBoxHideOnClose->setEnabled(
false);
89 ui->checkBoxStartMinimized->setEnabled(
false);
95 if (QGuiApplication::platformName().startsWith(QLatin1String(
"wayland"))) {
96 ui->checkBoxAlwaysOnTop->setEnabled(
false);
97 ui->checkBoxAlwaysOnTop->setToolTip(
98 tr(
"Not available on Wayland; use your compositor's "
99 "\"keep above\" window rule instead"));
105 ui->checkBoxUseQrencode->hide();
109 ui->checkBoxUseQrencode->setEnabled(
false);
110 ui->checkBoxUseQrencode->setToolTip(tr(
"qrencode needs to be installed"));
113 connect(
ui->profileList, &QListWidget::currentRowChanged,
this,
115 connect(
ui->profileName, &QLineEdit::textEdited,
this,
117 connect(
ui->profilePath, &QLineEdit::textEdited,
this,
119 connect(
ui->profileSigningKey, &QLineEdit::textEdited,
this,
121 for (QCheckBox *box :
122 {
ui->profileUseGit,
ui->profileAutoPush,
ui->profileAutoPull}) {
137 QFormLayout::ItemRole role = QFormLayout::FieldRole;
138 ui->profileFormLayout->getWidgetPosition(
ui->profileSigningKey, &row,
149 connect(
ui->storePath, &QLineEdit::textChanged,
this,
150 [
this] { updatePassGitWarning(); });
151 connect(
ui->pwgenPath, &QLineEdit::textChanged,
this,
153 connect(
ui->gitPath, &QLineEdit::textChanged,
this,
157 ui->label->setText(
ui->label->text() + VERSION);
158 ui->comboBoxClipboard->clear();
160 ui->comboBoxClipboard->addItem(tr(
"No clipboard"));
161 ui->comboBoxClipboard->addItem(tr(
"Always copy to clipboard"));
162 ui->comboBoxClipboard->addItem(tr(
"On-demand copy to clipboard"));
165 ui->comboBoxClipboard->setCurrentIndex(currentIndex);
168 QClipboard *clip = QApplication::clipboard();
169 if (!clip->supportsSelection()) {
171 ui->checkBoxSelection->setVisible(
false);
176 connect(
ui->pageList, &QListWidget::currentRowChanged,
ui->pages,
177 &QStackedWidget::setCurrentIndex);
178 ui->pageList->setCurrentRow(
182 :
ui->pages->indexOf(
ui->pagePrograms));
195 ui->spinBoxAutoclearSeconds->setValue(
197 ui->labelSeconds->setVisible(
ui->spinBoxAutoclearSeconds->value() > 0);
199 ui->checkBoxRestoreClipboard->setVisible(
200 ui->spinBoxAutoclearSeconds->value() > 0);
201 ui->spinBoxAutoclearPanelSeconds->setValue(
203 ui->labelPanelSeconds->setVisible(
ui->spinBoxAutoclearPanelSeconds->value() >
208 ui->lineEditSecretFields->setText(
215 ui->checkBoxAddGPGId->setChecked(settings.
addGPGId);
221 ui->checkBoxLessRandom->setChecked(settings.
lessRandom);
222 ui->checkBoxUseSymbols->setChecked(settings.
useSymbols);
226 ui->comboBoxFields->setCurrentIndex(
229 ui->checkBoxAutoPull->setChecked(settings.
autoPull);
230 ui->checkBoxAutoPush->setChecked(settings.
autoPush);
231 ui->checkBoxGitUseParentRepository->setChecked(
260 settings.
usePass =
ui->radioButtonPass->isChecked();
274 const QStringList names =
275 ui->lineEditSecretFields->text().split(QLatin1Char(
','));
276 for (
const QString &name : names) {
277 if (!name.trimmed().isEmpty()) {
285 settings.
addGPGId =
ui->checkBoxAddGPGId->isChecked();
288 if (
ui->checkBoxUseTrayIcon->isEnabled()) {
299 if (
ui->checkBoxHideOnClose->isEnabled()) {
302 if (
ui->checkBoxStartMinimized->isEnabled()) {
305 settings.
useGit =
ui->checkBoxUseGit->isChecked();
309 settings.
autoPush =
ui->checkBoxAutoPush->isChecked();
310 settings.
autoPull =
ui->checkBoxAutoPull->isChecked();
312 ui->checkBoxGitUseParentRepository->isChecked();
313 settings.
useOtp =
ui->checkBoxUseOtp->isChecked();
317 settings.
usePwgen =
ui->checkBoxUsePwgen->isChecked();
320 settings.
lessRandom =
ui->checkBoxLessRandom->isChecked();
321 settings.
useSymbols =
ui->checkBoxUseSymbols->isChecked();
323 settings.
useTemplate =
ui->comboBoxFields->currentIndex() > 0;
332ConfigDialog::~ConfigDialog() =
default;
335 ui->gitPath->setText(path);
343 const bool hasGit = !
ui->gitPath->text().isEmpty();
344 if (!hasGit &&
ui->checkBoxUseGit->isChecked()) {
350 ui->checkBoxUseGit->setEnabled(hasGit);
358 ui->radioButtonNative->setChecked(!
usePass);
359 ui->radioButtonPass->setChecked(
usePass);
365 static const QRegularExpression fingerprint(
366 QStringLiteral(
"^(?:[0-9A-Fa-f]{40}|[0-9A-Fa-f]{64})$"));
367 const QStringList keys = setting.split(QLatin1Char(
' '), Qt::SkipEmptyParts);
368 return std::all_of(keys.cbegin(), keys.cend(), [](
const QString &key) {
369 return fingerprint.match(key).hasMatch();
382 const QHash<QString, int> &names)
const
385 if (entry.name.isEmpty()) {
386 problems.
name = tr(
"This field is required");
387 }
else if (entry.name.contains(QLatin1Char(
'/')) ||
388 entry.name.contains(QLatin1Char(
'\\'))) {
389 problems.
name = tr(
"A profile name cannot contain / or \\");
390 }
else if (names.value(entry.name.toCaseFolded()) > 1) {
391 problems.
name = tr(
"Another profile already has this name");
393 if (entry.profile.path.isEmpty()) {
394 problems.
path = tr(
"This field is required");
400 problems.
key = tr(
"Full key fingerprints only (40 or 64 hexadecimal "
401 "characters), separated by spaces");
407 if (QListWidgetItem *item =
ui->profileList->item(row)) {
408 item->setBackground(problems.
none() ? QBrush() : QBrush(Qt::red));
416 const auto tipOr = [](
const QString &problem,
const QString &tip) -> QString {
417 return problem.isEmpty() ? tip : problem;
421 ui->profileSigningKey->setToolTip(tipOr(problems.
key,
m_keyTip));
440 const QString real = QFileInfo(entry.profile.path).canonicalFilePath();
441 resolved.
stores << (real.isEmpty() ? QDir::cleanPath(entry.profile.path)
449 const QProcessEnvironment &env)
const
456 static const QRegularExpression complete(QStringLiteral(
457 "^(?:0X)?(?:[0-9A-F]{8}|[0-9A-F]{16}|[0-9A-F]{40}|[0-9A-F]{64})$"));
458 const QString gpg =
ui->gpgPath->text();
460 const QStringList given =
461 signingKey.toUpper().split(QLatin1Char(
' '), Qt::SkipEmptyParts);
462 for (
const QString &key : given) {
464 if (gpg.isEmpty() || !complete.match(key).hasMatch()) {
467 const QString cacheKey = gpg + QLatin1Char(
'\n') +
468 env.value(QStringLiteral(
"GNUPGHOME")) +
469 QLatin1Char(
'\n') + key;
477 {QStringLiteral(
"--no-tty"), QStringLiteral(
"--batch"),
478 QStringLiteral(
"--no-auto-check-trustdb"),
479 QStringLiteral(
"--with-colons"),
480 QStringLiteral(
"--with-fingerprint"),
481 QStringLiteral(
"--with-subkey-fingerprint"),
482 QStringLiteral(
"--list-keys"), QStringLiteral(
"--"), key},
487 if (!cached->isEmpty()) {
488 keys.insert(*cached);
495 QDialog::changeEvent(event);
496 if (event->type() != QEvent::ActivationChange) {
503 if (!isActiveWindow()) {
505 [](
const std::pair<const QString &, QString &> &lookup) {
506 return lookup.second.isEmpty();
520 const QSet<QString> &mine = resolved.keys.at(row);
521 if (mine.isEmpty()) {
524 for (
int other = 0; other <
m_entries.size(); ++other) {
525 if (other == row || resolved.stores.at(other) == resolved.stores.at(row)) {
528 if (resolved.keys.at(other).intersects(mine)) {
537 QHash<QString, int> names;
539 names[entry.name.toCaseFolded()]++;
543 for (
int row = 0; row <
m_entries.size(); ++row) {
548 tr(
"%1 signs with the same key for another store. A recipient "
549 "list signed for one of these stores is accepted in the other: "
550 "use a separate signing key for each store whose recipients "
552 .arg(others.join(QStringLiteral(
", ")));
555 status = status && problems.
none();
557 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status);
566 QStringList warnings;
567 if (
ui->radioButtonPass->isChecked()) {
568 QStringList stores{
ui->storePath->text()};
570 stores << entry.profile.path;
572 stores.removeDuplicates();
573 for (
const QString &store : std::as_const(stores)) {
575 if (!repository.isEmpty()) {
576 warnings << tr(
"pass commits changes in %1 to the Git repository in "
577 "%2: with a colon in the store's path, pass cannot "
578 "keep Git to the store. Run \"git init\" in the store, "
579 "or use native Git/GPG.")
580 .arg(QDir::toNativeSeparators(store),
581 QDir::toNativeSeparators(repository));
590 const QString
override =
ui->sshAuthSockOverride->text().trimmed();
591 if (
override.isEmpty()) {
599 reason = tr(
"The path does not exist.");
602 reason = tr(
"The path is not readable.");
605 reason = tr(
"The path is not a Unix domain socket.");
609 this, tr(
"Potentially invalid SSH_AUTH_SOCK override"),
610 tr(
"The SSH_AUTH_SOCK override value may be invalid.\n\n%1\n\n"
611 "The value will still be saved as entered.")
621 if (!wasActive.isEmpty() && entry.originalName == wasActive) {
622 nowActive = entry.name;
626 const auto active = profiles.constFind(nowActive);
627 if (active != profiles.constEnd()) {
659 if (!pass.isEmpty()) {
660 ui->passPath->setText(pass);
667 if (!gpg.isEmpty()) {
668 ui->gpgPath->setText(gpg);
671 if (!git.isEmpty()) {
675 if (!pwgen.isEmpty()) {
685 bool state =
ui->radioButtonPass->isChecked();
686 ui->groupBoxNative->setEnabled(!state);
687 ui->groupBoxPass->setEnabled(state);
691 ui->spinBoxPasswordLength->setEnabled(
false);
692 ui->checkBoxUsePwgen->setEnabled(
false);
693 ui->checkBoxAvoidCapitals->setEnabled(
false);
694 ui->checkBoxUseSymbols->setEnabled(
false);
695 ui->checkBoxLessRandom->setEnabled(
false);
696 ui->checkBoxAvoidNumbers->setEnabled(
false);
697 ui->labelPasswordChars->setEnabled(
false);
698 ui->passwordCharTemplateSelector->setEnabled(
false);
699 ui->lineEditPasswordChars->setEnabled(
false);
702 ui->spinBoxPasswordLength->setEnabled(
true);
708 QFileDialog dialog(
this);
709 dialog.setFileMode(QFileDialog::ExistingFile);
710 dialog.setOption(QFileDialog::ReadOnly);
712 return dialog.selectedFiles().constFirst();
719 QFileDialog dialog(
this);
720 dialog.setFileMode(QFileDialog::Directory);
721 dialog.setFilter(QDir::NoFilter);
722 dialog.setOption(QFileDialog::ShowDirsOnly);
724 return dialog.selectedFiles().constFirst();
732 if (!git.isEmpty()) {
739 if (!gpg.isEmpty()) {
740 ui->gpgPath->setText(gpg);
751 if (!pass.isEmpty()) {
752 ui->passPath->setText(pass);
758 if (!store.isEmpty()) {
759 ui->storePath->setText(store);
765 bool state = index > 0;
767 ui->checkBoxSelection->setEnabled(state);
768 ui->checkBoxHidePassword->setEnabled(state);
770 ui->checkBoxHideContent->setEnabled(state);
771 ui->labelAutoclear->setEnabled(state);
772 ui->spinBoxAutoclearSeconds->setEnabled(state);
773 ui->labelSeconds->setEnabled(state);
774 ui->checkBoxRestoreClipboard->setEnabled(state);
781 const bool hiding =
ui->checkBoxHidePassword->isEnabled() &&
782 ui->checkBoxHidePassword->isChecked();
783 ui->checkBoxHideAllFields->setEnabled(hiding);
784 const bool all = hiding &&
ui->checkBoxHideAllFields->isChecked();
785 ui->checkBoxHideSecretFields->setEnabled(hiding && !all);
787 hiding && !all &&
ui->checkBoxHideSecretFields->isChecked();
788 ui->lineEditSecretFields->setEnabled(words);
789 ui->buttonDefaultSecretFields->setEnabled(words);
802 const QString ¤tProfile) {
804 profiles.remove(QString());
807 ui->profileList->clear();
809 for (
auto i = profiles.cbegin(); i != profiles.cend(); ++i) {
810 if (i.key() == currentProfile) {
811 currentRow =
static_cast<int>(
m_entries.size());
813 m_entries.append({i.key(), i.value(), i.key()});
814 ui->profileList->addItem(i.key());
816 ui->profileList->setCurrentRow(currentRow);
817 if (currentRow < 0) {
824 if (m_currentEntry < 0 || m_currentEntry >=
m_entries.size()) {
836 ui->profileForm->setEnabled(entry !=
nullptr);
837 ui->deleteButton->setEnabled(entry !=
nullptr);
838 ui->profileName->setText(entry ? entry->
name : QString());
839 ui->profilePath->setText(entry ? entry->
profile.
path : QString());
842 entry && entry->
profile.
useGit.value_or(
ui->checkBoxUseGit->isChecked());
843 ui->profileUseGit->setChecked(
useGit);
844 ui->profileAutoPush->setChecked(
847 ui->profileAutoPull->setChecked(
850 ui->profileAutoPush->setEnabled(
useGit);
851 ui->profileAutoPull->setEnabled(
useGit);
860 profiles.insert(entry.name, entry.profile);
866 if (QDir(path).exists()) {
869 if (QMessageBox::question(
870 this, tr(
"Create profile directory?"),
871 tr(
"Would you like to create a password store at %1?").arg(path),
872 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
878 tr(
"Could not create profile directory: %1").arg(path));
886 const QString &path) {
902 usersDialog.setWindowTitle(tr(
"Select recipients for %1").arg(name));
903 if (usersDialog.exec() != QDialog::Accepted) {
915 QFile::remove(QDir(path).filePath(QStringLiteral(
".gpg-id")));
916 QFile::remove(QDir(path).filePath(QStringLiteral(
".gpg-id.sig")));
918 this, tr(
"Could not initialise profile %1").arg(name), note);
919 }
else if (!note.isEmpty()) {
921 tr(
"Profile %1").arg(name), note);
928 for (
auto it = newProfiles.cbegin(); it != newProfiles.cend(); ++it) {
929 const QString path = QDir::cleanPath(it.value().path);
932 const bool known = std::any_of(
933 existingProfiles.cbegin(), existingProfiles.cend(),
934 [&it](
const Profile &old) { return old.path == it.value().path; });
944 entry.
name = tr(
"New profile");
947 ui->profileList->addItem(entry.
name);
948 ui->profileList->setCurrentRow(
static_cast<int>(
m_entries.size()) - 1);
949 ui->profileName->setFocus();
950 ui->profileName->selectAll();
956 if (!dir.isEmpty()) {
957 ui->profilePath->setText(dir);
963 const int row =
ui->profileList->currentRow();
964 if (row < 0 || row >=
m_entries.size()) {
965 QMessageBox::warning(
this, tr(
"No profile selected"),
966 tr(
"No profile selected to delete"));
970 delete ui->profileList->takeItem(row);
979 QMessageBox::critical(
this, title, text, QMessageBox::Ok, QMessageBox::Ok);
986 Q_UNUSED(configuredPath);
989 if (!configuredPath.isEmpty()) {
990 const QFileInfo configured(configuredPath);
991 if (configured.isFile() && configured.isExecutable()) {
996 if (found.isEmpty()) {
1005 if (QSystemTrayIcon::isSystemTrayAvailable()) {
1006 ui->checkBoxUseTrayIcon->setChecked(useSystray);
1007 ui->checkBoxHideOnClose->setEnabled(useSystray);
1008 ui->checkBoxStartMinimized->setEnabled(useSystray);
1011 ui->checkBoxHideOnClose->setChecked(
false);
1012 ui->checkBoxStartMinimized->setChecked(
false);
1018 bool state =
ui->checkBoxUseTrayIcon->isChecked();
1019 ui->checkBoxHideOnClose->setEnabled(state);
1020 ui->checkBoxStartMinimized->setEnabled(state);
1026 if (
ui->gitPath->text().isEmpty()) {
1029 ui->checkBoxUseGit->setChecked(
useGit);
1034 ui->checkBoxUseOtp->setChecked(
useOtp);
1046 ui->checkBoxAddGPGId->setEnabled(
ui->checkBoxUseGit->isChecked());
1047 ui->checkBoxAutoPull->setEnabled(
ui->checkBoxUseGit->isChecked());
1048 ui->checkBoxAutoPush->setEnabled(
ui->checkBoxUseGit->isChecked());
1051 ui->checkBoxGitUseParentRepository->setEnabled(
1052 ui->checkBoxUseGit->isChecked() && !
ui->radioButtonPass->isChecked());
1057 if (!pwgen.isEmpty()) {
1063 ui->pwgenPath->setText(pwgen);
1072 const bool hasPwgen = !
ui->pwgenPath->text().isEmpty();
1074 ui->checkBoxUsePwgen->setChecked(
false);
1076 ui->checkBoxUsePwgen->setEnabled(hasPwgen &&
1077 !
ui->radioButtonPass->isChecked());
1082 if (
ui->radioButtonPass->isChecked())
1084 bool usePwgen =
ui->checkBoxUsePwgen->isChecked();
1085 ui->checkBoxAvoidCapitals->setEnabled(
usePwgen);
1086 ui->checkBoxAvoidNumbers->setEnabled(
usePwgen);
1087 ui->checkBoxLessRandom->setEnabled(
usePwgen);
1088 ui->checkBoxUseSymbols->setEnabled(
usePwgen);
1090 ui->lineEditPasswordChars->setEnabled(
1091 !
usePwgen &&
ui->passwordCharTemplateSelector->currentIndex() ==
1093 ui->labelPasswordChars->setEnabled(!
usePwgen);
1094 ui->passwordCharTemplateSelector->setEnabled(!
usePwgen);
1098 if (
ui->pwgenPath->text().isEmpty()) {
1110 ui->spinBoxPasswordLength->setValue(config.
length);
1111 ui->passwordCharTemplateSelector->setCurrentIndex(config.
selected);
1113 ui->lineEditPasswordChars->setEnabled(
false);
1120 config.
length =
ui->spinBoxPasswordLength->value();
1122 ui->passwordCharTemplateSelector->currentIndex());
1127 ui->lineEditPasswordChars->text();
1135 ui->lineEditPasswordChars->setText(
1138 ui->lineEditPasswordChars->setEnabled(
true);
1140 ui->lineEditPasswordChars->setEnabled(
false);
1153 item->setText(name);
1187 ui->profileAutoPush->setEnabled(
ui->profileUseGit->isChecked());
1188 ui->profileAutoPull->setEnabled(
ui->profileUseGit->isChecked());
1193 if (entry ==
nullptr) {
1194 ui->statusLabel->setText(QString());
1198 QString statusMessage;
1200 const QString path = QDir::cleanPath(entry->
profile.
path);
1201 if (!QDir(path).exists()) {
1202 statusMessage = tr(
"New profile: %1 at %2").arg(entry->
name, path);
1204 statusMessage = tr(
"Profile: %1 at %2").arg(entry->
name, path);
1207 statusMessage = tr(
"Fill in all required fields");
1210 ui->statusLabel->setText(statusMessage);
AppSettings, the value object holding every flat QtPass setting.
void setPasswordConfiguration(const PasswordConfiguration &config)
Apply a password configuration to the dialog controls.
void on_deleteButton_clicked()
Remove the selected profile row (a message when none is); the list's currentRowChanged re-points the ...
std::optional< AppSettings > m_gpgSettings
void on_passwordCharTemplateSelector_activated(int index)
Show the chosen character set's characters in the line edit, editable only for the custom set.
static auto isFingerprintList(const QString &setting) -> bool
Whether a signing-key setting holds only full key fingerprints (40 or 64 hexadecimal characters each,...
void on_toolButtonGit_clicked()
Pick the git executable in a file dialog; a choice enables "useGit", a cancelled dialog keeps the fie...
auto sharingTheKey(int row, const SigningStores &resolved) const -> QStringList
The other profiles, for other stores, whose signing keys share a fingerprint with row row's.
void validate()
Check every profile (problemsOf(), sharingTheKey()), mark the rows and the form, enable OK only when ...
void updatePassGitWarning()
auto ensureProfileFolder(const QString &path) -> bool
Offer to create a new profile's store folder when it is missing.
void on_radioButtonNative_clicked()
Native (gpg/git) backend chosen: enable its group box, disable pass's.
QList< ProfileEntry > m_entries
The profiles as shown; index == row in profileList.
void useOtp(bool useOtp)
Enable or disable OTP support.
void updateSecretFieldsEnabled()
bool m_gitOnBeforeEmptyPath
void loadProfileForm(int row)
Show row row's profile in the form (or clear and disable it for -1), with m_loadingForm set so the fi...
void on_pushButtonGenerateKey_clicked()
Open KeygenDialog for the gpg shown in the dialog.
void setPwgenPath(const QString &path)
Set the path to the pwgen executable.
void on_toolButtonStore_clicked()
Pick the password store folder for the pass backend's store path.
void updateGitCheckbox()
Make "use Git" follow the git path field: enabled with a path, turned off and disabled without one....
void on_checkBoxUseTrayIcon_clicked()
Hide-on-close and start-minimised are only offered with a tray icon.
QHash< QString, QString > m_primaryOf
void useGit(bool useGit)
Enable or disable git integration.
void on_radioButtonPass_clicked()
pass backend chosen: enable its group box, disable the native one.
void showProblems(int row, const ProfileProblems &problems)
Mark row row of the profile list, and the form fields when it is the row being edited,...
int m_currentEntry
Row whose fields the form shows, -1 for none.
void on_profilePathBrowse_clicked()
Pick the selected profile's store folder and store it in its entry.
QLabel * m_sharedKeyWarning
Below the signing key: the profiles that share it, if any.
QScopedPointer< Ui::ConfigDialog > ui
The widgets from configdialog.ui.
void on_checkBoxUsePwgen_clicked()
Enable pwgen's flags or the character-set controls, whichever the "use pwgen" box selects; nothing in...
auto signerKeys(const QString &signingKey, const QProcessEnvironment &env) const -> QSet< QString >
One profile's signing keys as signers: each key as written, plus the primary fingerprint gpg gives fo...
void setProfiles(Profiles profiles, const QString ¤tProfile)
Fill the profile list and m_entries from profiles, dropping the empty-named leftover older versions w...
void useQrencode(bool useQrencode)
Enable or disable QR code display.
void on_autodetectButton_clicked()
Fill the pass, gpg (gpg2 first), git and pwgen paths from PATH, keeping a field as it is when nothing...
auto problemsOf(const ProfileEntry &entry, const QHash< QString, int > &names) const -> ProfileProblems
What is wrong with entry's name, store path and signing keys.
void on_comboBoxClipboard_activated(int index)
Enable the controls that only mean something with a clipboard (selection, hiding, autoclear) unless "...
void updatePwgenCheckbox()
Make "use pwgen" follow the pwgen path field: enabled with a path in native mode, unticked and disabl...
void onProfilePathEdited(const QString &path)
The path field was typed in: store it in the entry, validate and refresh the status line.
void usePass(bool usePass)
Tick the pass or the native radio button and enable the matching group box.
void useGrepSearch(bool useGrepSearch)
Enable or disable grep content search.
QLabel * m_passGitWarning
In the pass box: the stores pass would commit outside of, if any.
void initializeNewProfiles(const Profiles &existingProfiles)
For every saved profile whose store was not a profile's store when the dialog opened: offer to create...
ConfigDialog(QWidget *parent)
Construct a ConfigDialog associated with the given main window.
void onProfileSelected(int row)
The profile list's current row changed: show that profile.
auto signingStores() const -> SigningStores
Resolve every profile's store and fingerprints once.
auto selectExecutable() -> QString
Ask for an existing file in a read-only file dialog.
QString m_customPasswordChars
void setGitPath(const QString &path)
Show path as the git executable; an empty path disables and turns off "use Git".
void on_toolButtonPass_clicked()
Pick the pass executable in a file dialog; cancel keeps the field.
void setGroupBoxState()
Enable the group box of the chosen backend and, in pass mode, disable the password-generation control...
void onProfileGitToggled()
One of the profile's Git boxes was clicked: all three flags become the profile's own (no longer follo...
void on_checkBoxUseGit_clicked()
Enable the Git-dependent boxes (add .gpg-id, auto pull/push, and in native mode the parent-repository...
auto getPasswordConfiguration() -> PasswordConfiguration
Read the current password configuration from the dialog controls.
auto currentEntry() -> ProfileEntry *
The entry the form is editing.
void initialiseProfileStore(const QString &name, const Profile &profile, const QString &path)
Ask for a new profile's recipients and initialise its store with them, keeping the active backend's s...
void criticalMessage(const QString &title, const QString &text)
QMessageBox::critical with a single OK button. Once a workaround for crashes in Qt 5....
void useTrayIcon(bool useSystray)
Show or hide the system tray icon.
void onProfileSigningKeyEdited(const QString &key)
The signing-key field was typed in: store it in the entry and validate (fingerprints only,...
void followActiveProfile(const Profiles &profiles)
Point the active profile at its new name after a rename (or at none after a deletion),...
void on_toolButtonGpg_clicked()
Pick the gpg executable in a file dialog; cancel keeps the field.
void warnAboutSshAuthSockOverride()
void applySettings(const AppSettings &settings)
Load the dialog's value widgets from an AppSettings struct.
auto getProfiles() -> Profiles
Return all configured profiles.
void on_accepted()
On OK: warn about a dubious SSH_AUTH_SOCK override, save the settings and the profiles,...
void on_checkBoxSelection_clicked()
Re-apply the clipboard gating for the current clipboard mode.
void on_toolButtonPwgen_clicked()
Pick the pwgen executable; a choice enables "use pwgen", a cancelled dialog keeps the field and the c...
void usePwgen(bool usePwgen)
Enable or disable pwgen-based password generation.
void changeEvent(QEvent *event) override
Forget the signing keys gpg did not know while the dialog is in the background, and check them again ...
void updateProfileStatus()
Refresh the status line under the form: the profile's name and cleaned path, marked "New" while the f...
auto isQrencodeAvailable(const QString &configuredPath) -> bool
Whether qrencode can run: configuredPath when it is an executable file, else a qrencode on Util's PAT...
auto readSettings() -> AppSettings
Build an AppSettings struct from the dialog's widgets.
void onProfileNameEdited(const QString &name)
The name field was typed in: store it in the entry and the list item, then validate (duplicates,...
void on_addButton_clicked()
Append a "New profile" row pointing at the global store path, select it and put the cursor in the nam...
auto selectFolder() -> QString
Ask for a directory in a directories-only file dialog.
void useSelection(bool useSelection)
Enable or disable clipboard selection mode.
static auto executeBlocking(const QString &app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int
Run a command synchronously and return its exit code.
Handles GPG keypair generation.
static auto needsInit(const QString &path) -> bool
Check if a profile path needs initialization.
static auto initialise(const QString &dir, const QList< UserInfo > &users, const AppSettings &settings, bool useGit, QString *note) -> bool
Write the recipients and, if wanted, put the folder under git.
static auto gpgEnvironment(const AppSettings &s) -> QProcessEnvironment
The environment QtPass runs gpg in outside the active store's backend: the system's,...
static auto getPass() -> Pass *
Get currently active pass backend instance.
static auto getPasswordConfiguration() -> PasswordConfiguration
Get complete password generation configuration.
static auto load() -> AppSettings
Load all flat settings into an AppSettings value object.
static auto getProfiles() -> Profiles
Get all configured profiles.
static void setQrencodeExecutable(const QString &qrencodeExecutable)
Save qrencode executable path.
static auto getProfile(const QString &defaultValue=QVariant().toString()) -> QString
Get active profile name.
static void setProfiles(const Profiles &profiles)
Save all configured profiles.
static void takeProfileOfStore(AppSettings &settings, const Profiles &profiles)
Make settings use the profile whose store it opens.
static void save(const AppSettings &settings)
Persist an AppSettings value object to the singleton store.
@ Valid
Exists, readable, and on Unix a Unix domain socket.
@ NotUnixDomainSocket
Unix only: stat() says the path is not S_ISSOCK.
@ DoesNotExist
QFileInfo::exists() returned false.
static auto overrideStatus(const QString &path) -> OverrideStatus
Validate an SSH_AUTH_SOCK override path. Caller is expected to skip validation when the input is empt...
Dialog for selecting GPG recipients for password encryption.
auto selectedUsers() const -> QList< UserInfo >
The key list with the user's choice in each entry's enabled flag.
@ Nothing
None: for a store that had no list when it was chosen.
void setInitOnAccept(bool initOnAccept)
Choose whether OK runs Pass::Init on the folder.
static auto repositoryPassClimbsTo(const QString &store) -> QString
The repository above store that pass itself would commit to, if any.
static auto configIsValid(const AppSettings &s) -> bool
Verify that the required configuration is complete.
static auto mkpathForStore(const QString &path) -> bool
Create path and any missing parents as pass would.
static auto normalizeFolderPath(const QString &path) -> QString
Ensure a folder path always ends with '/'.
static auto findBinaryInPath(const QString &binary) -> QString
Locate an executable by searching the process PATH and (on Windows) falling back to WSL.
Settings dialog: every page of the configuration window and the profile table, with the validation th...
Executor, the FIFO queue every gpg, git and pass child process of QtPass goes through,...
auto primaryFingerprintOf(const QString &output, const QString &key) -> QString
The primary key fingerprint of the key that key names.
Parsing of gpg --with-colons key listings into UserInfo records.
Dialog that collects name, e-mail and passphrase for a new GPG keypair and drives gpg --gen-key --bat...
ClipBoardType
Defines when to copy passwords to clipboard.
auto show(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons=QMessageBox::Ok) -> QMessageBox::StandardButton
Show a modal message box with plain text and wait for it.
void warning(QWidget *parent, const QString &title, const QString &text)
Show a warning in plain text.
void attach(QDialog &dialog, const QString &key)
restore() now, save() whenever the dialog finishes.
QMessageBox helpers that force Qt::PlainText so store-controlled names can never be read as rich-text...
QMap< QString, Profile > Profiles
All profiles by name. QMap so iteration order is the name order.
Initialising a new profile's store (.gpg-id, signature, Git) with blocking processes,...
The "qtpass" logging category.
QtPassSettings, the QSettings singleton behind every saved setting, the profiles and the Pass backend...
SshAuthSock: finding an SSH agent socket for child processes and judging a configured override.
Plain value-object holding all flat QtPass configuration.
bool displayAsIs
Show file content unmodified.
bool useGrepSearch
Enable content (grep) search.
QString gpgExecutable
Path to the gpg/gpg2 executable.
QString qrencodeExecutable
Path to the qrencode executable.
QString sshAuthSockOverride
Manual SSH_AUTH_SOCK override path.
bool lessRandom
Generate memorable (less random) passwords.
bool useSymbols
Include special symbols.
bool hideOnClose
Hide to tray instead of quitting on close.
QStringList secretFieldNames
QString passSigningKey
GPG key used to sign .gpg-id files.
bool usePass
Use the pass CLI (true) or native git/gpg.
QString pwgenExecutable
Path to the pwgen executable.
bool hideContent
Hide the entire content panel.
bool useOtp
Enable native TOTP (OTP) support.
QString passStore
Password-store root path.
bool useAutoclearPanel
Clear the content panel after a delay.
bool noLineWrapping
Disable line wrapping in the panel.
QString gitExecutable
Path to the git executable.
bool autoPull
git pull before an entry is edited and before a re-encryption.
bool alwaysOnTop
Keep the main window always on top.
int autoclearPanelSeconds
Panel autoclear delay (seconds).
bool startMinimized
Start the window minimised.
bool useTrayIcon
Show a system tray icon.
bool gitUseParentRepository
QString passExecutable
Path to the pass executable.
bool avoidCapitals
Exclude uppercase letters.
int autoclearSeconds
Clipboard autoclear delay (seconds).
bool useSelection
Use the X11 primary selection.
bool useGit
Enable git integration.
bool addGPGId
Auto-add .gpg-id files to git.
Enums::ClipBoardType clipBoardType
Clipboard copy behaviour.
QString version
Last-run application version.
QString passTemplate
Newline-separated template field names.
bool useMonospace
Render content in a monospace font.
bool templateAllFields
Treat every key: line as a field.
bool avoidNumbers
Exclude digits.
bool useQrencode
Enable qrencode support.
QString activeProfile
Name of the active profile.
bool useTemplate
Use the password template.
PasswordConfiguration passwordConfiguration
Length/charset/custom chars.
One row of the profile list while the dialog is open. A QList rather than the Profiles map so a profi...
QString name
The name as typed; may be empty or a duplicate.
What is wrong with one profile's fields; empty strings where nothing is.
QString name
Empty or duplicate name; empty when fine.
auto none() const -> bool
Whether all three fields are fine.
auto first() const -> QString
The first complaint, for a tooltip on the profile's row.
QString path
Missing store path; empty when fine.
QStringList stores
Canonical (or cleaned) store path.
QList< QSet< QString > > keys
Fingerprints of the signing key.
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...
One named password store: where it is, how its .gpg-id is signed and, optionally, its own Git switche...
std::optional< bool > autoPush
Push after commits; unset = global.
QString path
Password store directory.
std::optional< bool > autoPull
Pull on start; unset = global.
std::optional< bool > useGit
Git on/off; unset follows the global.
QString signingKey
Key(s) that sign this store's .gpg-id.
UsersDialog, the recipient picker for a folder's .gpg-id.
Util: static helpers for the process environment, binary discovery, store paths, URL safety and the l...
WindowStateStore: saves and restores top-level window geometry through QtPassSettings,...