QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
firstrunwizard.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#ifndef SRC_FIRSTRUNWIZARD_H_
9#define SRC_FIRSTRUNWIZARD_H_
10
11#include "appsettings.h"
12#include "userinfo.h"
13#include <QList>
14#include <QString>
15#include <QWizard>
16#include <QWizardPage>
17
18class QCheckBox;
19class QLabel;
20class QLineEdit;
21class QListWidget;
22class QPushButton;
23
37class FirstRunWizard : public QWizard {
38 Q_OBJECT
39
40public:
45 explicit FirstRunWizard(QWidget *parent = nullptr);
46
51 auto settings() const -> AppSettings { return m_settings; }
52
66 static auto secretKeys(const QString &gpgExecutable,
67 QString *problem = nullptr) -> QList<UserInfo>;
68
74 static auto isStore(const QString &path) -> bool;
75
84
89 void accept() override;
90
91private:
100 auto initialiseStore(const QString &store) -> bool;
106 auto initialiseGit(const QString &store) -> bool;
107
108 friend class ProgramsWizardPage;
109 friend class KeyWizardPage;
110 friend class StoreWizardPage;
111 friend class DoneWizardPage;
112
120 bool m_detectChoices = false;
123 QList<UserInfo> m_keys;
124};
125
132class ProgramsWizardPage : public QWizardPage {
133 Q_OBJECT
134
135public:
140 explicit ProgramsWizardPage(FirstRunWizard *wizard);
144 void initializePage() override;
149 auto isComplete() const -> bool override;
154 auto validatePage() -> bool override;
155
156private:
158 QLineEdit *m_gpg;
159 QLineEdit *m_git;
160 QLineEdit *m_pass;
161 QCheckBox *m_usePass;
162 QLabel *m_gpgStatus;
163
169 void updateStatus();
170};
171
179class KeyWizardPage : public QWizardPage {
180 Q_OBJECT
181
182public:
187 explicit KeyWizardPage(FirstRunWizard *wizard);
191 void initializePage() override;
198 auto isComplete() const -> bool override;
203 auto validatePage() -> bool override;
204
205private:
207 QListWidget *m_list;
208 QPushButton *m_generate;
209 QLabel *m_status;
210
216 void reload();
221 void generate();
222};
223
233class StoreWizardPage : public QWizardPage {
234 Q_OBJECT
235
236public:
241 explicit StoreWizardPage(FirstRunWizard *wizard);
245 void initializePage() override;
251 auto isComplete() const -> bool override;
256 auto validatePage() -> bool override;
257
258private:
260 QLineEdit *m_path;
261 QCheckBox *m_useGit;
262 QLabel *m_status;
263
268 auto recipients() const -> int;
274 void updateStatus();
275};
276
288class DoneWizardPage : public QWizardPage {
289 Q_OBJECT
290
291public:
296 explicit DoneWizardPage(FirstRunWizard *wizard);
300 void initializePage() override;
305 auto validatePage() -> bool override;
306
307private:
309 QLabel *m_summary;
310 QCheckBox *m_hidePassword;
311 QCheckBox *m_trayIcon;
312};
313
314#endif // SRC_FIRSTRUNWIZARD_H_
AppSettings, the value object holding every flat QtPass setting.
Last page: a summary of what Finish will do and the two preferences worth asking on day one.
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.
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.
Page
Page ids, in order.
@ 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
auto settings() const -> AppSettings
The settings as the pages have edited them so far.
The secret keys gpg knows; a new pair can be generated here. The enabled ones become the recipients o...
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.
Where gpg, pass and git are; gpg is required, the rest optional. A stored path that no longer runs is...
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.
The folder the passwords live in: an existing store is used as-is, a folder without ....
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,...
Plain value-object holding all flat QtPass configuration.
Definition appsettings.h:36
UserInfo, one GPG key as listed by gpg, with the selection flag the recipient dialogs use.