GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
KeygenDialog.h
1 
29 #pragma once
30 
31 #include <memory>
32 
33 #include "core/model/GpgGenKeyInfo.h"
34 #include "core/utils/MemoryUtils.h"
35 #include "ui/GpgFrontendUI.h"
36 #include "ui/dialog/GeneralDialog.h"
37 
38 namespace GpgFrontend::UI {
39 
44 class KeyGenDialog : public GeneralDialog {
45  Q_OBJECT
46 
47  public:
55  explicit KeyGenDialog(QWidget* parent = nullptr);
56 
57  signals:
62  void SignalKeyGenerated();
63 
64  private:
70  QGroupBox* create_key_usage_group_box();
71 
77  QGroupBox* create_basic_info_group_box();
78 
83  QRegularExpression re_email_{
84  R"((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]))"};
85 
90  QStringList error_messages_;
92 
93  std::shared_ptr<GenKeyInfo> gen_key_info_ =
94  SecureCreateSharedObject<GenKeyInfo>();
95  std::shared_ptr<GenKeyInfo> gen_subkey_info_ = nullptr;
96 
97  QDialogButtonBox* button_box_;
98  QLabel* error_label_{};
99  QLineEdit* name_edit_{};
100  QLineEdit* email_edit_{};
101  QLineEdit* comment_edit_{};
102  QSpinBox* key_size_spin_box_{};
103  QComboBox* key_type_combo_box_{};
104  QDateTimeEdit* date_edit_{};
105  QCheckBox* expire_check_box_{};
106  QCheckBox* no_pass_phrase_check_box_{};
107  QGroupBox* key_usage_group_box_{};
109  QDateTime max_date_time_;
110  std::vector<QCheckBox*> key_usage_check_boxes_;
111 
116  void generate_key_dialog();
117 
121  void refresh_widgets_state();
122 
127  void set_signal_slot();
128 
136  bool check_email_address(const QString& str);
137 
138  private slots:
139 
145 
150  void slot_key_gen_accept();
151 
157  void slot_encryption_box_changed(int state);
158 
164  void slot_signing_box_changed(int state);
165 
171  void slot_certification_box_changed(int state);
172 
178  void slot_authentication_box_changed(int state);
179 
185  void slot_activated_key_type(int index);
186 };
187 
188 } // namespace GpgFrontend::UI
Definition: GeneralDialog.h:35
Definition: KeygenDialog.h:44
QGroupBox * create_basic_info_group_box()
Create a basic info group box object.
Definition: KeygenDialog.cpp:405
QStringList error_messages_
Definition: KeygenDialog.h:90
void slot_signing_box_changed(int state)
Definition: KeygenDialog.cpp:235
QCheckBox * expire_check_box_
Checkbox, if key should expire.
Definition: KeygenDialog.h:105
QDateTimeEdit * date_edit_
Date edit for expiration date.
Definition: KeygenDialog.h:104
QComboBox * key_type_combo_box_
Combobox for Key type.
Definition: KeygenDialog.h:103
QLineEdit * comment_edit_
Line edit for the keys comment.
Definition: KeygenDialog.h:101
QLineEdit * email_edit_
Line edit for the keys email.
Definition: KeygenDialog.h:100
KeyGenDialog(QWidget *parent=nullptr)
Definition: KeygenDialog.cpp:43
void slot_certification_box_changed(int state)
Definition: KeygenDialog.cpp:243
void refresh_widgets_state()
Definition: KeygenDialog.cpp:286
void slot_expire_box_changed()
Definition: KeygenDialog.cpp:192
QGroupBox * key_usage_group_box_
Definition: KeygenDialog.h:107
QLineEdit * name_edit_
Line edit for the keys name.
Definition: KeygenDialog.h:99
QLabel * error_label_
Label containing error message.
Definition: KeygenDialog.h:98
QGroupBox * create_key_usage_group_box()
Create a key usage group box object.
Definition: KeygenDialog.cpp:194
void slot_authentication_box_changed(int state)
Definition: KeygenDialog.cpp:251
void set_signal_slot()
Set the signal slot object.
Definition: KeygenDialog.cpp:370
QDialogButtonBox * button_box_
Box for standard buttons.
Definition: KeygenDialog.h:97
QSpinBox * key_size_spin_box_
Spinbox for the keys size (in bit)
Definition: KeygenDialog.h:102
std::vector< QCheckBox * > key_usage_check_boxes_
ENCR, SIGN, CERT, AUTH.
Definition: KeygenDialog.h:110
void slot_activated_key_type(int index)
Definition: KeygenDialog.cpp:259
void slot_encryption_box_changed(int state)
Definition: KeygenDialog.cpp:227
bool check_email_address(const QString &str)
Definition: KeygenDialog.cpp:401
void slot_key_gen_accept()
Definition: KeygenDialog.cpp:90
Definition: FileReadTask.cpp:31