aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/function/GlobalSettingStation.h20
-rw-r--r--src/core/function/gpg/GpgAdvancedOperator.cpp47
-rw-r--r--src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp3
-rw-r--r--src/module/GpgFrontendModuleInit.cpp4
-rw-r--r--src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp22
-rw-r--r--src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h10
-rw-r--r--src/module/integrated/version_checking_module/GpgTOFUInfo.h142
-rw-r--r--src/ui/dialog/gnupg/GnuPGControllerDialog.cpp52
-rw-r--r--src/ui/dialog/settings/SettingsAdvanced.cpp21
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.cpp17
-rw-r--r--src/ui/dialog/settings/SettingsDialog.cpp38
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp2
-rw-r--r--src/ui/function/ArchiveDirectory.cpp1
13 files changed, 128 insertions, 251 deletions
diff --git a/src/core/function/GlobalSettingStation.h b/src/core/function/GlobalSettingStation.h
index 5582562a..06f37264 100644
--- a/src/core/function/GlobalSettingStation.h
+++ b/src/core/function/GlobalSettingStation.h
@@ -168,6 +168,26 @@ class GPGFRONTEND_CORE_EXPORT GlobalSettingStation
return value;
}
+ /**
+ * @brief Looks up a setting by path.
+ * @param path The path to the setting.
+ * @param default_value The default value to return if setting is not found.
+ * @return The setting value.
+ */
+ template <typename T>
+ auto SaveSettings(std::string path, libconfig::Setting::Type type,
+ T value) noexcept -> T {
+ try {
+ if (!GetMainSettings().exists(path)) {
+ // TODO
+ GetMainSettings().add(path, type);
+ }
+ } catch (...) {
+ GF_CORE_LOG_WARN("setting not found: {}", path);
+ }
+ return value;
+ }
+
private:
class Impl;
SecureUniquePtr<Impl> p_;
diff --git a/src/core/function/gpg/GpgAdvancedOperator.cpp b/src/core/function/gpg/GpgAdvancedOperator.cpp
index c96b35f7..9195c55e 100644
--- a/src/core/function/gpg/GpgAdvancedOperator.cpp
+++ b/src/core/function/gpg/GpgAdvancedOperator.cpp
@@ -110,6 +110,7 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() {
GF_CORE_LOG_ERROR(
"gpgconf execute error, process stderr: {}, process stdout: {}",
p_err, p_out);
+ return;
}
GF_CORE_LOG_DEBUG("gpgconf --kill --all execute result: {}", success);
@@ -125,18 +126,21 @@ void GpgFrontend::GpgAdvancedOperator::RestartGpgComponents() {
if (!success) {
GF_CORE_LOG_ERROR("start gpg agent after core initilized failed");
+ return;
}
success &= StartDirmngr();
if (!success) {
GF_CORE_LOG_ERROR("start dirmngr after core initilized failed");
+ return;
}
success &= StartKeyBoxd();
if (!success) {
GF_CORE_LOG_ERROR("start keyboxd after core initilized failed");
+ return;
}
Module::UpsertRTValue(
@@ -198,16 +202,19 @@ auto GpgFrontend::GpgAdvancedOperator::StartGpgAgent() -> bool {
if (exit_code == 0) {
success = true;
GF_CORE_LOG_INFO("start gpg-agent successfully");
- } else if (exit_code == 2) {
+ return;
+ }
+
+ if (exit_code == 2) {
success = true;
GF_CORE_LOG_INFO("gpg-agent already started");
- } else {
- GF_CORE_LOG_ERROR(
- "gpg-agent execute error, process stderr: {}, process stdout: "
- "{}",
- p_err, p_out);
return;
}
+
+ GF_CORE_LOG_ERROR(
+ "gpg-agent execute error, "
+ "process stderr: {}, process stdout: {}",
+ p_err, p_out);
}});
return success;
@@ -238,22 +245,25 @@ auto GpgFrontend::GpgAdvancedOperator::StartDirmngr() -> bool {
if (exit_code == 0) {
success = true;
GF_CORE_LOG_INFO("start dirmngr successfully");
- } else if (exit_code == 2) {
+ return;
+ }
+
+ if (exit_code == 2) {
success = true;
GF_CORE_LOG_INFO("dirmngr already started");
- } else {
- GF_CORE_LOG_ERROR(
- "dirmngr execute error, process stderr: {}, process stdout: {}",
- p_err, p_out);
return;
}
+
+ GF_CORE_LOG_ERROR(
+ "dirmngr execute error, process stderr: {}, process stdout: {}",
+ p_err, p_out);
}});
return success;
}
auto GpgFrontend::GpgAdvancedOperator::StartKeyBoxd() -> bool {
- bool success = false;
+ auto success = false;
const auto keyboxd_path = Module::RetrieveRTValueTypedOrDefault<>(
"com.bktus.gpgfrontend.module.integrated.gnupg-info-gathering",
@@ -277,15 +287,18 @@ auto GpgFrontend::GpgAdvancedOperator::StartKeyBoxd() -> bool {
if (exit_code == 0) {
success = true;
GF_CORE_LOG_INFO("start keyboxd successfully");
- } else if (exit_code == 2) {
+ return;
+ }
+
+ if (exit_code == 2) {
success = true;
GF_CORE_LOG_INFO("keyboxd already started");
- } else {
- GF_CORE_LOG_ERROR(
- "keyboxd execute error, process stderr: {}, process stdout: {}",
- p_err, p_out);
return;
}
+
+ GF_CORE_LOG_ERROR(
+ "keyboxd execute error, process stderr: {}, process stdout: {}",
+ p_err, p_out);
}});
return success;
diff --git a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
index 064dc087..d497c094 100644
--- a/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
+++ b/src/core/function/result_analyse/GpgVerifyResultAnalyse.cpp
@@ -108,7 +108,8 @@ void GpgFrontend::GpgVerifyResultAnalyse::doAnalyse() {
stream_ << _("Signature Fully Valid.") << std::endl;
} else {
stream_ << _("Signature Not Fully Valid.") << std::endl;
- stream_ << _("(May used a subkey to sign)") << std::endl;
+ stream_ << _("(Adjust Trust Level to make it Fully Vaild)")
+ << std::endl;
}
if ((sign->status & GPGME_SIGSUM_KEY_MISSING) == 0U) {
diff --git a/src/module/GpgFrontendModuleInit.cpp b/src/module/GpgFrontendModuleInit.cpp
index b2d29c71..6f88b9ec 100644
--- a/src/module/GpgFrontendModuleInit.cpp
+++ b/src/module/GpgFrontendModuleInit.cpp
@@ -40,11 +40,11 @@
namespace GpgFrontend::Module {
-void LoadGpgFrontendModules(ModuleInitArgs args) {
+void LoadGpgFrontendModules(ModuleInitArgs) {
// must init at default thread before core
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
new Thread::Task(
- [args](const DataObjectPtr&) -> int {
+ [](const DataObjectPtr&) -> int {
MODULE_LOG_INFO("loading integrated module...");
// VersionCheckingModule
diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
index 84dd49cb..c257a977 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
+++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.cpp
@@ -81,20 +81,20 @@ GnuPGInfoGatheringModule::GnuPGInfoGatheringModule()
GnuPGInfoGatheringModule::~GnuPGInfoGatheringModule() = default;
-bool GnuPGInfoGatheringModule::Register() {
- MODULE_LOG_INFO("gnupg info gathering module registering");
+auto GnuPGInfoGatheringModule::Register() -> bool {
+ MODULE_LOG_DEBUG("gnupg info gathering module registering");
listenEvent("GPGFRONTEND_CORE_INITLIZED");
return true;
}
-bool GnuPGInfoGatheringModule::Active() {
- MODULE_LOG_INFO("gnupg info gathering module activating");
+auto GnuPGInfoGatheringModule::Active() -> bool {
+ MODULE_LOG_DEBUG("gnupg info gathering module activating");
return true;
}
-int GnuPGInfoGatheringModule::Exec(EventRefrernce event) {
- MODULE_LOG_INFO("gnupg info gathering module executing, event id: {}",
- event->GetIdentifier());
+auto GnuPGInfoGatheringModule::Exec(EventRefrernce event) -> int {
+ MODULE_LOG_DEBUG("gnupg info gathering module executing, event id: {}",
+ event->GetIdentifier());
const auto gpgme_version = RetrieveRTValueTypedOrDefault<>(
"core", "gpgme.version", std::string{"0.0.0"});
@@ -145,8 +145,8 @@ int GnuPGInfoGatheringModule::Exec(EventRefrernce event) {
component_infos.push_back(c_i_gpgme);
component_infos.push_back(c_i_gpgconf);
- nlohmann::json jsonlized_gpgme_component_info = c_i_gpgme;
- nlohmann::json jsonlized_gpgconf_component_info = c_i_gpgconf;
+ nlohmann::json const jsonlized_gpgme_component_info = c_i_gpgme;
+ nlohmann::json const jsonlized_gpgconf_component_info = c_i_gpgconf;
UpsertRTValue(
GetModuleIdentifier(), "gnupg.components.gpgme",
static_cast<std::string>(jsonlized_gpgme_component_info.dump()));
@@ -212,7 +212,7 @@ int GnuPGInfoGatheringModule::Exec(EventRefrernce event) {
c_i.binary_checksum =
binary_checksum.has_value() ? binary_checksum.value() : "/";
- nlohmann::json jsonlized_component_info = c_i;
+ nlohmann::json const jsonlized_component_info = c_i;
UpsertRTValue(
GetModuleIdentifier(),
(boost::format("gnupg.components.%1%") % component_name).str(),
@@ -375,7 +375,7 @@ int GnuPGInfoGatheringModule::Exec(EventRefrernce event) {
info.argdef = option_argdef;
info.value = option_value;
- nlohmann::json jsonlized_option_info = info;
+ nlohmann::json const jsonlized_option_info = info;
UpsertRTValue(
GetModuleIdentifier(),
(boost::format("gnupg.components.%1%.options.%2%") %
diff --git a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h
index 5c6d4636..5c228298 100644
--- a/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h
+++ b/src/module/integrated/gnupg_info_gathering_module/GnuPGInfoGatheringModule.h
@@ -41,14 +41,14 @@ class GPGFRONTEND_MODULE_SDK_EXPORT GnuPGInfoGatheringModule : public Module {
public:
GnuPGInfoGatheringModule();
- ~GnuPGInfoGatheringModule();
+ ~GnuPGInfoGatheringModule() override;
- virtual bool Register() override;
+ auto Register() -> bool override;
- virtual bool Active() override;
+ auto Active() -> bool override;
- virtual int Exec(EventRefrernce) override;
+ auto Exec(EventRefrernce) -> int override;
- virtual bool Deactive() override;
+ auto Deactive() -> bool override;
};
} // namespace GpgFrontend::Module::Integrated::GnuPGInfoGatheringModule
diff --git a/src/module/integrated/version_checking_module/GpgTOFUInfo.h b/src/module/integrated/version_checking_module/GpgTOFUInfo.h
deleted file mode 100644
index 9deec33f..00000000
--- a/src/module/integrated/version_checking_module/GpgTOFUInfo.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * Copyright (C) 2021 Saturneric <[email protected]>
- *
- * This file is part of GpgFrontend.
- *
- * GpgFrontend is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GpgFrontend is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
- *
- * The initial version of the source code is inherited from
- * the gpg4usb project, which is under GPL-3.0-or-later.
- *
- * All the source code of GpgFrontend was modified and released by
- * Saturneric <[email protected]> starting on May 12, 2021.
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#pragma once
-
-namespace GpgFrontend {
-/**
- * @brief
- *
- */
-class GPGFRONTEND_CORE_EXPORT GpgTOFUInfo {
- public:
- /**
- * @brief
- *
- * @return unsigned
- */
- [[nodiscard]] unsigned GetValidity() const;
- /**
- * @brief
- *
- * @return unsigned
- */
- [[nodiscard]] unsigned GetPolicy() const;
-
- /**
- * @brief
- *
- * @return unsigned long
- */
- [[nodiscard]] unsigned long GetSignCount() const;
-
- /**
- * @brief
- *
- * @return unsigned long
- */
- [[nodiscard]] unsigned long GetEncrCount() const;
-
- /**
- * @brief
- *
- * @return unsigned long
- */
- [[nodiscard]] unsigned long GetSignFirst() const;
-
- /**
- * @brief
- *
- * @return unsigned long
- */
- [[nodiscard]] unsigned long GetSignLast() const;
-
- /**
- * @brief
- *
- * @return unsigned long
- */
- [[nodiscard]] unsigned long GetEncrLast() const;
-
- /**
- * @brief
- *
- * @return std::string
- */
- [[nodiscard]] std::string GetDescription() const;
-
- /**
- * @brief Construct a new Gpg T O F U Info object
- *
- */
- GpgTOFUInfo();
-
- /**
- * @brief Construct a new Gpg T O F U Info object
- *
- * @param tofu_info
- */
- explicit GpgTOFUInfo(gpgme_tofu_info_t tofu_info);
-
- /**
- * @brief Construct a new Gpg T O F U Info object
- *
- * @param o
- */
- GpgTOFUInfo(GpgTOFUInfo&& o) noexcept;
-
- /**
- * @brief Construct a new Gpg T O F U Info object
- *
- */
- GpgTOFUInfo(const GpgTOFUInfo&) = delete;
-
- /**
- * @brief
- *
- * @param o
- * @return GpgTOFUInfo&
- */
- GpgTOFUInfo& operator=(GpgTOFUInfo&& o) noexcept;
-
- /**
- * @brief
- *
- * @return GpgTOFUInfo&
- */
- GpgTOFUInfo& operator=(const GpgTOFUInfo&) = delete;
-
- private:
- using SubkeyRefHandler =
- std::unique_ptr<struct _gpgme_tofu_info,
- std::function<void(gpgme_tofu_info_t)>>; ///<
-
- SubkeyRefHandler _tofu_info_ref = nullptr; ///<
-};
-
-} // namespace GpgFrontend
diff --git a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp
index d2bbf07b..0c3af463 100644
--- a/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp
+++ b/src/ui/dialog/gnupg/GnuPGControllerDialog.cpp
@@ -279,47 +279,33 @@ void GnuPGControllerDialog::slot_update_custom_gnupg_install_path_label(
}
void GnuPGControllerDialog::set_settings() {
- auto& settings = GlobalSettingStation::GetInstance().GetMainSettings();
-
- try {
- bool non_ascii_when_export =
- settings.lookup("general.non_ascii_when_export");
- GF_UI_LOG_DEBUG("non_ascii_when_export: {}", non_ascii_when_export);
- if (non_ascii_when_export)
- ui_->asciiModeCheckBox->setCheckState(Qt::Checked);
- } catch (...) {
- GF_UI_LOG_ERROR("setting operation error: non_ascii_when_export");
- }
+ auto& settings_station = GlobalSettingStation::GetInstance();
+
+ bool non_ascii_when_export =
+ settings_station.LookupSettings("general.non_ascii_when_export", true);
+ GF_UI_LOG_DEBUG("non_ascii_when_export: {}", non_ascii_when_export);
+ if (non_ascii_when_export) ui_->asciiModeCheckBox->setCheckState(Qt::Checked);
- try {
- bool use_custom_key_database_path =
- settings.lookup("general.use_custom_key_database_path");
- if (use_custom_key_database_path)
- ui_->keyDatabseUseCustomCheckBox->setCheckState(Qt::Checked);
- } catch (...) {
- GF_UI_LOG_ERROR("setting operation error: use_custom_key_database_path");
+ bool const use_custom_key_database_path = settings_station.LookupSettings(
+ "general.use_custom_key_database_path", false);
+ if (use_custom_key_database_path) {
+ ui_->keyDatabseUseCustomCheckBox->setCheckState(Qt::Checked);
}
this->slot_update_custom_key_database_path_label(
ui_->keyDatabseUseCustomCheckBox->checkState());
- try {
- bool use_custom_gnupg_install_path =
- settings.lookup("general.use_custom_gnupg_install_path");
- if (use_custom_gnupg_install_path)
- ui_->useCustomGnuPGInstallPathCheckBox->setCheckState(Qt::Checked);
- } catch (...) {
- GF_UI_LOG_ERROR("setting operation error: use_custom_gnupg_install_path");
+ bool const use_custom_gnupg_install_path = settings_station.LookupSettings(
+ "general.use_custom_gnupg_install_path", false);
+ if (use_custom_gnupg_install_path) {
+ ui_->useCustomGnuPGInstallPathCheckBox->setCheckState(Qt::Checked);
}
- try {
- bool use_pinentry_as_password_input_dialog =
- settings.lookup("general.use_pinentry_as_password_input_dialog");
- if (use_pinentry_as_password_input_dialog)
- ui_->usePinentryAsPasswordInputDialogCheckBox->setCheckState(Qt::Checked);
- } catch (...) {
- GF_UI_LOG_ERROR(
- "setting operation error: use_pinentry_as_password_input_dialog");
+ bool const use_pinentry_as_password_input_dialog =
+ settings_station.LookupSettings(
+ "general.use_pinentry_as_password_input_dialog", false);
+ if (use_pinentry_as_password_input_dialog) {
+ ui_->usePinentryAsPasswordInputDialogCheckBox->setCheckState(Qt::Checked);
}
this->slot_update_custom_gnupg_install_path_label(
diff --git a/src/ui/dialog/settings/SettingsAdvanced.cpp b/src/ui/dialog/settings/SettingsAdvanced.cpp
index f7c6eeaa..6d8a2b4a 100644
--- a/src/ui/dialog/settings/SettingsAdvanced.cpp
+++ b/src/ui/dialog/settings/SettingsAdvanced.cpp
@@ -55,15 +55,17 @@ AdvancedTab::AdvancedTab(QWidget* parent) : QWidget(parent) {
}
void AdvancedTab::SetSettings() {
- int stegano_checked = GlobalSettingStation::GetInstance().LookupSettings(
- "advanced.stegano_checked", false);
+ auto const stegano_checked =
+ GlobalSettingStation::GetInstance().LookupSettings(
+ "advanced.stegano_checked", false);
if (stegano_checked) stegano_check_box_->setCheckState(Qt::Checked);
- int auto_pubkey_exchange_checked =
+ auto const auto_pubkey_exchange_checked =
GlobalSettingStation::GetInstance().LookupSettings(
"advanced.auto_pubkey_exchange_checked", false);
- if (auto_pubkey_exchange_checked)
+ if (auto_pubkey_exchange_checked) {
auto_pubkey_exchange_check_box_->setCheckState(Qt::Checked);
+ }
}
void AdvancedTab::ApplySettings() {
@@ -71,23 +73,24 @@ void AdvancedTab::ApplySettings() {
GpgFrontend::GlobalSettingStation::GetInstance().GetMainSettings();
if (!settings.exists("advanced") ||
- settings.lookup("advanced").getType() != libconfig::Setting::TypeGroup)
+ settings.lookup("advanced").getType() != libconfig::Setting::TypeGroup) {
settings.add("advanced", libconfig::Setting::TypeGroup);
+ }
auto& advanced = settings["advanced"];
- if (!advanced.exists("stegano_checked"))
+ if (!advanced.exists("stegano_checked")) {
advanced.add("stegano_checked", libconfig::Setting::TypeBoolean) =
stegano_check_box_->isChecked();
- else {
+ } else {
advanced["stegano_checked"] = stegano_check_box_->isChecked();
}
- if (!advanced.exists("auto_pubkey_exchange_checked"))
+ if (!advanced.exists("auto_pubkey_exchange_checked")) {
advanced.add("auto_pubkey_exchange_checked",
libconfig::Setting::TypeBoolean) =
auto_pubkey_exchange_check_box_->isChecked();
- else {
+ } else {
advanced["auto_pubkey_exchange_checked"] =
auto_pubkey_exchange_check_box_->isChecked();
}
diff --git a/src/ui/dialog/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp
index 84d79f17..6ce04f45 100644
--- a/src/ui/dialog/settings/SettingsAppearance.cpp
+++ b/src/ui/dialog/settings/SettingsAppearance.cpp
@@ -28,7 +28,6 @@
#include "SettingsAppearance.h"
-#include "core/function/GlobalSettingStation.h"
#include "ui/struct/SettingsObject.h"
#include "ui_AppearanceSettings.h"
@@ -76,8 +75,10 @@ AppearanceTab::AppearanceTab(QWidget* parent)
void AppearanceTab::SetSettings() {
SettingsObject general_settings_state("general_settings_state");
- int width = general_settings_state.Check("icon_size").Check("width", 24),
- height = general_settings_state.Check("icon_size").Check("height", 24);
+ int const width =
+ general_settings_state.Check("icon_size").Check("width", 24);
+ int const height =
+ general_settings_state.Check("icon_size").Check("height", 24);
auto icon_size = QSize(width, height);
@@ -94,7 +95,7 @@ void AppearanceTab::SetSettings() {
}
// icon_style
- int s_icon_style =
+ int const s_icon_style =
general_settings_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
@@ -112,19 +113,21 @@ void AppearanceTab::SetSettings() {
break;
}
- bool window_save = general_settings_state.Check("window_save", true);
+ bool const window_save = general_settings_state.Check("window_save", true);
if (window_save) ui_->windowStateCheckBox->setCheckState(Qt::Checked);
auto info_board_info_font_size =
general_settings_state.Check("info_board").Check("font_size", 10);
- if (info_board_info_font_size < 9 || info_board_info_font_size > 18)
+ if (info_board_info_font_size < 9 || info_board_info_font_size > 18) {
info_board_info_font_size = 10;
+ }
ui_->fontSizeInformationBoardSpinBox->setValue(info_board_info_font_size);
auto text_editor_info_font_size =
general_settings_state.Check("text_editor").Check("font_size", 10);
- if (text_editor_info_font_size < 9 || text_editor_info_font_size > 18)
+ if (text_editor_info_font_size < 9 || text_editor_info_font_size > 18) {
text_editor_info_font_size = 10;
+ }
ui_->fontSizeTextEditorLabelSpinBox->setValue(text_editor_info_font_size);
}
diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp
index 9815ba76..daf5ac86 100644
--- a/src/ui/dialog/settings/SettingsDialog.cpp
+++ b/src/ui/dialog/settings/SettingsDialog.cpp
@@ -31,7 +31,6 @@
#include "core/GpgConstants.h"
#include "core/GpgModel.h"
#include "core/function/GlobalSettingStation.h"
-#include "ui/dialog/settings/SettingsAdvanced.h"
#include "ui/dialog/settings/SettingsAppearance.h"
#include "ui/dialog/settings/SettingsGeneral.h"
#include "ui/dialog/settings/SettingsKeyServer.h"
@@ -48,9 +47,9 @@ SettingsDialog::SettingsDialog(QWidget* parent)
key_server_tab_ = new KeyserverTab();
network_tab_ = new NetworkTab();
- auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(tab_widget_);
- mainLayout->stretch(0);
+ auto* main_layout = new QVBoxLayout();
+ main_layout->addWidget(tab_widget_);
+ main_layout->stretch(0);
tab_widget_->addTab(general_tab_, _("General"));
tab_widget_->addTab(appearance_tab_, _("Appearance"));
@@ -73,7 +72,7 @@ SettingsDialog::SettingsDialog(QWidget* parent)
setWindowTitle(_("Preference"));
#endif
- setLayout(mainLayout);
+ setLayout(main_layout);
// slots for handling the restart needed member
this->slot_set_restart_needed(0);
@@ -89,8 +88,9 @@ SettingsDialog::SettingsDialog(QWidget* parent)
// restart core and ui
connect(general_tab_, &GeneralTab::SignalDeepRestartNeeded, this,
[=](bool needed) {
- if (needed && restart_needed_ < kDeepRestartCode)
+ if (needed && restart_needed_ < kDeepRestartCode) {
this->restart_needed_ = kDeepRestartCode;
+ }
});
// announce main window
@@ -102,7 +102,9 @@ SettingsDialog::SettingsDialog(QWidget* parent)
this->show();
}
-int SettingsDialog::get_restart_needed() const { return this->restart_needed_; }
+auto SettingsDialog::get_restart_needed() const -> int {
+ return this->restart_needed_;
+}
void SettingsDialog::slot_set_restart_needed(int mode) {
this->restart_needed_ = mode;
@@ -114,19 +116,17 @@ void SettingsDialog::SlotAccept() {
key_server_tab_->ApplySettings();
network_tab_->ApplySettings();
- GF_UI_LOG_DEBUG("apply done");
-
// write settings to filesystem
GlobalSettingStation::GetInstance().SyncSettings();
GF_UI_LOG_DEBUG("restart needed: {}", get_restart_needed());
- if (get_restart_needed()) {
+ if (get_restart_needed() != 0) {
emit SignalRestartNeeded(get_restart_needed());
}
close();
}
-QHash<QString, QString> SettingsDialog::ListLanguages() {
+auto SettingsDialog::ListLanguages() -> QHash<QString, QString> {
QHash<QString, QString> languages;
languages.insert(QString(), _("System Default"));
@@ -136,21 +136,15 @@ QHash<QString, QString> SettingsDialog::ListLanguages() {
auto locale_dir = QDir(QString::fromStdString(locale_path.string()));
QStringList file_names = locale_dir.entryList(QStringList("*"));
- for (int i = 0; i < file_names.size(); ++i) {
- QString locale = file_names[i];
- GF_UI_LOG_DEBUG("locale: {}", locale.toStdString());
+ for (const auto& locale : file_names) {
+ GF_UI_LOG_DEBUG("get locale from locale directory: {}",
+ locale.toStdString());
if (locale == "." || locale == "..") continue;
- // this works in qt 4.8
- QLocale q_locale(locale);
+ QLocale const q_locale(locale);
if (q_locale.nativeCountryName().isEmpty()) continue;
-#if QT_VERSION < 0x040800
- QString language =
- QLocale::languageToString(q_locale.language()) + " (" + locale +
- ")"; //+ " (" + QLocale::languageToString(q_locale.language()) + ")";
-#else
+
auto language = q_locale.nativeLanguageName() + " (" + locale + ")";
-#endif
languages.insert(locale, language);
}
return languages;
diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index dd326567..174c9c39 100644
--- a/src/ui/dialog/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
@@ -48,8 +48,6 @@ GeneralTab::GeneralTab(QWidget* parent)
ui_->setupUi(this);
ui_->cacheBox->setTitle(_("Cache"));
- ui_->saveCheckedKeysCheckBox->setText(
- _("Save checked private keys on exit and restore them on next start."));
ui_->clearGpgPasswordCacheCheckBox->setText(
_("Clear gpg password cache when closing GpgFrontend."));
ui_->restoreTextEditorPageCheckBox->setText(
diff --git a/src/ui/function/ArchiveDirectory.cpp b/src/ui/function/ArchiveDirectory.cpp
index 89bb7ff2..f0151705 100644
--- a/src/ui/function/ArchiveDirectory.cpp
+++ b/src/ui/function/ArchiveDirectory.cpp
@@ -80,6 +80,7 @@ auto ArchiveDirectory::Exec(const std::filesystem::path& target_directory)
GF_UI_LOG_ERROR("archive caught exception error");
return {false, {}};
}
+ return {true, {}};
}
} // namespace GpgFrontend::UI \ No newline at end of file