QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
firstrunwizard.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#include "firstrunwizard.h"
9#include "executor.h"
10#include "gpgkeystate.h"
11#include "imitatepass.h"
12#include "keygendialog.h"
13#include "passbackendfactory.h"
14#include "plainmessagebox.h"
15#include "profileinit.h"
16#include "qtpasssettings.h"
17#include "settingsconstants.h"
18#include "util.h"
19#include <QCheckBox>
20#include <QDateTime>
21#include <QDir>
22#include <QFile>
23#include <QFileDialog>
24#include <QFileInfo>
25#include <QFormLayout>
26#include <QHBoxLayout>
27#include <QLabel>
28#include <QLineEdit>
29#include <QListWidget>
30#include <QMessageBox>
31#include <QPushButton>
32#include <QSystemTrayIcon>
33#include <QToolButton>
34#include <QVBoxLayout>
35#include <functional>
36#ifdef Q_OS_WIN
37#include <windows.h>
38#endif
39
40namespace {
41
43auto pathRow(QLineEdit *edit, QWidget *parent,
44 const std::function<QString()> &pick) -> QWidget * {
45 auto *row = new QWidget(parent);
46 auto *layout = new QHBoxLayout(row);
47 layout->setContentsMargins(0, 0, 0, 0);
48 layout->addWidget(edit);
49 auto *browse = new QToolButton(row);
50 browse->setText(QStringLiteral("…"));
51 browse->setToolTip(FirstRunWizard::tr("Browse"));
52 layout->addWidget(browse);
53 QObject::connect(browse, &QToolButton::clicked, edit, [edit, pick]() {
54 const QString chosen = pick();
55 if (!chosen.isEmpty()) {
56 edit->setText(chosen);
57 emit edit->textEdited(chosen);
58 }
59 });
60 return row;
61}
62
63auto runnable(const QString &exe) -> bool {
64 return Executor::parseWslCommand(exe).has_value() ||
65 (!exe.isEmpty() && QFileInfo(exe).isExecutable());
66}
67
68} // namespace
69
70// --------------------------------------------------------------------------
71
73 : QWizard(parent), m_settings(QtPassSettings::load()),
74 m_detectChoices(QtPassSettings::getInstance()
75 ->value(SettingsConstants::firstRunPending, false)
76 .toBool()) {
77 setWindowTitle(tr("Welcome to QtPass"));
78 setWizardStyle(QWizard::ModernStyle);
79 setOption(QWizard::NoBackButtonOnStartPage);
80 setOption(QWizard::HaveHelpButton, false);
81
82 auto *intro = new QWizardPage(this);
83 intro->setTitle(tr("Welcome to QtPass"));
84 auto *introLayout = new QVBoxLayout(intro);
85 auto *introText = new QLabel(
86 tr("QtPass is a graphical front-end for <i>pass</i>, the standard Unix "
87 "password manager: every password is a file encrypted with GnuPG, "
88 "kept in a folder you can put under Git.<br><br>The next pages find "
89 "GnuPG, make sure you have a key to encrypt to and pick the folder "
90 "your passwords live in. Nothing is written until you press "
91 "Finish."),
92 intro);
93 introText->setWordWrap(true);
94 introText->setTextFormat(Qt::RichText);
95 introLayout->addWidget(introText);
96 setPage(IntroPage, intro);
97 setPage(ProgramsPage, new ProgramsWizardPage(this));
98 setPage(KeyPage, new KeyWizardPage(this));
99 setPage(StorePage, new StoreWizardPage(this));
100 setPage(DonePage, new DoneWizardPage(this));
101 setStartId(IntroPage);
102 resize(640, 480);
103}
104
105auto FirstRunWizard::secretKeys(const QString &gpgExecutable, QString *problem)
106 -> QList<UserInfo> {
107 if (!runnable(gpgExecutable)) {
108 return {};
109 }
110 QString out;
111 QString err;
112 const int rc = Executor::executeBlocking(
113 gpgExecutable,
114 {QStringLiteral("--no-tty"), QStringLiteral("--with-colons"),
115 QStringLiteral("--with-fingerprint"),
116 QStringLiteral("--list-secret-keys")},
117 &out, &err);
118 if (rc != 0 && problem != nullptr) {
119 constexpr qsizetype kMaxProblem = 400;
120 // It may quote a user ID someone else chose: no bidi overrides or other
121 // controls that change how the text around them reads.
122 *problem = Util::displayable(err.trimmed());
123 if (problem->size() > kMaxProblem) {
124 *problem = problem->left(kMaxProblem) + QChar(0x2026);
125 }
126 }
127 // Exit 2 is gpg's "an error occurred", also after a complete listing in
128 // which one key could not be handled: setup must not stall on that key.
129 if (rc != 0 && rc != 2) {
130 return {};
131 }
132 return parseGpgColonOutput(out, true);
133}
134
135auto FirstRunWizard::isStore(const QString &path) -> bool {
136 return !path.isEmpty() &&
137 QFile::exists(QDir(path).filePath(QStringLiteral(".gpg-id")));
138}
139
140auto FirstRunWizard::initialiseStore(const QString &store) -> bool {
141 QList<UserInfo> recipients;
142 for (const UserInfo &key : std::as_const(m_keys)) {
143 if (key.enabled) {
144 recipients.append(key);
145 }
146 }
147 const bool created = !QDir(store).exists();
148 if (created && !Util::mkpathForStore(store)) {
150 this, tr("Error"),
151 tr("Failed to create password-store at: %1").arg(store));
152 return false;
153 }
154#ifdef Q_OS_WIN
155 // Only a folder made here is hidden, like ~/.password-store on Unix; a
156 // folder the user picked keeps its attributes.
157 if (created) {
158 SetFileAttributes(store.toStdWString().c_str(), FILE_ATTRIBUTE_HIDDEN);
159 }
160#endif
161 QString note;
162 if (!ProfileInit::initialise(store, recipients, m_settings, m_settings.useGit,
163 &note)) {
164 // ProfileInit writes .gpg-id before it signs and commits; take it back so
165 // a second Finish runs the whole initialisation again instead of finding
166 // a store that looks finished.
167 QFile::remove(QDir(store).filePath(QStringLiteral(".gpg-id")));
168 QFile::remove(QDir(store).filePath(QStringLiteral(".gpg-id.sig")));
169 PlainMessageBox::warning(this, tr("Password store not initialised"), note);
170 return false;
171 }
172 if (!note.isEmpty()) {
173 // ProfileInit's own note talks of switching profiles; on the first run
174 // the folder simply becomes the store.
176 this, QMessageBox::Information, tr("Password store"),
177 tr("%1 already contains encrypted files; they were not "
178 "re-encrypted to the ticked keys. Open Users after the start "
179 "to do that.")
180 .arg(QDir::toNativeSeparators(store)));
181 }
182 return true;
183}
184
185auto FirstRunWizard::initialiseGit(const QString &store) -> bool {
186 QString note;
187 if (ProfileInit::initGit(store, m_settings, &note)) {
188 return true;
189 }
190 // Take the repository back too, so a second Finish retries the whole thing
191 // instead of skipping a .git that never got its first commit.
192 QDir(QDir(store).filePath(QStringLiteral(".git"))).removeRecursively();
193 PlainMessageBox::warning(this, tr("Password store not initialised"), note);
194 return false;
195}
196
198 // The Finish button validates the page before calling this; a programmatic
199 // accept() gets the same treatment so the last page's choices are in.
200 if (currentPage() != nullptr && !currentPage()->validatePage()) {
201 return;
202 }
203 const QString store = QDir::cleanPath(m_settings.passStore);
204 // A profile's store opens as that profile, with its signing key: taken
205 // before a new store's list is written, so it is signed with that key.
206 // A refused or failed setup puts the previous choice back for a retry.
207 const QString wasActive = m_settings.activeProfile;
208 const QString wasKey = m_settings.passSigningKey;
209 const QString wasStore = m_settings.passStore;
210 // Matched as it is saved: the typed spelling can name another folder (a
211 // link followed by "..").
214 const bool needsGit =
215 m_settings.useGit && !QDir(store).exists(QStringLiteral(".git"));
216 const bool ready = !isStore(store) ? initialiseStore(store)
217 : needsGit ? initialiseGit(store)
218 : true;
219 if (!ready) {
220 m_settings.activeProfile = wasActive;
221 m_settings.passSigningKey = wasKey;
222 m_settings.passStore = wasStore;
223 return;
224 }
227 // Chosen now: a later run (the store lost its list) keeps these choices.
229 // The backend cached the old paths at construction.
231 QWizard::accept();
232}
233
234// --------------------------------------------------------------------------
235
237 : QWizardPage(wizard), m_wizard(wizard), m_gpg(new QLineEdit(this)),
238 m_git(new QLineEdit(this)), m_pass(new QLineEdit(this)),
239 m_usePass(new QCheckBox(tr("Use the pass command-line tool"), this)),
240 m_gpgStatus(new QLabel(this)) {
241 setTitle(tr("Programs"));
242 setSubTitle(tr("GnuPG does the encrypting. pass and Git are optional; "
243 "QtPass can do their work itself."));
244 auto *layout = new QFormLayout(this);
245 auto pickExe = [this]() {
246 return QFileDialog::getOpenFileName(this, tr("Select executable"),
247 QString(), tr("All files (*)"));
248 };
249 layout->addRow(tr("GnuPG"), pathRow(m_gpg, this, pickExe));
250 m_gpgStatus->setWordWrap(true);
251 layout->addRow(QString(), m_gpgStatus);
252 layout->addRow(tr("Git"), pathRow(m_git, this, pickExe));
253 layout->addRow(tr("pass"), pathRow(m_pass, this, pickExe));
254 m_usePass->setToolTip(tr("Run the pass script for every operation instead "
255 "of calling gpg and git directly"));
256 layout->addRow(QString(), m_usePass);
257 for (QLineEdit *edit : {m_gpg, m_git, m_pass}) {
258 connect(edit, &QLineEdit::textEdited, this,
260 }
261}
262
265 // QtPassSettings::initExecutables() fills empty paths from PATH only; a
266 // stored path whose binary has moved would be shown as an error here, so
267 // look it up again in that case.
268 auto detect = [](QString &stored, const QStringList &names) {
269 if (runnable(stored)) {
270 return;
271 }
272 for (const QString &name : names) {
273 const QString found = Util::findBinaryInPath(name);
274 if (!found.isEmpty()) {
275 stored = found;
276 return;
277 }
278 }
279 };
280 detect(s.gpgExecutable, {QStringLiteral("gpg2"), QStringLiteral("gpg")});
281 detect(s.gitExecutable, {QStringLiteral("git")});
282 detect(s.passExecutable, {QStringLiteral("pass")});
283 detect(s.pwgenExecutable, {QStringLiteral("pwgen")});
284 m_gpg->setText(s.gpgExecutable);
285 m_git->setText(s.gitExecutable);
286 m_pass->setText(s.passExecutable);
287 // Detected only the first time: a choice saved before (the wizard also
288 // runs for a store whose recipient list went missing) stays, or Next and
289 // Finish switched the backend without a word.
291 ? s.usePass || runnable(s.passExecutable)
292 : s.usePass);
293 updateStatus();
294}
295
297 const QString gpg = m_gpg->text().trimmed();
298 if (gpg.isEmpty()) {
299 m_gpgStatus->setText(tr("GnuPG was not found. Install it (gpg or gpg2) "
300 "and enter its location here."));
301 } else if (!runnable(gpg)) {
302 m_gpgStatus->setText(tr("%1 is not an executable file.").arg(gpg));
303 } else {
304 m_gpgStatus->setText(QString());
305 }
306 m_usePass->setEnabled(runnable(m_pass->text().trimmed()));
307 if (!m_usePass->isEnabled()) {
308 m_usePass->setChecked(false);
309 }
310 emit completeChanged();
311}
312
313auto ProgramsWizardPage::isComplete() const -> bool {
314 return runnable(m_gpg->text().trimmed());
315}
316
318 AppSettings &s = m_wizard->m_settings;
319 s.gpgExecutable = m_gpg->text().trimmed();
320 s.gitExecutable = m_git->text().trimmed();
321 s.passExecutable = m_pass->text().trimmed();
322 s.usePass = m_usePass->isChecked();
323 return true;
324}
325
326// --------------------------------------------------------------------------
327
329 : QWizardPage(wizard), m_wizard(wizard), m_list(new QListWidget(this)),
330 m_generate(new QPushButton(tr("Generate a new key pair…"), this)),
331 m_status(new QLabel(this)) {
332 setTitle(tr("Your key"));
333 setSubTitle(tr("Passwords are encrypted to GnuPG keys. Tick the keys that "
334 "should be able to open a new store; you need at least one "
335 "with its secret half on this machine."));
336 auto *layout = new QVBoxLayout(this);
337 layout->addWidget(m_list);
338 // What gpg reports is shown here: as text, never as markup.
339 m_status->setTextFormat(Qt::PlainText);
340 m_status->setWordWrap(true);
341 layout->addWidget(m_status);
342 auto *buttons = new QHBoxLayout;
343 buttons->addStretch();
344 buttons->addWidget(m_generate);
345 layout->addLayout(buttons);
346 connect(m_generate, &QPushButton::clicked, this, &KeyWizardPage::generate);
347 connect(m_list, &QListWidget::itemChanged, this,
348 [this]() { emit completeChanged(); });
349}
350
352
354 QString problem;
357 m_list->clear();
358 const QDateTime now = QDateTime::currentDateTime();
359 for (UserInfo &key : m_wizard->m_keys) {
360 // An expired or otherwise unusable key would make every encryption to
361 // the new store fail; list it, but do not tick it.
362 QString why;
363 if (key.expiry.isValid() && key.expiry < now) {
364 why = tr("expired");
365 } else if (!key.isValid()) {
366 why = tr("not usable");
367 }
368 const bool usable = why.isEmpty();
369 // Only a key the user trusts ultimately, which gpg gives the keys made
370 // here, starts ticked. A colleague's key can be in this listing too: a
371 // secret key block imported from them, or a public one bound to the
372 // user's own subkey (gpg lists it as sec#). Certified, it shows as fully
373 // valid, and ticked by default every new entry would be encrypted to them.
374 key.enabled = usable && key.validity == 'u';
375 QString label = QStringLiteral("%1\n%2").arg(key.name, key.key_id);
376 if (!usable) {
377 label += QStringLiteral(" (%1)").arg(why);
378 }
379 auto *item = new QListWidgetItem(label, m_list);
380 item->setFlags(usable ? (item->flags() | Qt::ItemIsUserCheckable)
381 : (item->flags() & ~Qt::ItemIsEnabled));
382 item->setCheckState(key.enabled ? Qt::Checked : Qt::Unchecked);
383 }
384 // gpg's own words when it did not exit cleanly: "no secret key yet" would
385 // send the user to make a key they may well have.
386 if (!problem.isEmpty()) {
387 //: %1 is what GnuPG reported, in its own words.
388 m_status->setText(tr("GnuPG reported a problem while listing the secret "
389 "keys:\n%1")
390 .arg(problem));
391 } else {
392 m_status->setText(
393 m_wizard->m_keys.isEmpty()
394 ? tr("GnuPG has no secret key yet. Generate one here, "
395 "or import your existing key with gpg first.")
396 : QString());
397 }
398 emit completeChanged();
399}
400
402 // A backend of the wizard's own, set up from its copy of the settings, so
403 // the chosen gpg is used and nothing is written before Finish. Each Pass
404 // owns its Executor; the shared backend is not involved.
405 ImitatePass pass;
406 pass.init(m_wizard->m_settings);
408 d.exec();
409 reload();
410}
411
412auto KeyWizardPage::isComplete() const -> bool { return true; }
413
415 for (int i = 0; i < m_list->count() && i < m_wizard->m_keys.size(); ++i) {
416 m_wizard->m_keys[i].enabled = m_list->item(i)->checkState() == Qt::Checked;
417 }
418 return true;
419}
420
421// --------------------------------------------------------------------------
422
424 : QWizardPage(wizard), m_wizard(wizard), m_path(new QLineEdit(this)),
425 m_useGit(new QCheckBox(tr("Keep the store under Git"), this)),
426 m_status(new QLabel(this)) {
427 setTitle(tr("Password store"));
428 setSubTitle(tr("The folder your passwords live in. An existing store is "
429 "used as it is; an empty or missing folder is set up for "
430 "the keys you ticked."));
431 auto *layout = new QFormLayout(this);
432 layout->addRow(tr("Folder"), pathRow(m_path, this, [this]() {
433 return QFileDialog::getExistingDirectory(
434 this, tr("Choose the password store folder"),
435 m_path->text());
436 }));
437 m_status->setWordWrap(true);
438 layout->addRow(QString(), m_status);
439 layout->addRow(QString(), m_useGit);
440 connect(m_path, &QLineEdit::textEdited, this, &StoreWizardPage::updateStatus);
441}
442
444 QString path = m_wizard->m_settings.passStore;
445 if (path.isEmpty()) {
447 }
448 m_path->setText(QDir::toNativeSeparators(QDir::cleanPath(path)));
449 const QString clean = QDir::cleanPath(path);
450 const bool repository = QDir(clean).exists(QStringLiteral(".git"));
451 bool haveGit = runnable(m_wizard->m_settings.gitExecutable);
452 // A first commit needs a name and an e-mail; without them Finish would
453 // fail at the very end. Ask git now and say what to do instead.
454 const bool identity =
455 haveGit && (repository || ProfileInit::gitIdentityConfigured(
456 QDir::homePath(), m_wizard->m_settings));
457 m_useGit->setToolTip(
458 haveGit && !identity
459 ? tr("Git has no name and e-mail to commit with yet. Run\n"
460 "git config --global user.name \"Your Name\"\n"
461 "git config --global user.email you@example.org\n"
462 "and turn Git on in Settings afterwards.")
463 : tr("Every change becomes a commit; a folder that is no "
464 "repository yet gets one"));
465 haveGit = haveGit && identity;
466 m_useGit->setEnabled(haveGit);
467 // On for a repository or a store still to be made, off for an existing
468 // store that is no repository: turning Git on there would make every
469 // remove fail in a folder git knows nothing about. A choice saved before
470 // stays (see ProgramsWizardPage::initializePage()).
471 m_useGit->setChecked(haveGit &&
473 ? m_wizard->m_settings.useGit || repository ||
476 updateStatus();
477}
478
479auto StoreWizardPage::recipients() const -> int {
480 int ticked = 0;
481 for (const UserInfo &key : std::as_const(m_wizard->m_keys)) {
482 ticked += key.enabled ? 1 : 0;
483 }
484 return ticked;
485}
486
488 const QString path = QDir::cleanPath(m_path->text().trimmed());
489 QString text;
490 if (path.isEmpty()) {
491 text = tr("Enter a folder.");
492 } else if (FirstRunWizard::isStore(path)) {
493 const int entries = static_cast<int>(
494 Util::regularFilesUnder(path, {QStringLiteral("*.gpg")}).size());
495 text = tr("An existing password store with %n entries.", nullptr, entries);
496 } else if (QDir(path).exists()) {
497 text = QDir(path).isEmpty()
498 ? tr("An empty folder; it will be set up as a password store.")
499 : tr("This folder is not a password store yet; a .gpg-id for "
500 "the ticked keys will be written into it.");
501 } else {
502 text = tr("The folder does not exist yet; it will be created.");
503 }
504 if (!path.isEmpty() && !FirstRunWizard::isStore(path) && recipients() == 0) {
505 text += QLatin1Char(' ') +
506 tr("Go back and tick at least one key to encrypt it to.");
507 }
508 m_status->setText(text);
509 emit completeChanged();
510}
511
512auto StoreWizardPage::isComplete() const -> bool {
513 const QString path = QDir::cleanPath(m_path->text().trimmed());
514 if (path.isEmpty()) {
515 return false;
516 }
517 return FirstRunWizard::isStore(path) || recipients() > 0;
518}
519
521 m_wizard->m_settings.passStore =
522 QDir::fromNativeSeparators(m_path->text().trimmed());
523 m_wizard->m_settings.useGit = m_useGit->isEnabled() && m_useGit->isChecked();
524 return true;
525}
526
527// --------------------------------------------------------------------------
528
530 : QWizardPage(wizard), m_wizard(wizard), m_summary(new QLabel(this)),
531 m_hidePassword(new QCheckBox(tr("Hide passwords until asked"), this)),
532 m_trayIcon(new QCheckBox(tr("Show an icon in the system tray"), this)) {
533 setTitle(tr("Ready"));
534 setSubTitle(tr("Everything else can be changed later in Settings."));
535 auto *layout = new QVBoxLayout(this);
536 m_summary->setWordWrap(true);
537 m_summary->setTextFormat(Qt::RichText);
538 layout->addWidget(m_summary);
539 layout->addSpacing(12);
540 m_hidePassword->setToolTip(
541 tr("Show the password line as dots; Show password reveals it"));
542 layout->addWidget(m_hidePassword);
543 layout->addWidget(m_trayIcon);
544 layout->addStretch();
545 setFinalPage(true);
546}
547
549 const AppSettings &s = m_wizard->m_settings;
550 const QString store = QDir::toNativeSeparators(QDir::cleanPath(s.passStore));
551 QStringList lines;
552 lines << tr("Store: %1").arg(store.toHtmlEscaped());
554 lines << tr("It is already a password store and is used as it is.");
555 } else if (s.useGit) {
556 lines << tr("It will be set up for the ticked keys and put under Git.");
557 } else {
558 lines << tr("It will be set up for the ticked keys.");
559 }
560 lines << tr("GnuPG: %1").arg(s.gpgExecutable.toHtmlEscaped());
561 lines << (s.usePass ? tr("Operations run through pass.")
562 : tr("Operations run through gpg and git directly."));
563 m_summary->setText(lines.join(QStringLiteral("<br>")));
564 m_hidePassword->setChecked(true);
565 const bool tray = QSystemTrayIcon::isSystemTrayAvailable();
566 m_trayIcon->setVisible(tray);
567 m_trayIcon->setChecked(tray && s.useTrayIcon);
568}
569
571 m_wizard->m_settings.hidePassword = m_hidePassword->isChecked();
572 m_wizard->m_settings.useTrayIcon =
573 m_trayIcon->isVisible() && m_trayIcon->isChecked();
574 return true;
575}
QLabel * m_summary
Store, what Finish does with it, gpg, mode.
void initializePage() override
Fill the summary from the settings.
QCheckBox * m_trayIcon
Tray icon; hidden when there is no tray.
FirstRunWizard * m_wizard
Owner; its settings get the preferences.
QCheckBox * m_hidePassword
Show the password line as dots; on.
DoneWizardPage(FirstRunWizard *wizard)
Build the page.
auto validatePage() -> bool override
Store the preferences.
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.
Definition executor.cpp:700
static auto parseWslCommand(const QString &app) -> std::optional< WslCommand >
Parse a configured executable as a WSL command.
Definition executor.cpp:272
The first start of QtPass: find GnuPG (and pass and Git), make sure there is a secret key,...
static auto secretKeys(const QString &gpgExecutable, QString *problem=nullptr) -> QList< UserInfo >
The secret keys gpg lists for gpgExecutable.
@ DonePage
DoneWizardPage: summary and two preferences.
@ ProgramsPage
ProgramsWizardPage: where gpg, pass and git are.
@ KeyPage
KeyWizardPage: the secret keys, with generation.
@ StorePage
StoreWizardPage: the store folder and the Git choice.
@ IntroPage
What QtPass is and what the wizard will do.
auto initialiseStore(const QString &store) -> bool
Make store a password store for the ticked keys: create the folder when it is missing,...
void accept() override
Write the settings and, when the chosen store has no .gpg-id yet, create and initialise it for the ch...
auto initialiseGit(const QString &store) -> bool
Give an existing store the Git repository it was chosen to have.
static auto isStore(const QString &path) -> bool
Whether path points at an initialised store.
AppSettings m_settings
FirstRunWizard(QWidget *parent=nullptr)
Build the wizard from the current settings.
QList< UserInfo > m_keys
Implementation that imitates 'pass' when the real tool is unavailable.
Definition imitatepass.h:41
QListWidget * m_list
One checkable row per secret key.
void initializePage() override
List the secret keys for the gpg chosen on the previous page.
void reload()
List the secret keys of the chosen gpg into the wizard and the widget, ticking every usable key and g...
auto isComplete() const -> bool override
Always passable: an existing store needs no recipient choice here (and its key may not be imported ye...
QPushButton * m_generate
Opens KeygenDialog.
void generate()
Run KeygenDialog on a private ImitatePass built from the wizard's settings, so the chosen gpg is used...
FirstRunWizard * m_wizard
Owner; holds the key list this page fills.
QLabel * m_status
Says so when gpg has no secret key yet.
auto validatePage() -> bool override
Remember which keys are enabled.
KeyWizardPage(FirstRunWizard *wizard)
Build the page.
Handles GPG keypair generation.
static void invalidate()
Forget the currently active backend.
void init(const AppSettings &settings)
Initialize the Pass instance with a settings snapshot.
Definition pass.cpp:171
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 initGit(const QString &dir, const AppSettings &s, QString *note) -> bool
Put an existing store under Git: git init, stage the .gpg entries and the .gpg-id files (nothing else...
static auto gitIdentityConfigured(const QString &dir, const AppSettings &s) -> bool
Whether git has a name and e-mail to commit with, i.e. user.name and user.email resolve (globally or ...
QLineEdit * m_gpg
The gpg executable; required.
QLineEdit * m_pass
The pass executable; optional.
QLineEdit * m_git
The git executable; optional.
FirstRunWizard * m_wizard
Owner; its settings are what the page edits.
void initializePage() override
Fill the fields from the settings (autodetection already ran).
QLabel * m_gpgStatus
Under the gpg field: why it cannot be used.
void updateStatus()
After an edit: say under the gpg field when it is missing or not executable, allow "use pass" only fo...
auto isComplete() const -> bool override
Whether the gpg path points at something that can run.
ProgramsWizardPage(FirstRunWizard *wizard)
Build the page.
auto validatePage() -> bool override
Store the paths and the pass/Git choices in the settings.
QCheckBox * m_usePass
Run pass instead of gpg/git; needs m_pass.
Singleton that stores QtPass settings, handles persistence and defaults.
static auto getInstance() -> QtPassSettings *
Get the singleton instance.
static auto getProfiles() -> Profiles
Get 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.
The names of the keys in the settings file, one constant per key.
static const QString firstRunPending
Set on a fresh install until QtPass is first set up: the first-run wizard finished,...
StoreWizardPage(FirstRunWizard *wizard)
Build the page.
QLabel * m_status
What Finish will do with the folder.
auto validatePage() -> bool override
Store the path and the Git choice.
void initializePage() override
Show the configured store path.
auto recipients() const -> int
How many keys are ticked on the key page.
auto isComplete() const -> bool override
Whether a path is given and, for a folder that is not a store yet, at least one key was ticked to enc...
QLineEdit * m_path
The store folder, in native separators.
QCheckBox * m_useGit
Keep the store under Git; off without git.
FirstRunWizard * m_wizard
Owner; its settings get the path and flag.
void updateStatus()
After an edit: describe the folder (existing store with its entry count, empty folder,...
static auto findPasswordStore() -> QString
Locate the password store directory.
Definition util.cpp:81
static auto regularFilesUnder(const QString &dir, const QStringList &nameFilters, QStringList *skipped=nullptr, bool hiddenFiles=false, QStringList *unlisted=nullptr) -> QStringList
Regular files under dir whose name matches one of nameFilters, found by walking only real directories...
Definition util.cpp:1149
static auto mkpathForStore(const QString &path) -> bool
Create path and any missing parents as pass would.
Definition util.cpp:615
static auto displayable(const QString &text, bool lineBreaks=true) -> QString
text with the characters that change how the text around them reads replaced by U+FFFD,...
Definition util.cpp:898
static auto normalizeFolderPath(const QString &path) -> QString
Ensure a folder path always ends with '/'.
Definition util.cpp:118
static auto findBinaryInPath(const QString &binary) -> QString
Locate an executable by searching the process PATH and (on Windows) falling back to WSL.
Definition util.cpp:651
Executor, the FIFO queue every gpg, git and pass child process of QtPass goes through,...
The first-run wizard and its four pages: programs, key, store and summary.
auto parseGpgColonOutput(const QString &output, bool secret) -> QList< UserInfo >
Parse a gpg colon listing into one UserInfo per key.
Parsing of gpg --with-colons key listings into UserInfo records.
ImitatePass, the backend that does what pass does by running gpg and git itself.
Dialog that collects name, e-mail and passphrase for a new GPG keypair and drives gpg --gen-key --bat...
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.
PassBackendFactory, which constructs the two Pass backends on demand and hands out the one the settin...
QMessageBox helpers that force Qt::PlainText so store-controlled names can never be read as rich-text...
Initialising a new profile's store (.gpg-id, signature, Git) with blocking processes,...
QtPassSettings, the QSettings singleton behind every saved setting, the profiles and the Pass backend...
Names of the keys QtPass stores its settings under.
Plain value-object holding all flat QtPass configuration.
Definition appsettings.h:36
QString gpgExecutable
Path to the gpg/gpg2 executable.
Definition appsettings.h:66
QString passSigningKey
GPG key used to sign .gpg-id files.
Definition appsettings.h:61
bool usePass
Use the pass CLI (true) or native git/gpg.
Definition appsettings.h:59
QString pwgenExecutable
Path to the pwgen executable.
Definition appsettings.h:67
QString passStore
Password-store root path.
Definition appsettings.h:60
QString gitExecutable
Path to the git executable.
Definition appsettings.h:65
bool useTrayIcon
Show a system tray icon.
QString passExecutable
Path to the pass executable.
Definition appsettings.h:64
bool useGit
Enable git integration.
QString activeProfile
Name of the active profile.
Definition appsettings.h:56
Stores GPG key info including validity, creation date, and more.
Definition userinfo.h:20
bool enabled
Whether this user/key is enabled for normal use.
Definition userinfo.h:76
QString key_id
Hexadecimal representation of the GnuPG key identifier.
Definition userinfo.h:53
auto isValid() const -> bool
Check whether the key has any usable validity level.
Definition userinfo.h:44
QString name
GPG user ID / full name.
Definition userinfo.h:49
char validity
GnuPG representation of validity. http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg....
Definition userinfo.h:68
QDateTime expiry
Date/time when key expires.
Definition userinfo.h:80
Util: static helpers for the process environment, binary discovery, store paths, URL safety and the l...