diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/settings/GlobalSettingStation.cpp | 64 | ||||
-rw-r--r-- | src/ui/settings/GlobalSettingStation.h | 219 | ||||
-rw-r--r-- | src/ui/settings/SettingsAdvanced.cpp | 94 | ||||
-rw-r--r-- | src/ui/settings/SettingsAdvanced.h | 13 | ||||
-rw-r--r-- | src/ui/settings/SettingsAppearance.cpp | 88 | ||||
-rw-r--r-- | src/ui/settings/SettingsAppearance.h | 42 | ||||
-rw-r--r-- | src/ui/settings/SettingsDialog.cpp | 82 | ||||
-rwxr-xr-x | src/ui/settings/SettingsDialog.h | 64 | ||||
-rw-r--r-- | src/ui/settings/SettingsGeneral.cpp | 81 | ||||
-rw-r--r-- | src/ui/settings/SettingsGeneral.h | 48 | ||||
-rw-r--r-- | src/ui/settings/SettingsKeyServer.cpp | 155 | ||||
-rw-r--r-- | src/ui/settings/SettingsKeyServer.h | 62 | ||||
-rw-r--r-- | src/ui/settings/SettingsNetwork.cpp | 162 | ||||
-rw-r--r-- | src/ui/settings/SettingsNetwork.h | 43 | ||||
-rw-r--r-- | src/ui/settings/SettingsSendMail.cpp | 168 | ||||
-rw-r--r-- | src/ui/settings/SettingsSendMail.h | 71 |
16 files changed, 890 insertions, 566 deletions
diff --git a/src/ui/settings/GlobalSettingStation.cpp b/src/ui/settings/GlobalSettingStation.cpp index 66d3fac9..54e7daaf 100644 --- a/src/ui/settings/GlobalSettingStation.cpp +++ b/src/ui/settings/GlobalSettingStation.cpp @@ -35,26 +35,26 @@ #include <vmime/vmime.hpp> std::unique_ptr<GpgFrontend::UI::GlobalSettingStation> - GpgFrontend::UI::GlobalSettingStation::_instance = nullptr; + GpgFrontend::UI::GlobalSettingStation::instance_ = nullptr; GpgFrontend::UI::GlobalSettingStation& GpgFrontend::UI::GlobalSettingStation::GetInstance() { - if (_instance == nullptr) { - _instance = std::make_unique<GlobalSettingStation>(); + if (instance_ == nullptr) { + instance_ = std::make_unique<GlobalSettingStation>(); } - return *_instance; + return *instance_; } void GpgFrontend::UI::GlobalSettingStation::SyncSettings() noexcept { using namespace libconfig; try { - ui_cfg.writeFile(ui_config_path.string().c_str()); + ui_cfg_.writeFile(ui_config_path_.string().c_str()); LOG(INFO) << _("Updated ui configuration successfully written to") - << ui_config_path; + << ui_config_path_; } catch (const FileIOException& fioex) { LOG(ERROR) << _("I/O error while writing ui configuration file") - << ui_config_path; + << ui_config_path_; } } @@ -64,49 +64,49 @@ GpgFrontend::UI::GlobalSettingStation::GlobalSettingStation() noexcept { el::Loggers::addFlag(el::LoggingFlag::AutoSpacing); - LOG(INFO) << _("App Path") << app_path; - LOG(INFO) << _("App Configure Path") << app_configure_path; - LOG(INFO) << _("App Data Path") << app_data_path; - LOG(INFO) << _("App Log Path") << app_log_path; - LOG(INFO) << _("App Locale Path") << app_locale_path; + LOG(INFO) << _("App Path") << app_path_; + LOG(INFO) << _("App Configure Path") << app_configure_path_; + LOG(INFO) << _("App Data Path") << app_data_path_; + LOG(INFO) << _("App Log Path") << app_log_path_; + LOG(INFO) << _("App Locale Path") << app_locale_path_; - if (!is_directory(app_configure_path)) create_directory(app_configure_path); + if (!is_directory(app_configure_path_)) create_directory(app_configure_path_); - if (!is_directory(app_data_path)) create_directory(app_data_path); + if (!is_directory(app_data_path_)) create_directory(app_data_path_); - if (!is_directory(app_log_path)) create_directory(app_log_path); + if (!is_directory(app_log_path_)) create_directory(app_log_path_); - if (!is_directory(ui_config_dir_path)) create_directory(ui_config_dir_path); + if (!is_directory(ui_config_dir_path_)) create_directory(ui_config_dir_path_); - if (!is_directory(app_secure_path)) create_directory(app_secure_path); + if (!is_directory(app_secure_path_)) create_directory(app_secure_path_); - if (!exists(app_secure_key_path)) { + if (!exists(app_secure_key_path_)) { init_app_secure_key(); } const auto key = - GpgFrontend::read_all_data_in_file(app_secure_key_path.string()); + GpgFrontend::read_all_data_in_file(app_secure_key_path_.string()); hash_key_ = QCryptographicHash::hash(QByteArray::fromStdString(key), QCryptographicHash::Sha256); - if (!exists(app_data_objs_path)) create_directory(app_data_objs_path); + if (!exists(app_data_objs_path_)) create_directory(app_data_objs_path_); - if (!exists(ui_config_path)) { + if (!exists(ui_config_path_)) { try { - this->ui_cfg.writeFile(ui_config_path.string().c_str()); + this->ui_cfg_.writeFile(ui_config_path_.string().c_str()); LOG(INFO) << _("UserInterface configuration successfully written to") - << ui_config_path; + << ui_config_path_; } catch (const FileIOException& fioex) { LOG(ERROR) << _("I/O error while writing UserInterface configuration file") - << ui_config_path; + << ui_config_path_; } } else { try { - this->ui_cfg.readFile(ui_config_path.string().c_str()); + this->ui_cfg_.readFile(ui_config_path_.string().c_str()); LOG(INFO) << _("UserInterface configuration successfully read from") - << ui_config_path; + << ui_config_path_; } catch (const FileIOException& fioex) { LOG(ERROR) << _("I/O error while reading UserInterface configure file"); } catch (const ParseException& pex) { @@ -164,17 +164,17 @@ std::string GpgFrontend::UI::GlobalSettingStation::generate_passphrase( tmp_str.reserve(len); for (int i = 0; i < len; ++i) { - tmp_str += alphanum[dist(mt) % (sizeof(alphanum) - 1)]; + tmp_str += alphanum[dist(mt_) % (sizeof(alphanum) - 1)]; } return tmp_str; } void GpgFrontend::UI::GlobalSettingStation::init_app_secure_key() { - GpgFrontend::write_buffer_to_file(app_secure_key_path.string(), + GpgFrontend::write_buffer_to_file(app_secure_key_path_.string(), generate_passphrase(256)); boost::filesystem::permissions( - app_secure_key_path, + app_secure_key_path_, boost::filesystem::owner_read | boost::filesystem::owner_write); } @@ -199,7 +199,7 @@ std::string GpgFrontend::UI::GlobalSettingStation::SaveDataObj( .toStdString(); } - const auto obj_path = app_data_objs_path / _hash_obj_key; + const auto obj_path = app_data_objs_path_ / _hash_obj_key; QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB, QAESEncryption::Padding::ISO); @@ -220,7 +220,7 @@ GpgFrontend::UI::GlobalSettingStation::GetDataObject(const std::string& _key) { .toHex() .toStdString(); - const auto obj_path = app_data_objs_path / _hash_obj_key; + const auto obj_path = app_data_objs_path_ / _hash_obj_key; if (!boost::filesystem::exists(obj_path)) { return {}; @@ -247,7 +247,7 @@ GpgFrontend::UI::GlobalSettingStation::GetDataObjectByRef( try { auto _hash_obj_key = _ref; - const auto obj_path = app_data_objs_path / _hash_obj_key; + const auto obj_path = app_data_objs_path_ / _hash_obj_key; if (!boost::filesystem::exists(obj_path)) return {}; diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h index f12e56bd..537550a4 100644 --- a/src/ui/settings/GlobalSettingStation.h +++ b/src/ui/settings/GlobalSettingStation.h @@ -31,9 +31,9 @@ #include <openssl/x509.h> -#include <nlohmann/json.hpp> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> +#include <nlohmann/json.hpp> #include "GpgFrontendBuildInstallInfo.h" #include "ui/GpgFrontendUI.h" @@ -45,127 +45,228 @@ class X509Certificate; namespace GpgFrontend::UI { +/** + * @brief + * + */ class GlobalSettingStation : public QObject { Q_OBJECT public: + /** + * @brief Get the Instance object + * + * @return GlobalSettingStation& + */ static GlobalSettingStation& GetInstance(); + /** + * @brief Construct a new Global Setting Station object + * + */ GlobalSettingStation() noexcept; + /** + * @brief Destroy the Global Setting Station object + * + */ ~GlobalSettingStation() noexcept override; - libconfig::Setting& GetUISettings() noexcept { return ui_cfg.getRoot(); } - - [[nodiscard]] boost::filesystem::path GetAppDir() const { return app_path; } - + /** + * @brief + * + * @return libconfig::Setting& + */ + libconfig::Setting& GetUISettings() noexcept { return ui_cfg_.getRoot(); } + + /** + * @brief Get the App Dir object + * + * @return boost::filesystem::path + */ + [[nodiscard]] boost::filesystem::path GetAppDir() const { return app_path_; } + + /** + * @brief Get the Log Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetLogDir() const { - return app_log_path; + return app_log_path_; } + /** + * @brief Get the Standalone Database Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetStandaloneDatabaseDir() const { - auto db_path = app_configure_path / "db"; + auto db_path = app_configure_path_ / "db"; if (!boost::filesystem::exists(db_path)) { boost::filesystem::create_directory(db_path); } return db_path; } + /** + * @brief Get the Standalone Gpg Bin Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetStandaloneGpgBinDir() const { - return app_resource_path / "gpg1.4" / "gpg"; + return app_resource_path_ / "gpg1.4" / "gpg"; } + /** + * @brief Get the Locale Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetLocaleDir() const { - return app_locale_path; + return app_locale_path_; } + /** + * @brief Get the Resource Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetResourceDir() const { - return app_resource_path; + return app_resource_path_; } + /** + * @brief Get the Certs Dir object + * + * @return boost::filesystem::path + */ [[nodiscard]] boost::filesystem::path GetCertsDir() const { - return app_resource_path / "certs"; + return app_resource_path_ / "certs"; } + /** + * @brief Get the Cert Verifier object + * + * @return std::shared_ptr< + * vmime::security::cert::defaultCertificateVerifier> + */ [[nodiscard]] std::shared_ptr< vmime::security::cert::defaultCertificateVerifier> GetCertVerifier() const; + /** + * @brief + * + * @param path + */ void AddRootCert(const boost::filesystem::path& path); + /** + * @brief Get the Root Certs object + * + * @return const std::vector<std::shared_ptr<X509>>& + */ const std::vector<std::shared_ptr<X509>>& GetRootCerts(); + /** + * @brief + * + */ void ResetRootCerts() { root_certs_.clear(); } + /** + * @brief + * + */ void SyncSettings() noexcept; + /** + * @brief + * + * @param _key + * @param value + * @return std::string + */ + std::string SaveDataObj(const std::string& _key, const nlohmann::json& value); + /** + * @brief Get the Data Object object + * + * @param _key + * @return std::optional<nlohmann::json> + */ std::optional<nlohmann::json> GetDataObject(const std::string& _key); + /** + * @brief Get the Data Object By Ref object + * + * @param _ref + * @return std::optional<nlohmann::json> + */ std::optional<nlohmann::json> GetDataObjectByRef(const std::string& _ref); private: - // Program Location - boost::filesystem::path app_path = qApp->applicationDirPath().toStdString(); - - // Program Data Location - boost::filesystem::path app_data_path = + boost::filesystem::path app_path_ = + qApp->applicationDirPath().toStdString(); ///< Program Location + boost::filesystem::path app_data_path_ = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) - .toStdString(); - - // Program Data Location - boost::filesystem::path app_log_path = app_data_path / "logs"; - - // object storage path - boost::filesystem::path app_data_objs_path = app_data_path / "objs"; + .toStdString(); ///< Program Data Location + boost::filesystem::path app_log_path_ = + app_data_path_ / "logs"; ///< Program Data Location + boost::filesystem::path app_data_objs_path_ = + app_data_path_ / "objs"; ///< Object storage path #ifdef LINUX_INSTALL_BUILD - // Program Data Location - boost::filesystem::path app_resource_path = - boost::filesystem::path(APP_LOCALSTATE_PATH) / "gpgfrontend"; + boost::filesystem::path app_resource_path_ = + boost::filesystem::path(APP_LOCALSTATE_PATH) / + "gpgfrontend"; ///< Program Data Location #else - // Program Data Location - boost::filesystem::path app_resource_path = RESOURCE_DIR_BOOST_PATH(app_path); + boost::filesystem::path app_resource_path_ = + RESOURCE_DIR_BOOST_PATH(app_path_); ///< Program Data Location #endif #ifdef LINUX_INSTALL_BUILD - // Program Data Location - boost::filesystem::path app_locale_path = std::string(APP_LOCALE_PATH); + boost::filesystem::path app_locale_path_ = + std::string(APP_LOCALE_PATH); ///< Program Data Location #else - // Program Data Location - boost::filesystem::path app_locale_path = app_resource_path / "locales"; + boost::filesystem::path app_locale_path_ = + app_resource_path_ / "locales"; ///< Program Data Location #endif - // Program Configure Location - boost::filesystem::path app_configure_path = + boost::filesystem::path app_configure_path_ = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) - .toStdString(); - - boost::filesystem::path app_secure_path = app_configure_path / "secure"; - - boost::filesystem::path app_secure_key_path = app_secure_path / "app.key"; - - // Configure File Directory Location - boost::filesystem::path ui_config_dir_path = - app_configure_path / "UserInterface"; - - // UI Configure File Location - boost::filesystem::path ui_config_path = ui_config_dir_path / "ui.cfg"; - - libconfig::Config ui_cfg; - - std::vector<std::shared_ptr<X509>> root_certs_; - - std::random_device rd; - - std::mt19937 mt; - - QByteArray hash_key_; - - static std::unique_ptr<GlobalSettingStation> _instance; - + .toStdString(); ///< Program Configure Location + boost::filesystem::path app_secure_path_ = + app_configure_path_ / + "secure"; ///< Where sensitive information is stored + boost::filesystem::path app_secure_key_path_ = + app_secure_path_ / "app.key"; ///< + boost::filesystem::path ui_config_dir_path_ = + app_configure_path_ / + "UserInterface"; ///< Configure File Directory Location + boost::filesystem::path ui_config_path_ = + ui_config_dir_path_ / "ui.cfg"; ///< UI Configure File Location + + libconfig::Config ui_cfg_; ///< + std::vector<std::shared_ptr<X509>> root_certs_; ///< + std::random_device rd_; ///< + std::mt19937 mt_; ///< + QByteArray hash_key_; ///< + + static std::unique_ptr<GlobalSettingStation> instance_; ///< + + /** + * @brief + * + */ void init_app_secure_key(); + /** + * @brief + * + * @param len + * @return std::string + */ std::string generate_passphrase(int len); }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/settings/SettingsAdvanced.cpp index 3f06893b..093e34a0 100644 --- a/src/ui/settings/SettingsAdvanced.cpp +++ b/src/ui/settings/SettingsAdvanced.cpp @@ -28,49 +28,77 @@ #include "SettingsAdvanced.h" +#include "ui/settings/GlobalSettingStation.h" + namespace GpgFrontend::UI { -AdvancedTab::AdvancedTab(QWidget* parent) - : QWidget(parent), - appPath(qApp->applicationDirPath()), - settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini", - QSettings::IniFormat) { - /***************************************** - * Steganography Box - *****************************************/ - auto* steganoBox = new QGroupBox(_("Show Steganography Options")); - auto* steganoBoxLayout = new QHBoxLayout(); - steganoCheckBox = new QCheckBox(_("Show Steganographic Options."), this); - steganoBoxLayout->addWidget(steganoCheckBox); - steganoBox->setLayout(steganoBoxLayout); +AdvancedTab::AdvancedTab(QWidget* parent) : QWidget(parent) { + auto* stegano_box = new QGroupBox(_("Show Steganography Options")); + auto* stegano_box_layout = new QHBoxLayout(); + stegano_check_box_ = new QCheckBox(_("Show Steganography Options."), this); + stegano_box_layout->addWidget(stegano_check_box_); + stegano_box->setLayout(stegano_box_layout); - auto* pubkeyExchangeBox = new QGroupBox(_("Pubkey Exchange")); - auto* pubkeyExchangeBoxLayout = new QHBoxLayout(); - autoPubkeyExchangeCheckBox = new QCheckBox(_("Auto Pubkey Exchange"), this); - pubkeyExchangeBoxLayout->addWidget(autoPubkeyExchangeCheckBox); - pubkeyExchangeBox->setLayout(pubkeyExchangeBoxLayout); + auto* pubkey_exchange_box = new QGroupBox(_("Pubkey Exchange")); + auto* pubkey_exchange_box_layout = new QHBoxLayout(); + auto_pubkey_exchange_check_box_ = + new QCheckBox(_("Auto Pubkey Exchange"), this); + pubkey_exchange_box_layout->addWidget(auto_pubkey_exchange_check_box_); + pubkey_exchange_box->setLayout(pubkey_exchange_box_layout); - auto* mainLayout = new QVBoxLayout; - mainLayout->addWidget(steganoBox); - mainLayout->addWidget(pubkeyExchangeBox); - setSettings(); - mainLayout->addStretch(1); - setLayout(mainLayout); + auto* main_layout = new QVBoxLayout; + main_layout->addWidget(stegano_box); + main_layout->addWidget(pubkey_exchange_box); + SetSettings(); + main_layout->addStretch(1); + setLayout(main_layout); } -void AdvancedTab::setSettings() { - if (settings.value("advanced/steganography").toBool()) { - steganoCheckBox->setCheckState(Qt::Checked); +void AdvancedTab::SetSettings() { + auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + try { + bool stegano_checked = settings.lookup("advanced.stegano_checked"); + if (stegano_checked) stegano_check_box_->setCheckState(Qt::Checked); + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") << _("stegano_checked"); } - if (settings.value("advanced/autoPubkeyExchange").toBool()) { - autoPubkeyExchangeCheckBox->setCheckState(Qt::Checked); + + try { + bool auto_pubkey_exchange_checked = + settings.lookup("advanced.auto_pubkey_exchange_checked"); + if (auto_pubkey_exchange_checked) + auto_pubkey_exchange_check_box_->setCheckState(Qt::Checked); + } catch (...) { + LOG(ERROR) << _("Setting Operation Error") + << _("auto_pubkey_exchange_checked"); } } -void AdvancedTab::applySettings() { - settings.setValue("advanced/steganography", steganoCheckBox->isChecked()); - settings.setValue("advanced/autoPubkeyExchange", - autoPubkeyExchangeCheckBox->isChecked()); +void AdvancedTab::ApplySettings() { + auto& settings = + GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings(); + + if (!settings.exists("advanced") || + settings.lookup("advanced").getType() != libconfig::Setting::TypeGroup) + settings.add("advanced", libconfig::Setting::TypeGroup); + + auto& advanced = settings["advanced"]; + + if (!advanced.exists("stegano_checked")) + advanced.add("stegano_checked", libconfig::Setting::TypeBoolean) = + stegano_check_box_->isChecked(); + else { + advanced["stegano_checked"] = stegano_check_box_->isChecked(); + } + + if (!advanced.exists("auto_pubkey_exchange_checked")) + advanced.add("auto_pubkey_exchange_checked", + libconfig::Setting::TypeBoolean) = + auto_pubkey_exchange_check_box_->isChecked(); + else { + advanced["auto_pubkey_exchange_checked"] = + auto_pubkey_exchange_check_box_->isChecked(); + } } } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/settings/SettingsAdvanced.h index d53e36bc..c1a3d5a6 100644 --- a/src/ui/settings/SettingsAdvanced.h +++ b/src/ui/settings/SettingsAdvanced.h @@ -38,20 +38,17 @@ class AdvancedTab : public QWidget { public: explicit AdvancedTab(QWidget* parent = nullptr); - void setSettings(); + void SetSettings(); - void applySettings(); + void ApplySettings(); private: - QString appPath; - QSettings settings; - - QCheckBox* steganoCheckBox; - QCheckBox* autoPubkeyExchangeCheckBox; + QCheckBox* stegano_check_box_; + QCheckBox* auto_pubkey_exchange_check_box_; signals: - void signalRestartNeeded(bool needed); + void SignalRestartNeeded(bool needed); }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/settings/SettingsAppearance.cpp index 471aed77..c9288ce6 100644 --- a/src/ui/settings/SettingsAppearance.cpp +++ b/src/ui/settings/SettingsAppearance.cpp @@ -37,19 +37,19 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { * Icon-Size-Box *****************************************/ auto* iconSizeBox = new QGroupBox(_("Icon Size")); - iconSizeGroup = new QButtonGroup(); - iconSizeSmall = new QRadioButton(_("small")); - iconSizeMedium = new QRadioButton(_("medium")); - iconSizeLarge = new QRadioButton(_("large")); + icon_size_group_ = new QButtonGroup(); + icon_size_small_ = new QRadioButton(_("small")); + icon_size_medium_ = new QRadioButton(_("medium")); + icon_size_large_ = new QRadioButton(_("large")); - iconSizeGroup->addButton(iconSizeSmall, 1); - iconSizeGroup->addButton(iconSizeMedium, 2); - iconSizeGroup->addButton(iconSizeLarge, 3); + icon_size_group_->addButton(icon_size_small_, 1); + icon_size_group_->addButton(icon_size_medium_, 2); + icon_size_group_->addButton(icon_size_large_, 3); auto* iconSizeBoxLayout = new QHBoxLayout(); - iconSizeBoxLayout->addWidget(iconSizeSmall); - iconSizeBoxLayout->addWidget(iconSizeMedium); - iconSizeBoxLayout->addWidget(iconSizeLarge); + iconSizeBoxLayout->addWidget(icon_size_small_); + iconSizeBoxLayout->addWidget(icon_size_medium_); + iconSizeBoxLayout->addWidget(icon_size_large_); iconSizeBox->setLayout(iconSizeBoxLayout); @@ -57,19 +57,19 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { * Icon-Style-Box *****************************************/ auto* iconStyleBox = new QGroupBox(_("Icon Style")); - iconStyleGroup = new QButtonGroup(); - iconTextButton = new QRadioButton(_("just text")); - iconIconsButton = new QRadioButton(_("just icons")); - iconAllButton = new QRadioButton(_("text and icons")); + icon_style_group_ = new QButtonGroup(); + icon_text_button_ = new QRadioButton(_("just text")); + icon_icons_button_ = new QRadioButton(_("just icons")); + icon_all_button_ = new QRadioButton(_("text and icons")); - iconStyleGroup->addButton(iconTextButton, 1); - iconStyleGroup->addButton(iconIconsButton, 2); - iconStyleGroup->addButton(iconAllButton, 3); + icon_style_group_->addButton(icon_text_button_, 1); + icon_style_group_->addButton(icon_icons_button_, 2); + icon_style_group_->addButton(icon_all_button_, 3); auto* iconStyleBoxLayout = new QHBoxLayout(); - iconStyleBoxLayout->addWidget(iconTextButton); - iconStyleBoxLayout->addWidget(iconIconsButton); - iconStyleBoxLayout->addWidget(iconAllButton); + iconStyleBoxLayout->addWidget(icon_text_button_); + iconStyleBoxLayout->addWidget(icon_icons_button_); + iconStyleBoxLayout->addWidget(icon_all_button_); iconStyleBox->setLayout(iconStyleBoxLayout); @@ -78,9 +78,9 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { *****************************************/ auto* windowSizeBox = new QGroupBox(_("Window State")); auto* windowSizeBoxLayout = new QHBoxLayout(); - windowSizeCheckBox = + window_size_check_box_ = new QCheckBox(_("Save window size and position on exit."), this); - windowSizeBoxLayout->addWidget(windowSizeCheckBox); + windowSizeBoxLayout->addWidget(window_size_check_box_); windowSizeBox->setLayout(windowSizeBoxLayout); /***************************************** @@ -89,12 +89,12 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { auto* infoBoardBox = new QGroupBox(_("Information Board")); auto* infoBoardLayout = new QHBoxLayout(); - infoBoardFontSizeSpin = new QSpinBox(); - infoBoardFontSizeSpin->setRange(9, 18); - infoBoardFontSizeSpin->setValue(10); - infoBoardFontSizeSpin->setSingleStep(1); + info_board_font_size_spin_ = new QSpinBox(); + info_board_font_size_spin_->setRange(9, 18); + info_board_font_size_spin_->setValue(10); + info_board_font_size_spin_->setSingleStep(1); infoBoardLayout->addWidget(new QLabel(_("Font Size in Information Board"))); - infoBoardLayout->addWidget(infoBoardFontSizeSpin); + infoBoardLayout->addWidget(info_board_font_size_spin_); infoBoardBox->setLayout(infoBoardLayout); auto* mainLayout = new QVBoxLayout; @@ -103,7 +103,7 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { mainLayout->addWidget(windowSizeBox); mainLayout->addWidget(infoBoardBox); mainLayout->addStretch(1); - setSettings(); + SetSettings(); setLayout(mainLayout); } @@ -112,7 +112,7 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) { * and set the buttons and checkboxes * appropriately **********************************/ -void AppearanceTab::setSettings() { +void AppearanceTab::SetSettings() { auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); try { @@ -123,13 +123,13 @@ void AppearanceTab::setSettings() { switch (icon_size.height()) { case 12: - iconSizeSmall->setChecked(true); + icon_size_small_->setChecked(true); break; case 24: - iconSizeMedium->setChecked(true); + icon_size_medium_->setChecked(true); break; case 32: - iconSizeLarge->setChecked(true); + icon_size_large_->setChecked(true); break; } @@ -144,13 +144,13 @@ void AppearanceTab::setSettings() { switch (icon_style) { case Qt::ToolButtonTextOnly: - iconTextButton->setChecked(true); + icon_text_button_->setChecked(true); break; case Qt::ToolButtonIconOnly: - iconIconsButton->setChecked(true); + icon_icons_button_->setChecked(true); break; case Qt::ToolButtonTextUnderIcon: - iconAllButton->setChecked(true); + icon_all_button_->setChecked(true); break; default: break; @@ -163,7 +163,7 @@ void AppearanceTab::setSettings() { // Window Save and Position try { bool window_save = settings.lookup("window.window_save"); - if (window_save) windowSizeCheckBox->setCheckState(Qt::Checked); + if (window_save) window_size_check_box_->setCheckState(Qt::Checked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("window_save"); @@ -173,7 +173,7 @@ void AppearanceTab::setSettings() { try { int info_font_size = settings.lookup("window.info_font_size"); if (info_font_size < 9 || info_font_size > 18) info_font_size = 10; - infoBoardFontSizeSpin->setValue(info_font_size); + info_board_font_size_spin_->setValue(info_font_size); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("info_font_size"); } @@ -183,7 +183,7 @@ void AppearanceTab::setSettings() { * get the values of the buttons and * write them to settings-file *************************************/ -void AppearanceTab::applySettings() { +void AppearanceTab::ApplySettings() { auto& settings = GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings(); @@ -194,7 +194,7 @@ void AppearanceTab::applySettings() { auto& window = settings["window"]; int icon_size = 24; - switch (iconSizeGroup->checkedId()) { + switch (icon_size_group_->checkedId()) { case 1: icon_size = 12; break; @@ -217,7 +217,7 @@ void AppearanceTab::applySettings() { } auto icon_style = Qt::ToolButtonTextUnderIcon; - switch (iconStyleGroup->checkedId()) { + switch (icon_style_group_->checkedId()) { case 1: icon_style = Qt::ToolButtonTextOnly; break; @@ -237,16 +237,16 @@ void AppearanceTab::applySettings() { if (!window.exists("window_save")) { window.add("window_save", libconfig::Setting::TypeBoolean) = - windowSizeCheckBox->isChecked(); + window_size_check_box_->isChecked(); } else { - window["window_save"] = windowSizeCheckBox->isChecked(); + window["window_save"] = window_size_check_box_->isChecked(); } if (!window.exists("info_font_size")) { window.add("info_font_size", libconfig::Setting::TypeBoolean) = - infoBoardFontSizeSpin->value(); + info_board_font_size_spin_->value(); } else { - window["info_font_size"] = infoBoardFontSizeSpin->value(); + window["info_font_size"] = info_board_font_size_spin_->value(); } } diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/settings/SettingsAppearance.h index 882f5dc8..7110d992 100644 --- a/src/ui/settings/SettingsAppearance.h +++ b/src/ui/settings/SettingsAppearance.h @@ -37,26 +37,44 @@ class AppearanceTab : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new Appearance Tab object + * + * @param parent + */ explicit AppearanceTab(QWidget* parent = nullptr); - void setSettings(); + /** + * @brief Set the Settings object + * + */ + void SetSettings(); - void applySettings(); + /** + * @brief + * + */ + void ApplySettings(); private: - QButtonGroup* iconStyleGroup; - QRadioButton* iconSizeSmall; - QRadioButton* iconSizeMedium; - QRadioButton* iconSizeLarge; - QButtonGroup* iconSizeGroup; - QRadioButton* iconTextButton; - QRadioButton* iconIconsButton; - QRadioButton* iconAllButton; - QSpinBox* infoBoardFontSizeSpin; - QCheckBox* windowSizeCheckBox; + QButtonGroup* icon_style_group_; ///< + QRadioButton* icon_size_small_; ///< + QRadioButton* icon_size_medium_; ///< + QRadioButton* icon_size_large_; ///< + QButtonGroup* icon_size_group_; ///< + QRadioButton* icon_text_button_; ///< + QRadioButton* icon_icons_button_; ///< + QRadioButton* icon_all_button_; ///< + QSpinBox* info_board_font_size_spin_; ///< + QCheckBox* window_size_check_box_; ///< signals: + /** + * @brief + * + * @param needed + */ void signalRestartNeeded(bool needed); }; diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp index 8092776d..ceaf089b 100644 --- a/src/ui/settings/SettingsDialog.cpp +++ b/src/ui/settings/SettingsDialog.cpp @@ -42,86 +42,88 @@ namespace GpgFrontend::UI { SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) { - tabWidget = new QTabWidget(); - generalTab = new GeneralTab(); - appearanceTab = new AppearanceTab(); + tab_widget_ = new QTabWidget(); + general_tab_ = new GeneralTab(); + appearance_tab_ = new AppearanceTab(); #ifdef SMTP_SUPPORT - sendMailTab = new SendMailTab(); + send_mail_tab_ = new SendMailTab(); #endif - keyserverTab = new KeyserverTab(); - networkTab = new NetworkTab(); + key_server_tab_ = new KeyserverTab(); + network_tab_ = new NetworkTab(); #ifdef ADVANCED_SUPPORT advancedTab = new AdvancedTab; #endif - tabWidget->addTab(generalTab, _("General")); - tabWidget->addTab(appearanceTab, _("Appearance")); + tab_widget_->addTab(general_tab_, _("General")); + tab_widget_->addTab(appearance_tab_, _("Appearance")); #ifdef SMTP_SUPPORT - tabWidget->addTab(sendMailTab, _("Send Mail")); + tab_widget_->addTab(send_mail_tab_, _("Send Mail")); #endif - tabWidget->addTab(keyserverTab, _("Key Server")); + tab_widget_->addTab(key_server_tab_, _("Key Server")); // tabWidget->addTab(gpgPathsTab, _("Gpg paths")); - tabWidget->addTab(networkTab, _("Network")); + tab_widget_->addTab(network_tab_, _("Network")); #ifdef ADVANCED_SUPPORT tabWidget->addTab(advancedTab, _("Advanced")); #endif - buttonBox = + button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(button_box_, SIGNAL(accepted()), this, SLOT(SlotAccept())); + connect(button_box_, SIGNAL(rejected()), this, SLOT(reject())); auto* mainLayout = new QVBoxLayout; - mainLayout->addWidget(tabWidget); + mainLayout->addWidget(tab_widget_); mainLayout->stretch(0); - mainLayout->addWidget(buttonBox); + mainLayout->addWidget(button_box_); mainLayout->stretch(0); setLayout(mainLayout); setWindowTitle(_("Settings")); // slots for handling the restartneeded member - this->slotSetRestartNeeded(false); - connect(generalTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); - connect(appearanceTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); + this->slot_set_restart_needed(false); + connect(general_tab_, SIGNAL(SignalRestartNeeded(bool)), this, + SLOT(slot_set_restart_needed(bool))); + connect(appearance_tab_, SIGNAL(SignalRestartNeeded(bool)), this, + SLOT(slot_set_restart_needed(bool))); #ifdef SMTP_SUPPORT - connect(sendMailTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); + connect(send_mail_tab_, SIGNAL(SignalRestartNeeded(bool)), this, + SLOT(slot_set_restart_needed(bool))); #endif - connect(keyserverTab, SIGNAL(signalRestartNeeded(bool)), this, - SLOT(slotSetRestartNeeded(bool))); + connect(key_server_tab_, SIGNAL(SignalRestartNeeded(bool)), this, + SLOT(slot_set_restart_needed(bool))); #ifdef ADVANCED_SUPPORT connect(advancedTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool))); #endif - connect(this, SIGNAL(signalRestartNeeded(bool)), parent, - SLOT(slotSetRestartNeeded(bool))); + connect(this, SIGNAL(SignalRestartNeeded(bool)), parent, + SLOT(slot_set_restart_needed(bool))); this->setMinimumSize(480, 680); this->adjustSize(); this->show(); } -bool SettingsDialog::getRestartNeeded() const { return this->restartNeeded; } +bool SettingsDialog::get_restart_needed() const { + return this->restart_needed_; +} -void SettingsDialog::slotSetRestartNeeded(bool needed) { - this->restartNeeded = needed; +void SettingsDialog::slot_set_restart_needed(bool needed) { + this->restart_needed_ = needed; } -void SettingsDialog::slotAccept() { +void SettingsDialog::SlotAccept() { LOG(INFO) << "Called"; - generalTab->applySettings(); + general_tab_->ApplySettings(); #ifdef SMTP_SUPPORT - sendMailTab->applySettings(); + send_mail_tab_->ApplySettings(); #endif - appearanceTab->applySettings(); - keyserverTab->applySettings(); - networkTab->applySettings(); + appearance_tab_->ApplySettings(); + key_server_tab_->ApplySettings(); + network_tab_->ApplySettings(); #ifdef ADVANCED_SUPPORT advancedTab->applySettings(); #endif @@ -131,14 +133,14 @@ void SettingsDialog::slotAccept() { // write settings to filesystem GlobalSettingStation::GetInstance().SyncSettings(); - LOG(INFO) << "restart needed" << getRestartNeeded(); - if (getRestartNeeded()) { - emit signalRestartNeeded(true); + LOG(INFO) << "restart needed" << get_restart_needed(); + if (get_restart_needed()) { + emit SignalRestartNeeded(true); } close(); } -QHash<QString, QString> SettingsDialog::listLanguages() { +QHash<QString, QString> SettingsDialog::ListLanguages() { QHash<QString, QString> languages; languages.insert(QString(), _("System Default")); diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/settings/SettingsDialog.h index 3d6a622a..000e6599 100755 --- a/src/ui/settings/SettingsDialog.h +++ b/src/ui/settings/SettingsDialog.h @@ -48,43 +48,77 @@ class NetworkTab; class AdvancedTab; #endif +/** + * @brief + * + */ class SettingsDialog : public QDialog { Q_OBJECT public: + /** + * @brief Construct a new Settings Dialog object + * + * @param parent + */ explicit SettingsDialog(QWidget* parent = nullptr); - GeneralTab* generalTab; + GeneralTab* general_tab_; ///< #ifdef SMTP_SUPPORT - SendMailTab* sendMailTab; + SendMailTab* send_mail_tab_; ///< #endif - AppearanceTab* appearanceTab; - KeyserverTab* keyserverTab; - NetworkTab* networkTab; + AppearanceTab* appearance_tab_; ///< + KeyserverTab* key_server_tab_; ///< + NetworkTab* network_tab_; ///< #ifdef ADVANCED_SUPPORT - AdvancedTab* advancedTab; + AdvancedTab* advanced_tab_; ///< #endif - static QHash<QString, QString> listLanguages(); + /** + * @brief + * + * @return QHash<QString, QString> + */ + static QHash<QString, QString> ListLanguages(); public slots: - void slotAccept(); + /** + * @brief + * + */ + void SlotAccept(); signals: - void signalRestartNeeded(bool needed); + /** + * @brief + * + * @param needed + */ + void SignalRestartNeeded(bool needed); private: - QTabWidget* tabWidget; - QDialogButtonBox* buttonBox; - bool restartNeeded{}; - - bool getRestartNeeded() const; + QTabWidget* tab_widget_; ///< + QDialogButtonBox* button_box_; ///< + bool restart_needed_{}; ///< + + /** + * @brief Get the Restart Needed object + * + * @return true + * @return false + */ + bool get_restart_needed() const; private slots: - void slotSetRestartNeeded(bool needed); + /** + * @brief + * + * @param needed + */ + void slot_set_restart_needed(bool needed); }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp index f190b983..5b697fa0 100644 --- a/src/ui/settings/SettingsGeneral.cpp +++ b/src/ui/settings/SettingsGeneral.cpp @@ -38,39 +38,39 @@ namespace GpgFrontend::UI { GeneralTab::GeneralTab(QWidget* parent) - : QWidget(parent), ui(std::make_shared<Ui_GeneralSettings>()) { - ui->setupUi(this); + : QWidget(parent), ui_(std::make_shared<Ui_GeneralSettings>()) { + ui_->setupUi(this); - ui->saveCheckedKeysBox->setTitle(_("Save Checked Keys")); - ui->saveCheckedKeysCheckBox->setText( + ui_->saveCheckedKeysBox->setTitle(_("Save Checked Keys")); + ui_->saveCheckedKeysCheckBox->setText( _("Save checked private keys on exit and restore them on next start.")); - ui->longerKeyExpirationDateBox->setTitle(_("Longer Key Expiration Date")); - ui->longerKeyExpirationDateCheckBox->setText( + ui_->longerKeyExpirationDateBox->setTitle(_("Longer Key Expiration Date")); + ui_->longerKeyExpirationDateCheckBox->setText( _("Unlock key expiration date setting up to 30 years.")); - ui->importConfirmationBox->setTitle(_("Confirm drag'n'drop key import")); - ui->importConfirmationCheckBox->setText( + ui_->importConfirmationBox->setTitle(_("Confirm drag'n'drop key import")); + ui_->importConfirmationCheckBox->setText( _("Import files dropped on the Key List without confirmation.")); - ui->asciiModeBox->setTitle(_("ASCII Mode")); - ui->asciiModeCheckBox->setText( + ui_->asciiModeBox->setTitle(_("ASCII Mode")); + ui_->asciiModeCheckBox->setText( _("ASCII encoding is not used when file encrypting and " "signing.")); - ui->langBox->setTitle(_("Language")); - ui->langNoteLabel->setText( + ui_->langBox->setTitle(_("Language")); + ui_->langNoteLabel->setText( "<b>" + QString(_("NOTE")) + _(": ") + "</b>" + _("GpgFrontend will restart automatically if you change the language!")); #ifdef MULTI_LANG_SUPPORT - lang = SettingsDialog::listLanguages(); - for (const auto& l : lang) { - ui->langSelectBox->addItem(l); + lang_ = SettingsDialog::ListLanguages(); + for (const auto& l : lang_) { + ui_->langSelectBox->addItem(l); } - connect(ui->langSelectBox, SIGNAL(currentIndexChanged(int)), this, - SLOT(slotLanguageChanged())); + connect(ui_->langSelectBox, SIGNAL(currentIndexChanged(int)), this, + SLOT(slot_language_changed())); #endif - setSettings(); + SetSettings(); } /********************************** @@ -78,12 +78,12 @@ GeneralTab::GeneralTab(QWidget* parent) * and set the buttons and checkboxes * appropriately **********************************/ -void GeneralTab::setSettings() { +void GeneralTab::SetSettings() { auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); try { bool save_key_checked = settings.lookup("general.save_key_checked"); if (save_key_checked) - ui->saveCheckedKeysCheckBox->setCheckState(Qt::Checked); + ui_->saveCheckedKeysCheckBox->setCheckState(Qt::Checked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("save_key_checked"); } @@ -93,7 +93,7 @@ void GeneralTab::setSettings() { settings.lookup("general.longer_expiration_date"); LOG(INFO) << "longer_expiration_date" << longer_expiration_date; if (longer_expiration_date) - ui->longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked); + ui_->longerKeyExpirationDateCheckBox->setCheckState(Qt::Checked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("longer_expiration_date"); } @@ -101,13 +101,13 @@ void GeneralTab::setSettings() { #ifdef MULTI_LANG_SUPPORT try { std::string lang_key = settings.lookup("general.lang"); - QString lang_value = lang.value(lang_key.c_str()); + QString lang_value = lang_.value(lang_key.c_str()); LOG(INFO) << "lang settings current" << lang_value.toStdString(); - if (!lang.empty()) { - ui->langSelectBox->setCurrentIndex( - ui->langSelectBox->findText(lang_value)); + if (!lang_.empty()) { + ui_->langSelectBox->setCurrentIndex( + ui_->langSelectBox->findText(lang_value)); } else { - ui->langSelectBox->setCurrentIndex(0); + ui_->langSelectBox->setCurrentIndex(0); } } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("lang"); @@ -118,7 +118,7 @@ void GeneralTab::setSettings() { bool confirm_import_keys = settings.lookup("general.confirm_import_keys"); LOG(INFO) << "confirm_import_keys" << confirm_import_keys; if (confirm_import_keys) - ui->importConfirmationCheckBox->setCheckState(Qt::Checked); + ui_->importConfirmationCheckBox->setCheckState(Qt::Checked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("confirm_import_keys"); } @@ -128,7 +128,7 @@ void GeneralTab::setSettings() { settings.lookup("general.non_ascii_when_export"); LOG(INFO) << "non_ascii_when_export" << non_ascii_when_export; if (non_ascii_when_export) - ui->asciiModeCheckBox->setCheckState(Qt::Checked); + ui_->asciiModeCheckBox->setCheckState(Qt::Checked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export"); } @@ -138,7 +138,7 @@ void GeneralTab::setSettings() { * get the values of the buttons and * write them to settings-file *************************************/ -void GeneralTab::applySettings() { +void GeneralTab::ApplySettings() { auto& settings = GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings(); @@ -150,46 +150,47 @@ void GeneralTab::applySettings() { if (!general.exists("longer_expiration_date")) general.add("longer_expiration_date", libconfig::Setting::TypeBoolean) = - ui->longerKeyExpirationDateCheckBox->isChecked(); + ui_->longerKeyExpirationDateCheckBox->isChecked(); else { general["longer_expiration_date"] = - ui->longerKeyExpirationDateCheckBox->isChecked(); + ui_->longerKeyExpirationDateCheckBox->isChecked(); } if (!general.exists("save_key_checked")) general.add("save_key_checked", libconfig::Setting::TypeBoolean) = - ui->saveCheckedKeysCheckBox->isChecked(); + ui_->saveCheckedKeysCheckBox->isChecked(); else { - general["save_key_checked"] = ui->saveCheckedKeysCheckBox->isChecked(); + general["save_key_checked"] = ui_->saveCheckedKeysCheckBox->isChecked(); } if (!general.exists("non_ascii_when_export")) general.add("non_ascii_when_export", libconfig::Setting::TypeBoolean) = - ui->asciiModeCheckBox->isChecked(); + ui_->asciiModeCheckBox->isChecked(); else { - general["non_ascii_when_export"] = ui->asciiModeCheckBox->isChecked(); + general["non_ascii_when_export"] = ui_->asciiModeCheckBox->isChecked(); } #ifdef MULTI_LANG_SUPPORT if (!general.exists("lang")) general.add("lang", libconfig::Setting::TypeBoolean) = - lang.key(ui->langSelectBox->currentText()).toStdString(); + lang_.key(ui_->langSelectBox->currentText()).toStdString(); else { - general["lang"] = lang.key(ui->langSelectBox->currentText()).toStdString(); + general["lang"] = + lang_.key(ui_->langSelectBox->currentText()).toStdString(); } #endif if (!general.exists("confirm_import_keys")) general.add("confirm_import_keys", libconfig::Setting::TypeBoolean) = - ui->importConfirmationCheckBox->isChecked(); + ui_->importConfirmationCheckBox->isChecked(); else { general["confirm_import_keys"] = - ui->importConfirmationCheckBox->isChecked(); + ui_->importConfirmationCheckBox->isChecked(); } } #ifdef MULTI_LANG_SUPPORT -void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); } +void GeneralTab::slot_language_changed() { emit SignalRestartNeeded(true); } #endif } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h index c20ca459..b3e7d904 100644 --- a/src/ui/settings/SettingsGeneral.h +++ b/src/ui/settings/SettingsGeneral.h @@ -36,37 +36,63 @@ class Ui_GeneralSettings; namespace GpgFrontend::UI { class KeyList; +/** + * @brief + * + */ class GeneralTab : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new General Tab object + * + * @param parent + */ explicit GeneralTab(QWidget* parent = nullptr); - void setSettings(); + /** + * @brief Set the Settings object + * + */ + void SetSettings(); - void applySettings(); + /** + * @brief + * + */ + void ApplySettings(); + + signals: + + /** + * @brief + * + * @param needed + */ + void SignalRestartNeeded(bool needed); private: - std::shared_ptr<Ui_GeneralSettings> ui; + std::shared_ptr<Ui_GeneralSettings> ui_; ///< #ifdef MULTI_LANG_SUPPORT - QHash<QString, QString> lang; + QHash<QString, QString> lang_; ///< #endif - std::vector<std::string> keyIdsList; + std::vector<std::string> key_ids_list_; ///< - KeyList* mKeyList{}; + KeyList* m_key_list_{}; ///< private slots: #ifdef MULTI_LANG_SUPPORT - - void slotLanguageChanged(); + /** + * @brief + * + */ + void slot_language_changed(); #endif - signals: - - void signalRestartNeeded(bool needed); }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/settings/SettingsKeyServer.cpp index 15c35810..ca74d3d2 100644 --- a/src/ui/settings/SettingsKeyServer.cpp +++ b/src/ui/settings/SettingsKeyServer.cpp @@ -35,79 +35,80 @@ namespace GpgFrontend::UI { KeyserverTab::KeyserverTab(QWidget* parent) - : QWidget(parent), ui(std::make_shared<Ui_KeyServerSettings>()) { - ui->setupUi(this); - ui->keyServerListTable->setSizeAdjustPolicy( + : QWidget(parent), ui_(std::make_shared<Ui_KeyServerSettings>()) { + ui_->setupUi(this); + ui_->keyServerListTable->setSizeAdjustPolicy( QAbstractScrollArea::AdjustToContents); - connect(ui->addKeyServerPushButton, &QPushButton::clicked, this, - &KeyserverTab::addKeyServer); - connect(ui->testKeyServerButton, &QPushButton::clicked, this, - &KeyserverTab::slotTestListedKeyServer); + connect(ui_->addKeyServerPushButton, &QPushButton::clicked, this, + &KeyserverTab::slot_add_key_server); + connect(ui_->testKeyServerButton, &QPushButton::clicked, this, + &KeyserverTab::slot_test_listed_key_server); - ui->keyServerListGroupBox->setTitle(_("Keyserver List")); - ui->operationsGroupBox->setTitle(_("Operations")); + ui_->keyServerListGroupBox->setTitle(_("Keyserver List")); + ui_->operationsGroupBox->setTitle(_("Operations")); - ui->keyServerListTable->horizontalHeaderItem(0)->setText(_("Default")); - ui->keyServerListTable->horizontalHeaderItem(1)->setText( + ui_->keyServerListTable->horizontalHeaderItem(0)->setText(_("Default")); + ui_->keyServerListTable->horizontalHeaderItem(1)->setText( _("Keyserver Address")); - ui->keyServerListTable->horizontalHeaderItem(2)->setText(_("Security")); - ui->keyServerListTable->horizontalHeaderItem(3)->setText(_("Available")); + ui_->keyServerListTable->horizontalHeaderItem(2)->setText(_("Security")); + ui_->keyServerListTable->horizontalHeaderItem(3)->setText(_("Available")); - ui->addKeyServerPushButton->setText(_("Add")); - ui->testKeyServerButton->setText(_("Test Listed Keyserver")); + ui_->addKeyServerPushButton->setText(_("Add")); + ui_->testKeyServerButton->setText(_("Test Listed Keyserver")); - ui->tipsLabel->setText(_("Tips: Please Double-click table item to edit it.")); - ui->actionDelete_Selected_Key_Server->setText(_("Delete Selected")); - ui->actionDelete_Selected_Key_Server->setToolTip( + ui_->tipsLabel->setText( + _("Tips: Please Double-click table item to edit it.")); + ui_->actionDelete_Selected_Key_Server->setText(_("Delete Selected")); + ui_->actionDelete_Selected_Key_Server->setToolTip( _("Delete Selected Key Server")); - ui->actionSet_As_Default->setText(_("Set As Default")); - ui->actionSet_As_Default->setToolTip(_("Set As Default")); + ui_->actionSet_As_Default->setText(_("Set As Default")); + ui_->actionSet_As_Default->setToolTip(_("Set As Default")); - popupMenu = new QMenu(this); - popupMenu->addAction(ui->actionSet_As_Default); - popupMenu->addAction(ui->actionDelete_Selected_Key_Server); + popup_menu_ = new QMenu(this); + popup_menu_->addAction(ui_->actionSet_As_Default); + popup_menu_->addAction(ui_->actionDelete_Selected_Key_Server); - connect(ui->keyServerListTable, &QTableWidget::itemChanged, + connect(ui_->keyServerListTable, &QTableWidget::itemChanged, [=](QTableWidgetItem* item) { LOG(INFO) << "item edited" << item->column(); if (item->column() != 1) return; - const auto row_size = ui->keyServerListTable->rowCount(); + const auto row_size = ui_->keyServerListTable->rowCount(); // Update Actions if (row_size > 0) { - keyServerStrList.clear(); + key_server_str_list_.clear(); for (int i = 0; i < row_size; i++) { const auto key_server = - ui->keyServerListTable->item(i, 1)->text(); - keyServerStrList.append(key_server); + ui_->keyServerListTable->item(i, 1)->text(); + key_server_str_list_.append(key_server); } } }); - connect(ui->actionSet_As_Default, &QAction::triggered, [=]() { - const auto row_size = ui->keyServerListTable->rowCount(); + connect(ui_->actionSet_As_Default, &QAction::triggered, [=]() { + const auto row_size = ui_->keyServerListTable->rowCount(); for (int i = 0; i < row_size; i++) { - const auto item = ui->keyServerListTable->item(i, 1); + const auto item = ui_->keyServerListTable->item(i, 1); if (!item->isSelected()) continue; - this->defaultKeyServer = item->text(); + this->default_key_server_ = item->text(); } - this->refreshTable(); + this->slot_refresh_table(); }); - connect(ui->actionDelete_Selected_Key_Server, &QAction::triggered, [=]() { - const auto row_size = ui->keyServerListTable->rowCount(); + connect(ui_->actionDelete_Selected_Key_Server, &QAction::triggered, [=]() { + const auto row_size = ui_->keyServerListTable->rowCount(); for (int i = 0; i < row_size; i++) { - const auto item = ui->keyServerListTable->item(i, 1); + const auto item = ui_->keyServerListTable->item(i, 1); if (!item->isSelected()) continue; - this->keyServerStrList.removeAt(i); + this->key_server_str_list_.removeAt(i); break; } - this->refreshTable(); + this->slot_refresh_table(); }); // Read key-list from ini-file and fill it into combobox - setSettings(); - refreshTable(); + SetSettings(); + slot_refresh_table(); } /********************************** @@ -115,7 +116,7 @@ KeyserverTab::KeyserverTab(QWidget* parent) * and set the buttons and checkboxes * appropriately **********************************/ -void KeyserverTab::setSettings() { +void KeyserverTab::SetSettings() { auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); try { @@ -123,7 +124,7 @@ void KeyserverTab::setSettings() { const auto server_list_size = server_list.getLength(); for (int i = 0; i < server_list_size; i++) { std::string server_url = server_list[i]; - keyServerStrList.append(server_url.c_str()); + key_server_str_list_.append(server_url.c_str()); } } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("server_list"); @@ -131,17 +132,17 @@ void KeyserverTab::setSettings() { try { std::string default_server = settings.lookup("keyserver.default_server"); - if (!keyServerStrList.contains(default_server.c_str())) - keyServerStrList.append(default_server.c_str()); - defaultKeyServer = QString::fromStdString(default_server); + if (!key_server_str_list_.contains(default_server.c_str())) + key_server_str_list_.append(default_server.c_str()); + default_key_server_ = QString::fromStdString(default_server); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("default_server"); } } -void KeyserverTab::addKeyServer() { - auto target_url = ui->addKeyServerEdit->text(); - if (url_reg.match(target_url).hasMatch()) { +void KeyserverTab::slot_add_key_server() { + auto target_url = ui_->addKeyServerEdit->text(); + if (url_reg_.match(target_url).hasMatch()) { if (target_url.startsWith("https://")) { ; } else if (target_url.startsWith("http://")) { @@ -152,7 +153,7 @@ void KeyserverTab::addKeyServer() { "the key server is not recommended. It is recommended to use " "HTTPS.")); } - keyServerStrList.append(ui->addKeyServerEdit->text()); + key_server_str_list_.append(ui_->addKeyServerEdit->text()); } else { auto ret = QMessageBox::warning( this, _("Warning"), @@ -166,12 +167,12 @@ void KeyserverTab::addKeyServer() { if (ret == QMessageBox::Cancel) return; else - keyServerStrList.append(ui->addKeyServerEdit->text()); + key_server_str_list_.append(ui_->addKeyServerEdit->text()); } - refreshTable(); + slot_refresh_table(); } -void KeyserverTab::applySettings() { +void KeyserverTab::ApplySettings() { auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); if (!settings.exists("keyserver") || @@ -184,67 +185,67 @@ void KeyserverTab::applySettings() { keyserver.add("server_list", libconfig::Setting::TypeList); - const auto row_size = ui->keyServerListTable->rowCount(); + const auto row_size = ui_->keyServerListTable->rowCount(); auto& server_list = keyserver["server_list"]; for (int i = 0; i < row_size; i++) { - const auto key_server = ui->keyServerListTable->item(i, 1)->text(); + const auto key_server = ui_->keyServerListTable->item(i, 1)->text(); server_list.add(libconfig::Setting::TypeString) = key_server.toStdString(); } if (!keyserver.exists("default_server")) { keyserver.add("default_server", libconfig::Setting::TypeString) = - defaultKeyServer.toStdString(); + default_key_server_.toStdString(); } else { - keyserver["default_server"] = defaultKeyServer.toStdString(); + keyserver["default_server"] = default_key_server_.toStdString(); } } -void KeyserverTab::refreshTable() { +void KeyserverTab::slot_refresh_table() { LOG(INFO) << "Start Refreshing Key Server Table"; - ui->keyServerListTable->blockSignals(true); - ui->keyServerListTable->setRowCount(keyServerStrList.size()); + ui_->keyServerListTable->blockSignals(true); + ui_->keyServerListTable->setRowCount(key_server_str_list_.size()); int index = 0; - for (const auto& server : keyServerStrList) { + for (const auto& server : key_server_str_list_) { auto* tmp1 = - new QTableWidgetItem(server == defaultKeyServer ? "*" : QString{}); + new QTableWidgetItem(server == default_key_server_ ? "*" : QString{}); tmp1->setTextAlignment(Qt::AlignCenter); - ui->keyServerListTable->setItem(index, 0, tmp1); + ui_->keyServerListTable->setItem(index, 0, tmp1); tmp1->setFlags(tmp1->flags() ^ Qt::ItemIsEditable); auto* tmp2 = new QTableWidgetItem(server); tmp2->setTextAlignment(Qt::AlignCenter); - ui->keyServerListTable->setItem(index, 1, tmp2); + ui_->keyServerListTable->setItem(index, 1, tmp2); auto* tmp3 = new QTableWidgetItem(server.startsWith("https") ? _("true") : _("false")); tmp3->setTextAlignment(Qt::AlignCenter); - ui->keyServerListTable->setItem(index, 2, tmp3); + ui_->keyServerListTable->setItem(index, 2, tmp3); tmp3->setFlags(tmp3->flags() ^ Qt::ItemIsEditable); auto* tmp4 = new QTableWidgetItem(_("unknown")); tmp4->setTextAlignment(Qt::AlignCenter); - ui->keyServerListTable->setItem(index, 3, tmp4); + ui_->keyServerListTable->setItem(index, 3, tmp4); tmp4->setFlags(tmp3->flags() ^ Qt::ItemIsEditable); index++; } - const auto column_count = ui->keyServerListTable->columnCount(); + const auto column_count = ui_->keyServerListTable->columnCount(); for (int i = 0; i < column_count; i++) { - ui->keyServerListTable->resizeColumnToContents(i); + ui_->keyServerListTable->resizeColumnToContents(i); } - ui->keyServerListTable->blockSignals(false); + ui_->keyServerListTable->blockSignals(false); } -void KeyserverTab::slotTestListedKeyServer() { +void KeyserverTab::slot_test_listed_key_server() { auto timeout = QInputDialog::getInt(this, _("Set TCP Timeout"), tr("timeout(ms): "), QLineEdit::Normal, 500, 2000); QStringList urls; - const auto row_size = ui->keyServerListTable->rowCount(); + const auto row_size = ui_->keyServerListTable->rowCount(); for (int i = 0; i < row_size; i++) { - const auto keyserver_url = ui->keyServerListTable->item(i, 1)->text(); + const auto keyserver_url = ui_->keyServerListTable->item(i, 1)->text(); urls.push_back(keyserver_url); } @@ -253,12 +254,12 @@ void KeyserverTab::slotTestListedKeyServer() { &GpgFrontend::UI::TestListedKeyServerThread:: signalKeyServerListTestResult, this, [=](const QStringList& result) { - const auto row_size = ui->keyServerListTable->rowCount(); + const auto row_size = ui_->keyServerListTable->rowCount(); if (result.size() != row_size) return; - ui->keyServerListTable->blockSignals(true); + ui_->keyServerListTable->blockSignals(true); for (int i = 0; i < row_size; i++) { const auto status = result[i]; - auto status_iem = ui->keyServerListTable->item(i, 3); + auto status_iem = ui_->keyServerListTable->item(i, 3); if (status == "Reachable") { status_iem->setText(_("Reachable")); status_iem->setForeground(QBrush(QColor::fromRgb(0, 255, 0))); @@ -267,7 +268,7 @@ void KeyserverTab::slotTestListedKeyServer() { status_iem->setForeground(QBrush(QColor::fromRgb(255, 0, 0))); } } - ui->keyServerListTable->blockSignals(false); + ui_->keyServerListTable->blockSignals(false); }); connect(thread, &QThread::finished, thread, &QThread::deleteLater); @@ -304,8 +305,8 @@ void KeyserverTab::slotTestListedKeyServer() { void KeyserverTab::contextMenuEvent(QContextMenuEvent* event) { QWidget::contextMenuEvent(event); - if (ui->keyServerListTable->selectedItems().length() > 0) { - popupMenu->exec(event->globalPos()); + if (ui_->keyServerListTable->selectedItems().length() > 0) { + popup_menu_->exec(event->globalPos()); } } diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/settings/SettingsKeyServer.h index 0f50b345..f983e69b 100644 --- a/src/ui/settings/SettingsKeyServer.h +++ b/src/ui/settings/SettingsKeyServer.h @@ -34,38 +34,76 @@ class Ui_KeyServerSettings; namespace GpgFrontend::UI { +/** + * @brief + * + */ class KeyserverTab : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new Keyserver Tab object + * + * @param parent + */ explicit KeyserverTab(QWidget* parent = nullptr); - void setSettings(); + /** + * @brief Set the Settings object + * + */ + void SetSettings(); - void applySettings(); + /** + * @brief + * + */ + void ApplySettings(); private: - std::shared_ptr<Ui_KeyServerSettings> ui; - QString defaultKeyServer; - QStringList keyServerStrList; - QMenu* popupMenu{}; + std::shared_ptr<Ui_KeyServerSettings> ui_; + QString default_key_server_; + QStringList key_server_str_list_; + QMenu* popup_menu_{}; - QRegularExpression url_reg{ + QRegularExpression url_reg_{ R"(^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$)"}; private slots: - void addKeyServer(); + /** + * @brief + * + */ + void slot_add_key_server(); - void refreshTable(); + /** + * @brief + * + */ + void slot_refresh_table(); - void slotTestListedKeyServer(); + /** + * @brief + * + */ + void slot_test_listed_key_server(); signals: - - void signalRestartNeeded(bool needed); + /** + * @brief + * + * @param needed + */ + void SignalRestartNeeded(bool needed); protected: + /** + * @brief + * + * @param event + */ void contextMenuEvent(QContextMenuEvent* event) override; }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsNetwork.cpp b/src/ui/settings/SettingsNetwork.cpp index 07b6981c..1a976412 100644 --- a/src/ui/settings/SettingsNetwork.cpp +++ b/src/ui/settings/SettingsNetwork.cpp @@ -33,124 +33,124 @@ #include "ui_NetworkSettings.h" GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent) - : QWidget(parent), ui(std::make_shared<Ui_NetworkSettings>()) { - ui->setupUi(this); + : QWidget(parent), ui_(std::make_shared<Ui_NetworkSettings>()) { + ui_->setupUi(this); - connect(ui->enableProxyCheckBox, &QCheckBox::stateChanged, this, + connect(ui_->enableProxyCheckBox, &QCheckBox::stateChanged, this, [=](int state) { switch_ui_enabled(state == Qt::Checked); }); connect( - ui->proxyTypeComboBox, &QComboBox::currentTextChanged, this, + ui_->proxyTypeComboBox, &QComboBox::currentTextChanged, this, [=](const QString ¤t_text) { switch_ui_proxy_type(current_text); }); - connect(ui->checkProxyConnectionButton, &QPushButton::clicked, this, - &NetworkTab::slotTestProxyConnectionResult); + connect(ui_->checkProxyConnectionButton, &QPushButton::clicked, this, + &NetworkTab::slot_test_proxy_connection_result); - ui->proxyGroupBox->setTitle(_("Proxy")); - ui->capabilityGroupBox->setTitle(_("Network Capability")); - ui->operationsGroupBox->setTitle(_("Operations")); + ui_->proxyGroupBox->setTitle(_("Proxy")); + ui_->capabilityGroupBox->setTitle(_("Network Capability")); + ui_->operationsGroupBox->setTitle(_("Operations")); - ui->enableProxyCheckBox->setText(_("Enable Proxy")); - ui->proxyServerPortLabel->setText(_("Port")); + ui_->enableProxyCheckBox->setText(_("Enable Proxy")); + ui_->proxyServerPortLabel->setText(_("Port")); - ui->proxyServerAddressLabel->setText(_("Host Address")); - ui->proxyServerPortLabel->setText(_("Port")); - ui->proxyTypeLabel->setText(_("Proxy Type")); - ui->usernameLabel->setText(_("Username")); - ui->passwordLabel->setText(_("Password")); + ui_->proxyServerAddressLabel->setText(_("Host Address")); + ui_->proxyServerPortLabel->setText(_("Port")); + ui_->proxyTypeLabel->setText(_("Proxy Type")); + ui_->usernameLabel->setText(_("Username")); + ui_->passwordLabel->setText(_("Password")); - ui->forbidALLCheckBox->setText(_("Forbid all network connection.")); - ui->forbidALLCheckBox->setDisabled(true); + ui_->forbidALLCheckBox->setText(_("Forbid all network connection.")); + ui_->forbidALLCheckBox->setDisabled(true); - ui->prohibitUpdateCheck->setText( + ui_->prohibitUpdateCheck->setText( _("Prohibit checking for version updates when the program starts.")); - ui->checkProxyConnectionButton->setText(_("Check Proxy Connection")); + ui_->checkProxyConnectionButton->setText(_("Check Proxy Connection")); - setSettings(); + SetSettings(); } -void GpgFrontend::UI::NetworkTab::setSettings() { +void GpgFrontend::UI::NetworkTab::SetSettings() { auto &settings = GlobalSettingStation::GetInstance().GetUISettings(); try { std::string proxy_host = settings.lookup("proxy.proxy_host"); - ui->proxyServerAddressEdit->setText(proxy_host.c_str()); + ui_->proxyServerAddressEdit->setText(proxy_host.c_str()); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("proxy_host"); } try { std::string std_username = settings.lookup("proxy.username"); - ui->usernameEdit->setText(std_username.c_str()); + ui_->usernameEdit->setText(std_username.c_str()); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("username"); } try { std::string std_password = settings.lookup("proxy.password"); - ui->passwordEdit->setText(std_password.c_str()); + ui_->passwordEdit->setText(std_password.c_str()); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("password"); } try { int port = settings.lookup("proxy.port"); - ui->portSpin->setValue(port); + ui_->portSpin->setValue(port); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("port"); } - ui->proxyTypeComboBox->setCurrentText("HTTP"); + ui_->proxyTypeComboBox->setCurrentText("HTTP"); try { std::string proxy_type = settings.lookup("proxy.proxy_type"); - ui->proxyTypeComboBox->setCurrentText(proxy_type.c_str()); + ui_->proxyTypeComboBox->setCurrentText(proxy_type.c_str()); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("proxy_type"); } - switch_ui_proxy_type(ui->proxyTypeComboBox->currentText()); + switch_ui_proxy_type(ui_->proxyTypeComboBox->currentText()); - ui->enableProxyCheckBox->setCheckState(Qt::Unchecked); + ui_->enableProxyCheckBox->setCheckState(Qt::Unchecked); try { bool proxy_enable = settings.lookup("proxy.enable"); if (proxy_enable) - ui->enableProxyCheckBox->setCheckState(Qt::Checked); + ui_->enableProxyCheckBox->setCheckState(Qt::Checked); else - ui->enableProxyCheckBox->setCheckState(Qt::Unchecked); + ui_->enableProxyCheckBox->setCheckState(Qt::Unchecked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("proxy_enable"); } { - auto state = ui->enableProxyCheckBox->checkState(); + auto state = ui_->enableProxyCheckBox->checkState(); switch_ui_enabled(state == Qt::Checked); } - ui->forbidALLCheckBox->setCheckState(Qt::Unchecked); + ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked); try { bool forbid_all_connection = settings.lookup("network.forbid_all_connection"); if (forbid_all_connection) - ui->forbidALLCheckBox->setCheckState(Qt::Checked); + ui_->forbidALLCheckBox->setCheckState(Qt::Checked); else - ui->forbidALLCheckBox->setCheckState(Qt::Unchecked); + ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("forbid_all_connection"); } - ui->prohibitUpdateCheck->setCheckState(Qt::Unchecked); + ui_->prohibitUpdateCheck->setCheckState(Qt::Unchecked); try { bool prohibit_update_checking = settings.lookup("network.prohibit_update_checking"); if (prohibit_update_checking) - ui->prohibitUpdateCheck->setCheckState(Qt::Checked); + ui_->prohibitUpdateCheck->setCheckState(Qt::Checked); else - ui->prohibitUpdateCheck->setCheckState(Qt::Unchecked); + ui_->prohibitUpdateCheck->setCheckState(Qt::Unchecked); } catch (...) { LOG(ERROR) << _("Setting Operation Error") << _("prohibit_update_checking"); } } -void GpgFrontend::UI::NetworkTab::applySettings() { +void GpgFrontend::UI::NetworkTab::ApplySettings() { LOG(INFO) << "called"; auto &settings = @@ -164,43 +164,43 @@ void GpgFrontend::UI::NetworkTab::applySettings() { if (!proxy.exists("proxy_host")) proxy.add("proxy_host", libconfig::Setting::TypeString) = - ui->proxyServerAddressEdit->text().toStdString(); + ui_->proxyServerAddressEdit->text().toStdString(); else { - proxy["proxy_host"] = ui->proxyServerAddressEdit->text().toStdString(); + proxy["proxy_host"] = ui_->proxyServerAddressEdit->text().toStdString(); } if (!proxy.exists("username")) proxy.add("username", libconfig::Setting::TypeString) = - ui->usernameEdit->text().toStdString(); + ui_->usernameEdit->text().toStdString(); else { - proxy["username"] = ui->usernameEdit->text().toStdString(); + proxy["username"] = ui_->usernameEdit->text().toStdString(); } if (!proxy.exists("password")) proxy.add("password", libconfig::Setting::TypeString) = - ui->passwordEdit->text().toStdString(); + ui_->passwordEdit->text().toStdString(); else { - proxy["password"] = ui->passwordEdit->text().toStdString(); + proxy["password"] = ui_->passwordEdit->text().toStdString(); } if (!proxy.exists("port")) - proxy.add("port", libconfig::Setting::TypeInt) = ui->portSpin->value(); + proxy.add("port", libconfig::Setting::TypeInt) = ui_->portSpin->value(); else { - proxy["port"] = ui->portSpin->value(); + proxy["port"] = ui_->portSpin->value(); } if (!proxy.exists("proxy_type")) proxy.add("proxy_type", libconfig::Setting::TypeString) = - ui->proxyTypeComboBox->currentText().toStdString(); + ui_->proxyTypeComboBox->currentText().toStdString(); else { - proxy["proxy_type"] = ui->proxyTypeComboBox->currentText().toStdString(); + proxy["proxy_type"] = ui_->proxyTypeComboBox->currentText().toStdString(); } if (!proxy.exists("enable")) proxy.add("enable", libconfig::Setting::TypeBoolean) = - ui->enableProxyCheckBox->isChecked(); + ui_->enableProxyCheckBox->isChecked(); else { - proxy["enable"] = ui->enableProxyCheckBox->isChecked(); + proxy["enable"] = ui_->enableProxyCheckBox->isChecked(); } if (!settings.exists("network") || @@ -211,16 +211,16 @@ void GpgFrontend::UI::NetworkTab::applySettings() { if (!network.exists("forbid_all_connection")) network.add("forbid_all_connection", libconfig::Setting::TypeBoolean) = - ui->forbidALLCheckBox->isChecked(); + ui_->forbidALLCheckBox->isChecked(); else { - network["forbid_all_connection"] = ui->forbidALLCheckBox->isChecked(); + network["forbid_all_connection"] = ui_->forbidALLCheckBox->isChecked(); } if (!network.exists("prohibit_update_checking")) network.add("prohibit_update_checking", libconfig::Setting::TypeBoolean) = - ui->prohibitUpdateCheck->isChecked(); + ui_->prohibitUpdateCheck->isChecked(); else { - network["prohibit_update_checking"] = ui->prohibitUpdateCheck->isChecked(); + network["prohibit_update_checking"] = ui_->prohibitUpdateCheck->isChecked(); } apply_proxy_settings(); @@ -228,7 +228,7 @@ void GpgFrontend::UI::NetworkTab::applySettings() { LOG(INFO) << "done"; } -void GpgFrontend::UI::NetworkTab::slotTestProxyConnectionResult() { +void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() { apply_proxy_settings(); bool ok; @@ -288,14 +288,14 @@ void GpgFrontend::UI::NetworkTab::slotTestProxyConnectionResult() { void GpgFrontend::UI::NetworkTab::apply_proxy_settings() { // apply settings QNetworkProxy _proxy; - if (ui->enableProxyCheckBox->isChecked() && + if (ui_->enableProxyCheckBox->isChecked() && proxy_type_ != QNetworkProxy::DefaultProxy) { _proxy.setType(proxy_type_); - _proxy.setHostName(ui->proxyServerAddressEdit->text()); - _proxy.setPort(ui->portSpin->value()); - if (!ui->usernameEdit->text().isEmpty()) { - _proxy.setUser(ui->usernameEdit->text()); - _proxy.setPassword(ui->passwordEdit->text()); + _proxy.setHostName(ui_->proxyServerAddressEdit->text()); + _proxy.setPort(ui_->portSpin->value()); + if (!ui_->usernameEdit->text().isEmpty()) { + _proxy.setUser(ui_->usernameEdit->text()); + _proxy.setPassword(ui_->passwordEdit->text()); } } else { _proxy.setType(proxy_type_); @@ -305,34 +305,34 @@ void GpgFrontend::UI::NetworkTab::apply_proxy_settings() { } void GpgFrontend::UI::NetworkTab::switch_ui_enabled(bool enabled) { - ui->proxyServerAddressEdit->setDisabled(!enabled); - ui->portSpin->setDisabled(!enabled); - ui->proxyTypeComboBox->setDisabled(!enabled); - ui->usernameEdit->setDisabled(!enabled); - ui->passwordEdit->setDisabled(!enabled); - ui->checkProxyConnectionButton->setDisabled(!enabled); + ui_->proxyServerAddressEdit->setDisabled(!enabled); + ui_->portSpin->setDisabled(!enabled); + ui_->proxyTypeComboBox->setDisabled(!enabled); + ui_->usernameEdit->setDisabled(!enabled); + ui_->passwordEdit->setDisabled(!enabled); + ui_->checkProxyConnectionButton->setDisabled(!enabled); if (!enabled) proxy_type_ = QNetworkProxy::NoProxy; } void GpgFrontend::UI::NetworkTab::switch_ui_proxy_type( const QString &type_text) { if (type_text == "HTTP") { - ui->proxyServerAddressEdit->setDisabled(false); - ui->portSpin->setDisabled(false); - ui->usernameEdit->setDisabled(false); - ui->passwordEdit->setDisabled(false); + ui_->proxyServerAddressEdit->setDisabled(false); + ui_->portSpin->setDisabled(false); + ui_->usernameEdit->setDisabled(false); + ui_->passwordEdit->setDisabled(false); proxy_type_ = QNetworkProxy::HttpProxy; } else if (type_text == "Socks5") { - ui->proxyServerAddressEdit->setDisabled(false); - ui->portSpin->setDisabled(false); - ui->usernameEdit->setDisabled(false); - ui->passwordEdit->setDisabled(false); + ui_->proxyServerAddressEdit->setDisabled(false); + ui_->portSpin->setDisabled(false); + ui_->usernameEdit->setDisabled(false); + ui_->passwordEdit->setDisabled(false); proxy_type_ = QNetworkProxy::Socks5Proxy; } else { - ui->proxyServerAddressEdit->setDisabled(true); - ui->portSpin->setDisabled(true); - ui->usernameEdit->setDisabled(true); - ui->passwordEdit->setDisabled(true); + ui_->proxyServerAddressEdit->setDisabled(true); + ui_->portSpin->setDisabled(true); + ui_->usernameEdit->setDisabled(true); + ui_->passwordEdit->setDisabled(true); proxy_type_ = QNetworkProxy::DefaultProxy; } } diff --git a/src/ui/settings/SettingsNetwork.h b/src/ui/settings/SettingsNetwork.h index e85635ab..d4c0d00d 100644 --- a/src/ui/settings/SettingsNetwork.h +++ b/src/ui/settings/SettingsNetwork.h @@ -38,22 +38,55 @@ class NetworkTab : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new Network Tab object + * + * @param parent + */ explicit NetworkTab(QWidget* parent = nullptr); - void setSettings(); + /** + * @brief Set the Settings object + * + */ + void SetSettings(); - void applySettings(); + /** + * @brief + * + */ + void ApplySettings(); private slots: - void slotTestProxyConnectionResult(); + /** + * @brief + * + */ + void slot_test_proxy_connection_result(); private: - std::shared_ptr<Ui_NetworkSettings> ui; - QNetworkProxy::ProxyType proxy_type_ = QNetworkProxy::HttpProxy; + std::shared_ptr<Ui_NetworkSettings> ui_; ///< + QNetworkProxy::ProxyType proxy_type_ = QNetworkProxy::HttpProxy; ///< + /** + * @brief + * + */ void apply_proxy_settings(); + + /** + * @brief + * + * @param enabled + */ void switch_ui_enabled(bool enabled); + + /** + * @brief + * + * @param type_text + */ void switch_ui_proxy_type(const QString& type_text); }; } // namespace GpgFrontend::UI diff --git a/src/ui/settings/SettingsSendMail.cpp b/src/ui/settings/SettingsSendMail.cpp index 1d42b6aa..910c54ec 100644 --- a/src/ui/settings/SettingsSendMail.cpp +++ b/src/ui/settings/SettingsSendMail.cpp @@ -36,23 +36,23 @@ namespace GpgFrontend::UI { SendMailTab::SendMailTab(QWidget* parent) - : QWidget(parent), ui(std::make_shared<Ui_SendMailSettings>()) { - ui->setupUi(this); + : QWidget(parent), ui_(std::make_shared<Ui_SendMailSettings>()) { + ui_->setupUi(this); - connect(ui->enableCheckBox, &QCheckBox::stateChanged, this, + connect(ui_->enableCheckBox, &QCheckBox::stateChanged, this, [=](int state) { switch_ui_enabled(state == Qt::Checked); }); #ifdef SMTP_SUPPORT - connect(ui->checkConnectionButton, &QPushButton::clicked, this, - &SendMailTab::slotCheckConnection); - connect(ui->senTestMailButton, &QPushButton::clicked, this, - &SendMailTab::slotSendTestMail); + connect(ui_->checkConnectionButton, &QPushButton::clicked, this, + &SendMailTab::slot_check_connection); + connect(ui_->senTestMailButton, &QPushButton::clicked, this, + &SendMailTab::slot_send_test_mail); #endif - connect(ui->identityCheckBox, &QCheckBox::stateChanged, this, + connect(ui_->identityCheckBox, &QCheckBox::stateChanged, this, [=](int state) { switch_ui_identity_enabled(state == Qt::Checked); }); - connect(ui->connextionSecurityComboBox, &QComboBox::currentTextChanged, this, + connect(ui_->connextionSecurityComboBox, &QComboBox::currentTextChanged, this, [=](const QString& current_text) { if (current_text == "SSL") { connection_type_ = SmtpClient::ConnectionType::SslConnection; @@ -63,104 +63,104 @@ SendMailTab::SendMailTab(QWidget* parent) } }); - ui->generalGroupBox->setTitle(_("General")); - ui->identityGroupBox->setTitle(_("Identity Information")); - ui->preferenceGroupBox->setTitle(_("Preference")); - ui->operationsGroupBox->setTitle(_("Operations")); + ui_->generalGroupBox->setTitle(_("General")); + ui_->identityGroupBox->setTitle(_("Identity Information")); + ui_->preferenceGroupBox->setTitle(_("Preference")); + ui_->operationsGroupBox->setTitle(_("Operations")); - ui->enableCheckBox->setText(_("Enable Send Mail Ability")); - ui->identityCheckBox->setText(_("Need Auth")); + ui_->enableCheckBox->setText(_("Enable Send Mail Ability")); + ui_->identityCheckBox->setText(_("Need Auth")); - ui->smtpServerAddressLabel->setText(_("SMTP Server Address")); - ui->smtpServerPortLabel->setText(_("SMTP Server Port")); - ui->connectionSecurityLabel->setText(_("SMTP Connection Security")); - ui->usernameLabel->setText(_("Username")); - ui->passwordLabel->setText(_("Password")); + ui_->smtpServerAddressLabel->setText(_("SMTP Server Address")); + ui_->smtpServerPortLabel->setText(_("SMTP Server Port")); + ui_->connectionSecurityLabel->setText(_("SMTP Connection Security")); + ui_->usernameLabel->setText(_("Username")); + ui_->passwordLabel->setText(_("Password")); - ui->senderLabel->setText(_("Default Sender Email")); - ui->checkConnectionButton->setText(_("Check Connection")); - ui->senTestMailButton->setText(_("Send Test Email")); - ui->gpgkeyIdLabel->setText(_("Default Sender GPG Key ID")); + ui_->senderLabel->setText(_("Default Sender Email")); + ui_->checkConnectionButton->setText(_("Check Connection")); + ui_->senTestMailButton->setText(_("Send Test Email")); + ui_->gpgkeyIdLabel->setText(_("Default Sender GPG Key ID")); - ui->tipsLabel->setText( + ui_->tipsLabel->setText( _("Tips: It is recommended that you build your own mail server or use " "a trusted mail server. If you don't know the detailed configuration " "information, you can get it from the mail service provider.")); - ui->senTestMailButton->setDisabled(true); + ui_->senTestMailButton->setDisabled(true); auto* email_validator = - new QRegularExpressionValidator(re_email, ui->defaultSenderEmailEdit); - ui->defaultSenderEmailEdit->setValidator(email_validator); + new QRegularExpressionValidator(re_email_, ui_->defaultSenderEmailEdit); + ui_->defaultSenderEmailEdit->setValidator(email_validator); - setSettings(); + SetSettings(); } -void SendMailTab::setSettings() { +void SendMailTab::SetSettings() { auto smtp_passport = SettingsObject("smtp_passport"); - ui->smtpServerAddressEdit->setText( + ui_->smtpServerAddressEdit->setText( std::string{smtp_passport.Check("smtp_address", {})}.c_str()); - ui->usernameEdit->setText( + ui_->usernameEdit->setText( std::string{smtp_passport.Check("username", {})}.c_str()); - ui->passwordEdit->setText( + ui_->passwordEdit->setText( std::string{smtp_passport.Check("password", {})}.c_str()); - ui->portSpin->setValue(int{smtp_passport.Check("port", 25)}); + ui_->portSpin->setValue(int{smtp_passport.Check("port", 25)}); - ui->connextionSecurityComboBox->setCurrentText( + ui_->connextionSecurityComboBox->setCurrentText( std::string{smtp_passport.Check("connection_type", "None")}.c_str()); - ui->defaultSenderEmailEdit->setText( + ui_->defaultSenderEmailEdit->setText( std::string{smtp_passport.Check("default_sender", {})}.c_str()); - ui->gpgKeyIDEdit->setText( + ui_->gpgKeyIDEdit->setText( std::string{smtp_passport.Check("default_sender_gpg_key_id", {})} .c_str()); - ui->identityCheckBox->setChecked( + ui_->identityCheckBox->setChecked( bool{smtp_passport.Check("identity_enable", false)}); - ui->enableCheckBox->setChecked(bool{smtp_passport.Check("enable", false)}); + ui_->enableCheckBox->setChecked(bool{smtp_passport.Check("enable", false)}); { - auto state = ui->identityCheckBox->checkState(); + auto state = ui_->identityCheckBox->checkState(); switch_ui_identity_enabled(state == Qt::Checked); } { - auto state = ui->enableCheckBox->checkState(); + auto state = ui_->enableCheckBox->checkState(); switch_ui_enabled(state == Qt::Checked); } } -void SendMailTab::applySettings() { +void SendMailTab::ApplySettings() { try { auto smtp_passport = SettingsObject("smtp_passport"); smtp_passport["smtp_address"] = - ui->smtpServerAddressEdit->text().toStdString(); + ui_->smtpServerAddressEdit->text().toStdString(); - smtp_passport["username"] = ui->usernameEdit->text().toStdString(); + smtp_passport["username"] = ui_->usernameEdit->text().toStdString(); - smtp_passport["password"] = ui->passwordEdit->text().toStdString(); + smtp_passport["password"] = ui_->passwordEdit->text().toStdString(); - smtp_passport["port"] = ui->portSpin->value(); + smtp_passport["port"] = ui_->portSpin->value(); smtp_passport["connection_type"] = - ui->connextionSecurityComboBox->currentText().toStdString(); + ui_->connextionSecurityComboBox->currentText().toStdString(); smtp_passport["default_sender"] = - ui->defaultSenderEmailEdit->text().toStdString(); + ui_->defaultSenderEmailEdit->text().toStdString(); smtp_passport["default_sender_gpg_key_id"] = - ui->gpgKeyIDEdit->text().toStdString(); + ui_->gpgKeyIDEdit->text().toStdString(); - smtp_passport["identity_enable"] = ui->identityCheckBox->isChecked(); + smtp_passport["identity_enable"] = ui_->identityCheckBox->isChecked(); - smtp_passport["enable"] = ui->enableCheckBox->isChecked(); + smtp_passport["enable"] = ui_->enableCheckBox->isChecked(); } catch (...) { LOG(ERROR) << _("apply settings failed"); @@ -168,13 +168,13 @@ void SendMailTab::applySettings() { } #ifdef SMTP_SUPPORT -void SendMailTab::slotCheckConnection() { - auto host = ui->smtpServerAddressEdit->text().toStdString(); - auto port = ui->portSpin->value(); +void SendMailTab::slot_check_connection() { + auto host = ui_->smtpServerAddressEdit->text().toStdString(); + auto port = ui_->portSpin->value(); auto connection_type = connection_type_; - bool identity_needed = ui->identityCheckBox->isChecked(); - auto username = ui->usernameEdit->text().toStdString(); - auto password = ui->passwordEdit->text().toStdString(); + bool identity_needed = ui_->identityCheckBox->isChecked(); + auto username = ui_->usernameEdit->text().toStdString(); + auto password = ui_->passwordEdit->text().toStdString(); auto thread = new SMTPTestThread(host, port, connection_type, identity_needed, username, password); @@ -191,7 +191,7 @@ void SendMailTab::slotCheckConnection() { waiting_dialog->setLabel(waiting_dialog_label); waiting_dialog->resize(420, 120); connect(thread, &SMTPTestThread::signalSMTPTestResult, this, - &SendMailTab::slotTestSMTPConnectionResult); + &SendMailTab::slot_test_smtp_connection_result); connect(thread, &QThread::finished, [=]() { waiting_dialog->finished(0); waiting_dialog->deleteLater(); @@ -213,14 +213,14 @@ void SendMailTab::slotCheckConnection() { #endif #ifdef SMTP_SUPPORT -void SendMailTab::slotSendTestMail() { - auto host = ui->smtpServerAddressEdit->text().toStdString(); - auto port = ui->portSpin->value(); +void SendMailTab::slot_send_test_mail() { + auto host = ui_->smtpServerAddressEdit->text().toStdString(); + auto port = ui_->portSpin->value(); auto connection_type = connection_type_; - bool identity_needed = ui->identityCheckBox->isChecked(); - auto username = ui->usernameEdit->text().toStdString(); - auto password = ui->passwordEdit->text().toStdString(); - auto sender_address = ui->defaultSenderEmailEdit->text(); + bool identity_needed = ui_->identityCheckBox->isChecked(); + auto username = ui_->usernameEdit->text().toStdString(); + auto password = ui_->passwordEdit->text().toStdString(); + auto sender_address = ui_->defaultSenderEmailEdit->text(); auto thread = new SMTPSendMailThread(host, port, connection_type, identity_needed, username, password); @@ -237,7 +237,7 @@ void SendMailTab::slotSendTestMail() { waiting_dialog->setLabel(waiting_dialog_label); waiting_dialog->resize(420, 120); connect(thread, &SMTPSendMailThread::signalSMTPResult, this, - &SendMailTab::slotTestSMTPConnectionResult); + &SendMailTab::slot_test_smtp_connection_result); connect(thread, &QThread::finished, [=]() { waiting_dialog->finished(0); waiting_dialog->deleteLater(); @@ -265,48 +265,48 @@ void SendMailTab::slotSendTestMail() { loop.exec(); } -void SendMailTab::slotTestSMTPConnectionResult(const QString& result) { +void SendMailTab::slot_test_smtp_connection_result(const QString& result) { if (result == "Fail to connect SMTP server") { QMessageBox::critical(this, _("Fail"), _("Fail to Connect SMTP Server.")); - ui->senTestMailButton->setDisabled(true); + ui_->senTestMailButton->setDisabled(true); } else if (result == "Fail to login") { QMessageBox::critical(this, _("Fail"), _("Fail to Login.")); - ui->senTestMailButton->setDisabled(true); + ui_->senTestMailButton->setDisabled(true); } else if (result == "Fail to send mail") { QMessageBox::critical(this, _("Fail"), _("Fail to Login.")); - ui->senTestMailButton->setDisabled(true); + ui_->senTestMailButton->setDisabled(true); } else if (result == "Succeed in testing connection") { QMessageBox::information(this, _("Success"), _("Succeed in connecting and login")); - ui->senTestMailButton->setDisabled(false); + ui_->senTestMailButton->setDisabled(false); } else if (result == "Succeed in sending a test email") { QMessageBox::information( this, _("Success"), _("Succeed in sending a test email to the SMTP Server")); - ui->senTestMailButton->setDisabled(false); + ui_->senTestMailButton->setDisabled(false); } else { QMessageBox::critical(this, _("Fail"), _("Unknown error.")); - ui->senTestMailButton->setDisabled(true); + ui_->senTestMailButton->setDisabled(true); } } void SendMailTab::switch_ui_enabled(bool enabled) { - ui->smtpServerAddressEdit->setDisabled(!enabled); - ui->portSpin->setDisabled(!enabled); - ui->connextionSecurityComboBox->setDisabled(!enabled); + ui_->smtpServerAddressEdit->setDisabled(!enabled); + ui_->portSpin->setDisabled(!enabled); + ui_->connextionSecurityComboBox->setDisabled(!enabled); - ui->identityCheckBox->setDisabled(!enabled); - ui->usernameEdit->setDisabled(!enabled); - ui->passwordEdit->setDisabled(!enabled); + ui_->identityCheckBox->setDisabled(!enabled); + ui_->usernameEdit->setDisabled(!enabled); + ui_->passwordEdit->setDisabled(!enabled); - ui->defaultSenderEmailEdit->setDisabled(!enabled); - ui->gpgKeyIDEdit->setDisabled(!enabled); - ui->checkConnectionButton->setDisabled(!enabled); + ui_->defaultSenderEmailEdit->setDisabled(!enabled); + ui_->gpgKeyIDEdit->setDisabled(!enabled); + ui_->checkConnectionButton->setDisabled(!enabled); } void SendMailTab::switch_ui_identity_enabled(bool enabled) { - ui->usernameEdit->setDisabled(!enabled); - ui->passwordEdit->setDisabled(!enabled); + ui_->usernameEdit->setDisabled(!enabled); + ui_->passwordEdit->setDisabled(!enabled); } #endif diff --git a/src/ui/settings/SettingsSendMail.h b/src/ui/settings/SettingsSendMail.h index 1c623359..84259844 100644 --- a/src/ui/settings/SettingsSendMail.h +++ b/src/ui/settings/SettingsSendMail.h @@ -34,40 +34,85 @@ class Ui_SendMailSettings; namespace GpgFrontend::UI { +/** + * @brief + * + */ class SendMailTab : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new Send Mail Tab object + * + * @param parent + */ explicit SendMailTab(QWidget* parent = nullptr); - void setSettings(); + /** + * @brief Set the Settings object + * + */ + void SetSettings(); + + /** + * @brief + * + */ + void ApplySettings(); + + signals: - void applySettings(); + /** + * @brief + * + * @param needed + */ + void SignalRestartNeeded(bool needed); private slots: - void slotTestSMTPConnectionResult(const QString& result); + /** + * @brief + * + * @param result + */ + void slot_test_smtp_connection_result(const QString& result); #ifdef SMTP_SUPPORT - void slotCheckConnection(); - - void slotSendTestMail(); + /** + * @brief + * + */ + void slot_check_connection(); + + /** + * @brief + * + */ + void slot_send_test_mail(); #endif private: - std::shared_ptr<Ui_SendMailSettings> ui; - QRegularExpression re_email{ + std::shared_ptr<Ui_SendMailSettings> ui_; ///< + QRegularExpression re_email_{ 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])+)\]))"}; SmtpClient::ConnectionType connection_type_ = - SmtpClient::ConnectionType::TcpConnection; + SmtpClient::ConnectionType::TcpConnection; ///< + /** + * @brief + * + * @param enabled + */ void switch_ui_enabled(bool enabled); + /** + * @brief + * + * @param enabled + */ void switch_ui_identity_enabled(bool enabled); - - signals: - - void signalRestartNeeded(bool needed); }; } // namespace GpgFrontend::UI |