diff options
author | Jonathan White <support@dmapps.us> | 2020-06-04 15:10:43 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-06-04 17:03:40 +0300 |
commit | 2073f2ddc30f6922eda89ee3c66e80f9cb426859 (patch) | |
tree | f28e002fb0955f30c3ba96777735d2f3c3a97a28 /src/gui/Application.cpp | |
parent | 6f5e13815c656486b8bd1fb0a0c2b3bcfb06dfd9 (diff) |
Fix theming with Qt 5.15
* Fixes #4765
* Fixes #4766
Diffstat (limited to 'src/gui/Application.cpp')
-rw-r--r-- | src/gui/Application.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/gui/Application.cpp b/src/gui/Application.cpp index 4a382567e..273ab8763 100644 --- a/src/gui/Application.cpp +++ b/src/gui/Application.cpp @@ -68,26 +68,6 @@ Application::Application(int& argc, char** argv) registerUnixSignals(); #endif - QString appTheme = config()->get(Config::GUI_ApplicationTheme).toString(); - if (appTheme == "auto") { - if (osUtils->isDarkMode()) { - setStyle(new DarkStyle); - m_darkTheme = true; - } else { - setStyle(new LightStyle); - } - } else if (appTheme == "light") { - setStyle(new LightStyle); - } else if (appTheme == "dark") { - setStyle(new DarkStyle); - m_darkTheme = true; - } else { - // Classic mode, only check for dark theme when not on Windows -#ifndef Q_OS_WIN - m_darkTheme = osUtils->isDarkMode(); -#endif - } - QString userName = qgetenv("USER"); if (userName.isEmpty()) { userName = qgetenv("USERNAME"); @@ -162,6 +142,32 @@ Application::~Application() } } +void Application::applyTheme() +{ + QString appTheme = config()->get(Config::GUI_ApplicationTheme).toString(); + if (appTheme == "auto") { + if (osUtils->isDarkMode()) { + setStyle(new DarkStyle); + m_darkTheme = true; + } else { + setStyle(new LightStyle); + } + } else if (appTheme == "light") { + setStyle(new LightStyle); + } else if (appTheme == "dark") { + setStyle(new DarkStyle); + m_darkTheme = true; + } else { + // Classic mode, don't check for dark theme on Windows + // because Qt 5.x does not support it +#ifndef Q_OS_WIN + m_darkTheme = osUtils->isDarkMode(); +#endif + } + + setPalette(style()->standardPalette()); +} + bool Application::event(QEvent* event) { // Handle Apple QFileOpenEvent from finder (double click on .kdbx file) |