aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/GpgFrontendUIInit.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-04-05 05:16:26 +0000
committerSaturneric <[email protected]>2023-04-05 05:16:26 +0000
commit25dc98b395cbd4e60c468d82de7e2c7579350e58 (patch)
tree029683a56ad773aa915c32c93a1bf848def4a7a2 /src/ui/GpgFrontendUIInit.cpp
parentfix: remove 'cached' in codeql ci (diff)
downloadGpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.tar.gz
GpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.zip
feat: simplify settings lookup
Diffstat (limited to 'src/ui/GpgFrontendUIInit.cpp')
-rw-r--r--src/ui/GpgFrontendUIInit.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index c6360ca7..bfe4d828 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -33,6 +33,8 @@
#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_color_sinks.h>
+#include <string>
+
#include "core/GpgConstants.h"
#include "core/function/GlobalSettingStation.h"
#include "core/thread/CtxCheckTask.h"
@@ -74,25 +76,26 @@ void InitGpgFrontendUI(QApplication* app) {
CommonUtils::GetInstance();
// application proxy configure
-
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
- bool proxy_enable = false;
- try {
- proxy_enable = settings.lookup("proxy.enable");
- } catch (...) {
- SPDLOG_ERROR("setting operation error: proxy_enable");
- }
- SPDLOG_DEBUG("loading proxy configure, proxy_enable: {}", proxy_enable);
+ bool proxy_enable =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.enable", false);
// if enable proxy for application
if (proxy_enable) {
try {
- std::string proxy_type = settings.lookup("proxy.proxy_type");
- std::string proxy_host = settings.lookup("proxy.proxy_host");
- int proxy_port = settings.lookup("proxy.port");
- std::string proxy_username = settings.lookup("proxy.username");
- std::string proxy_password = settings.lookup("proxy.password");
-
+ std::string proxy_type =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.proxy_type",
+ std::string{});
+ std::string proxy_host =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.proxy_host",
+ std::string{});
+ int proxy_port =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.port", 0);
+ std::string proxy_username =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.username",
+ std::string{});
+ std::string proxy_password =
+ GlobalSettingStation::GetInstance().LookupSettings("proxy.password",
+ std::string{});
SPDLOG_DEBUG("proxy settings: type {}, host {}, port: {}", proxy_type,
proxy_host, proxy_port);