mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-17 11:56:13 -04:00
Add dynamic theme switching on Windows 10
This commit is contained in:
parent
80c1b9be6a
commit
9a7b20cbfd
@ -251,7 +251,7 @@ void ApplicationSettingsWidget::loadSettings()
|
||||
}
|
||||
|
||||
m_generalUi->trayIconAppearance->clear();
|
||||
#ifdef Q_OS_MACOS
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||
m_generalUi->trayIconAppearance->addItem(tr("Monochrome"), "monochrome");
|
||||
#else
|
||||
m_generalUi->trayIconAppearance->addItem(tr("Monochrome (light)"), "monochrome-light");
|
||||
|
@ -80,7 +80,7 @@ QIcon Icons::trayIcon(QString style)
|
||||
}
|
||||
|
||||
QIcon i;
|
||||
#ifdef Q_OS_MACOS
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||
if (osUtils->isStatusBarDark()) {
|
||||
i = icon(QString("keepassxc-monochrome-light%1").arg(style), false);
|
||||
} else {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user