Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2020-12-24 02:09:51 +0300
committerJanek Bevendorff <janek@jbev.net>2021-01-07 17:22:48 +0300
commit9a7b20cbfdf20467fc2827eb360898cd8aaf5cd8 (patch)
tree75bd17b24165492b2e87c052827a2946ad3a6b32 /src/gui/osutils/winutils
parent80c1b9be6a09cee67411840ecde129bcab70ebe1 (diff)
Add dynamic theme switching on Windows 10
Diffstat (limited to 'src/gui/osutils/winutils')
-rw-r--r--src/gui/osutils/winutils/WinUtils.cpp21
-rw-r--r--src/gui/osutils/winutils/WinUtils.h3
2 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/osutils/winutils/WinUtils.cpp b/src/gui/osutils/winutils/WinUtils.cpp
index 302c3914c..1ccade5f5 100644
--- a/src/gui/osutils/winutils/WinUtils.cpp
+++ b/src/gui/osutils/winutils/WinUtils.cpp
@@ -29,6 +29,8 @@ WinUtils* WinUtils::instance()
{
if (!m_instance) {
m_instance = new WinUtils(qApp);
+ m_instance->m_darkAppThemeActive = m_instance->isDarkMode();
+ m_instance->m_darkSystemThemeActive = m_instance->isStatusBarDark();
#ifdef QT_DEBUG
// Attach console to enable debug output
@@ -63,15 +65,17 @@ bool WinUtils::nativeEventFilter(const QByteArray& eventType, void* message, lon
auto* msg = static_cast<MSG*>(message);
switch (msg->message) {
- /* TODO: indicate dark mode support for black title bar
- case WM_CREATE:
- case WM_INITDIALOG: {
- if (msg->hwnd && winUtils()->isDarkMode()) {
+ case WM_SETTINGCHANGE:
+ if (m_darkAppThemeActive != isDarkMode()) {
+ m_darkAppThemeActive = !m_darkAppThemeActive;
+ emit interfaceThemeChanged();
+ }
+ if (m_darkSystemThemeActive != isStatusBarDark()) {
+ m_darkSystemThemeActive = !m_darkSystemThemeActive;
+ emit statusbarThemeChanged();
}
break;
- }
- */
case WM_HOTKEY:
triggerGlobalShortcut(msg->wParam);
break;
@@ -89,8 +93,9 @@ bool WinUtils::isDarkMode() const
bool WinUtils::isStatusBarDark() const
{
- // TODO: implement
- return isDarkMode();
+ QSettings settings(R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)",
+ QSettings::NativeFormat);
+ return settings.value("SystemUsesLightTheme", 0).toInt() == 0;
}
bool WinUtils::isLaunchAtStartupEnabled() const
diff --git a/src/gui/osutils/winutils/WinUtils.h b/src/gui/osutils/winutils/WinUtils.h
index 9e9f72684..b7ef47573 100644
--- a/src/gui/osutils/winutils/WinUtils.h
+++ b/src/gui/osutils/winutils/WinUtils.h
@@ -72,6 +72,9 @@ private:
int m_nextShortcutId = 1;
QHash<QString, QSharedPointer<globalShortcut>> m_globalShortcuts;
+ bool m_darkAppThemeActive;
+ bool m_darkSystemThemeActive;
+
Q_DISABLE_COPY(WinUtils)
};