Line data Source code
1 : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2 : // SPDX-License-Identifier: GPL-3.0-or-later
3 : #ifndef SRC_CONFIGDIALOG_H_
4 : #define SRC_CONFIGDIALOG_H_
5 :
6 : #include "enums.h"
7 : #include "passwordconfiguration.h"
8 :
9 : #include <QDialog>
10 :
11 : namespace Ui {
12 : struct UserInfo;
13 :
14 : class ConfigDialog;
15 : } // namespace Ui
16 :
17 : /*!
18 : \class ConfigDialog
19 : \brief The ConfigDialog handles the configuration interface.
20 :
21 : This class should also take the handling from the MainWindow class.
22 : */
23 : class MainWindow;
24 : class QCloseEvent;
25 : class QTableWidgetItem;
26 : class ConfigDialog : public QDialog {
27 0 : Q_OBJECT
28 :
29 : public:
30 : explicit ConfigDialog(MainWindow *parent);
31 : ~ConfigDialog();
32 :
33 : void useSelection(bool useSelection);
34 : void useAutoclear(bool useAutoclear);
35 : void useAutoclearPanel(bool useAutoclearPanel);
36 : auto getProfiles() -> QHash<QString, QHash<QString, QString>>;
37 : void wizard();
38 : void genKey(const QString &, QDialog *);
39 : void useTrayIcon(bool useSystray);
40 : void useGit(bool useGit);
41 : void useOtp(bool useOtp);
42 : void useQrencode(bool useQrencode);
43 : void setPwgenPath(const QString &);
44 : void usePwgen(bool usePwgen);
45 : void setPasswordConfiguration(const PasswordConfiguration &config);
46 : auto getPasswordConfiguration() -> PasswordConfiguration;
47 : void useTemplate(bool useTemplate);
48 :
49 : protected:
50 : void closeEvent(QCloseEvent *event);
51 :
52 : private slots:
53 : void on_accepted();
54 : void on_autodetectButton_clicked();
55 : void on_radioButtonNative_clicked();
56 : void on_radioButtonPass_clicked();
57 : void on_toolButtonGit_clicked();
58 : void on_toolButtonGpg_clicked();
59 : void on_toolButtonPwgen_clicked();
60 : void on_toolButtonPass_clicked();
61 : void on_toolButtonStore_clicked();
62 : void on_comboBoxClipboard_activated(int);
63 : void on_passwordCharTemplateSelector_activated(int);
64 : void on_checkBoxSelection_clicked();
65 : void on_checkBoxAutoclear_clicked();
66 : void on_checkBoxAutoclearPanel_clicked();
67 : void on_addButton_clicked();
68 : void on_deleteButton_clicked();
69 : void on_checkBoxUseTrayIcon_clicked();
70 : void on_checkBoxUseGit_clicked();
71 : void on_checkBoxUsePwgen_clicked();
72 : void on_checkBoxUseTemplate_clicked();
73 : void onProfileTableItemChanged(QTableWidgetItem *item);
74 :
75 : private:
76 : QScopedPointer<Ui::ConfigDialog> ui;
77 :
78 : auto getSecretKeys() -> QStringList;
79 :
80 : void setGitPath(const QString &);
81 : void setProfiles(QHash<QString, QHash<QString, QString>>, const QString &);
82 : void usePass(bool usePass);
83 :
84 : void setGroupBoxState();
85 : auto selectExecutable() -> QString;
86 : auto selectFolder() -> QString;
87 : // QMessageBox::critical with hack to avoid crashes with
88 : // Qt 5.4.1 when QApplication::exec was not yet called
89 : void criticalMessage(const QString &title, const QString &text);
90 :
91 : auto isPassOtpAvailable() -> bool;
92 : auto isQrencodeAvailable() -> bool;
93 : void validate(QTableWidgetItem *item = nullptr);
94 :
95 : auto checkGpgExistence() -> bool;
96 : auto checkSecretKeys() -> bool;
97 : auto checkPasswordStore() -> bool;
98 : void handleGpgIdFile();
99 :
100 : MainWindow *mainWindow;
101 : };
102 :
103 : #endif // SRC_CONFIGDIALOG_H_
|