diff options
author | saturneric <[email protected]> | 2024-05-03 14:45:48 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-05-03 14:46:40 +0000 |
commit | 526170b9676e7c04f5a6d7d2ba461b3f42cea32c (patch) | |
tree | 095e4448588f4202d5bd930cf83e90dbd37cb224 /src/ui/GpgFrontendUIInit.cpp | |
parent | fix: reset module settings object in a proper way (diff) | |
download | GpgFrontend-526170b9676e7c04f5a6d7d2ba461b3f42cea32c.tar.gz GpgFrontend-526170b9676e7c04f5a6d7d2ba461b3f42cea32c.zip |
feat: support theme changing by user
Diffstat (limited to 'src/ui/GpgFrontendUIInit.cpp')
-rw-r--r-- | src/ui/GpgFrontendUIInit.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp index 32cbc968..7b18e78c 100644 --- a/src/ui/GpgFrontendUIInit.cpp +++ b/src/ui/GpgFrontendUIInit.cpp @@ -110,11 +110,22 @@ void InitGpgFrontendUI(QApplication* /*app*/) { // init locale InitUITranslations(); + auto settings = GlobalSettingStation::GetInstance().GetSettings(); + auto theme = settings.value("appearance/theme").toString(); + #ifdef WINDOWS - // support dark mode on windows - QApplication::setStyle("fusion"); + if (theme.isEmpty()) { + // support dark mode on windows + QApplication::setStyle(QStyleFactory::create("Fusion")); + } #endif + auto available_styles = QStyleFactory::keys(); + for (QString& s : available_styles) s = s.toLower(); + if (!theme.isEmpty() && available_styles.contains(theme)) { + QApplication::setStyle(QStyleFactory::create(theme)); + } + // register meta types qRegisterMetaType<QSharedPointer<GpgPassphraseContext> >( "QSharedPointer<GpgPassphraseContext>"); @@ -125,10 +136,8 @@ void InitGpgFrontendUI(QApplication* /*app*/) { // init common utils CommonUtils::GetInstance(); - auto settings = GlobalSettingStation::GetInstance().GetSettings(); - // application proxy configure - bool proxy_enable = settings.value("proxy/enable", false).toBool(); + auto proxy_enable = settings.value("proxy/enable", false).toBool(); // if enable proxy for application if (proxy_enable) { @@ -138,9 +147,9 @@ void InitGpgFrontendUI(QApplication* /*app*/) { QString proxy_host = settings.value("proxy/proxy_host", QString{}).toString(); int proxy_port = settings.value("prox/port", 0).toInt(); - QString proxy_username = + QString const proxy_username = settings.value("proxy/username", QString{}).toString(); - QString proxy_password = + QString const proxy_password = settings.value("proxy/password", QString{}).toString(); GF_UI_LOG_DEBUG("proxy settings: type {}, host {}, port: {}", proxy_type, proxy_host, proxy_port); @@ -193,7 +202,7 @@ auto RunGpgFrontendUI(QApplication* app) -> int { // pre-check, if application need to restart if (CommonUtils::GetInstance()->isApplicationNeedRestart()) { - GF_UI_LOG_DEBUG("application need to restart, before mian window init"); + GF_UI_LOG_DEBUG("application need to restart, before main window init"); return kDeepRestartCode; } |