summaryrefslogtreecommitdiffstats
path: root/src/configdialog.h
blob: 4460d4bf4c8b054ea99c867b25bfe8042d702c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef CONFIGDIALOG_H_
#define CONFIGDIALOG_H_

#include "enums.h"
#include "passwordconfiguration.h"

#include <QDialog>

namespace Ui {
struct UserInfo;

class ConfigDialog;
} // namespace Ui

/*!
    \class ConfigDialog
    \brief The ConfigDialog handles the configuration interface.

    This class should also take the handling from the MainWindow class.
*/
class MainWindow;
class QCloseEvent;
class QTableWidgetItem;
class ConfigDialog : public QDialog {
  Q_OBJECT

public:
  explicit ConfigDialog(MainWindow *parent);
  ~ConfigDialog();

  void useSelection(bool useSelection);
  void useAutoclear(bool useAutoclear);
  void useAutoclearPanel(bool useAutoclearPanel);
  QHash<QString, QHash<QString, QString>> getProfiles();
  void wizard();
  void genKey(QString, QDialog *);
  void useTrayIcon(bool useSystray);
  void useGit(bool useGit);
  void useOtp(bool useOtp);
  void useQrencode(bool useQrencode);
  void setPwgenPath(QString);
  void usePwgen(bool usePwgen);
  void setPasswordConfiguration(const PasswordConfiguration &config);
  PasswordConfiguration getPasswordConfiguration();
  void useTemplate(bool useTemplate);

protected:
  void closeEvent(QCloseEvent *event);

private slots:
  void on_accepted();
  void on_autodetectButton_clicked();
  void on_radioButtonNative_clicked();
  void on_radioButtonPass_clicked();
  void on_toolButtonGit_clicked();
  void on_toolButtonGpg_clicked();
  void on_toolButtonPwgen_clicked();
  void on_toolButtonPass_clicked();
  void on_toolButtonStore_clicked();
  void on_comboBoxClipboard_activated(int);
  void on_passwordCharTemplateSelector_activated(int);
  void on_checkBoxSelection_clicked();
  void on_checkBoxAutoclear_clicked();
  void on_checkBoxAutoclearPanel_clicked();
  void on_addButton_clicked();
  void on_deleteButton_clicked();
  void on_checkBoxUseTrayIcon_clicked();
  void on_checkBoxUseGit_clicked();
  void on_checkBoxUsePwgen_clicked();
  void on_checkBoxUseTemplate_clicked();
  void onProfileTableItemChanged(QTableWidgetItem *item);

private:
  QScopedPointer<Ui::ConfigDialog> ui;

  QStringList getSecretKeys();

  void setGitPath(QString);
  void setProfiles(QHash<QString, QHash<QString, QString>>, QString);
  void usePass(bool usePass);

  void setGroupBoxState();
  QString selectExecutable();
  QString selectFolder();
  // QMessageBox::critical with hack to avoid crashes with
  // Qt 5.4.1 when QApplication::exec was not yet called
  void criticalMessage(const QString &title, const QString &text);

  bool isPassOtpAvailable();
  bool isQrencodeAvailable();
  void validate(QTableWidgetItem *item = nullptr);

  MainWindow *mainWindow;
};

#endif // CONFIGDIALOG_H_