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
58 static auto secretKeys(const QString &gpgExecutable) -> QList<UserInfo>;
59
65 static auto isStore(const QString &path) -> bool;
66
75
80 void accept() override;
81
82private:
91 auto initialiseStore(const QString &store) -> bool;
97 auto initialiseGit(const QString &store) -> bool;
98
99 friend class ProgramsWizardPage;
100 friend class KeyWizardPage;
101 friend class StoreWizardPage;
102 friend class DoneWizardPage;
103
109 QList<UserInfo> m_keys;
110};
111
118class ProgramsWizardPage : public QWizardPage {
119 Q_OBJECT
120
121public:
126 explicit ProgramsWizardPage(FirstRunWizard *wizard);
130 void initializePage() override;
135 auto isComplete() const -> bool override;
140 auto validatePage() -> bool override;
141
142private:
144 QLineEdit *m_gpg;
145 QLineEdit *m_git;
146 QLineEdit *m_pass;
147 QCheckBox *m_usePass;
148 QLabel *m_gpgStatus;
149
155 void updateStatus();
156};
157
165class KeyWizardPage : public QWizardPage {
166 Q_OBJECT
167
168public:
173 explicit KeyWizardPage(FirstRunWizard *wizard);
177 void initializePage() override;
184 auto isComplete() const -> bool override;
189 auto validatePage() -> bool override;
190
191private:
193 QListWidget *m_list;
194 QPushButton *m_generate;
195 QLabel *m_status;
196
202 void reload();
207 void generate();
208};
209
219class StoreWizardPage : public QWizardPage {
220 Q_OBJECT
221
222public:
227 explicit StoreWizardPage(FirstRunWizard *wizard);
231 void initializePage() override;
237 auto isComplete() const -> bool override;
242 auto validatePage() -> bool override;
243
244private:
246 QLineEdit *m_path;
247 QCheckBox *m_useGit;
248 QLabel *m_status;
249
254 auto recipients() const -> int;
260 void updateStatus();
261};
262
274class DoneWizardPage : public QWizardPage {
275 Q_OBJECT
276
277public:
282 explicit DoneWizardPage(FirstRunWizard *wizard);
286 void initializePage() override;
291 auto validatePage() -> bool override;
292
293private:
295 QLabel *m_summary;
296 QCheckBox *m_hidePassword;
297 QCheckBox *m_trayIcon;
298};
299
300#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,...
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
static auto secretKeys(const QString &gpgExecutable) -> QList< UserInfo >
The secret keys gpg lists for gpgExecutable.
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.