mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-26 17:46:47 -05:00
Add dynamic theme switching on Windows 10
This commit is contained in:
parent
80c1b9be6a
commit
9a7b20cbfd
4 changed files with 18 additions and 10 deletions
|
|
@ -251,7 +251,7 @@ void ApplicationSettingsWidget::loadSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_generalUi->trayIconAppearance->clear();
|
m_generalUi->trayIconAppearance->clear();
|
||||||
#ifdef Q_OS_MACOS
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
m_generalUi->trayIconAppearance->addItem(tr("Monochrome"), "monochrome");
|
m_generalUi->trayIconAppearance->addItem(tr("Monochrome"), "monochrome");
|
||||||
#else
|
#else
|
||||||
m_generalUi->trayIconAppearance->addItem(tr("Monochrome (light)"), "monochrome-light");
|
m_generalUi->trayIconAppearance->addItem(tr("Monochrome (light)"), "monochrome-light");
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ QIcon Icons::trayIcon(QString style)
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon i;
|
QIcon i;
|
||||||
#ifdef Q_OS_MACOS
|
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||||
if (osUtils->isStatusBarDark()) {
|
if (osUtils->isStatusBarDark()) {
|
||||||
i = icon(QString("keepassxc-monochrome-light%1").arg(style), false);
|
i = icon(QString("keepassxc-monochrome-light%1").arg(style), false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ WinUtils* WinUtils::instance()
|
||||||
{
|
{
|
||||||
if (!m_instance) {
|
if (!m_instance) {
|
||||||
m_instance = new WinUtils(qApp);
|
m_instance = new WinUtils(qApp);
|
||||||
|
m_instance->m_darkAppThemeActive = m_instance->isDarkMode();
|
||||||
|
m_instance->m_darkSystemThemeActive = m_instance->isStatusBarDark();
|
||||||
|
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG
|
||||||
// Attach console to enable debug output
|
// 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);
|
auto* msg = static_cast<MSG*>(message);
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
/* TODO: indicate dark mode support for black title bar
|
case WM_SETTINGCHANGE:
|
||||||
case WM_CREATE:
|
if (m_darkAppThemeActive != isDarkMode()) {
|
||||||
case WM_INITDIALOG: {
|
m_darkAppThemeActive = !m_darkAppThemeActive;
|
||||||
if (msg->hwnd && winUtils()->isDarkMode()) {
|
emit interfaceThemeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_darkSystemThemeActive != isStatusBarDark()) {
|
||||||
|
m_darkSystemThemeActive = !m_darkSystemThemeActive;
|
||||||
|
emit statusbarThemeChanged();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
*/
|
|
||||||
case WM_HOTKEY:
|
case WM_HOTKEY:
|
||||||
triggerGlobalShortcut(msg->wParam);
|
triggerGlobalShortcut(msg->wParam);
|
||||||
break;
|
break;
|
||||||
|
|
@ -89,8 +93,9 @@ bool WinUtils::isDarkMode() const
|
||||||
|
|
||||||
bool WinUtils::isStatusBarDark() const
|
bool WinUtils::isStatusBarDark() const
|
||||||
{
|
{
|
||||||
// TODO: implement
|
QSettings settings(R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)",
|
||||||
return isDarkMode();
|
QSettings::NativeFormat);
|
||||||
|
return settings.value("SystemUsesLightTheme", 0).toInt() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WinUtils::isLaunchAtStartupEnabled() const
|
bool WinUtils::isLaunchAtStartupEnabled() const
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@ private:
|
||||||
int m_nextShortcutId = 1;
|
int m_nextShortcutId = 1;
|
||||||
QHash<QString, QSharedPointer<globalShortcut>> m_globalShortcuts;
|
QHash<QString, QSharedPointer<globalShortcut>> m_globalShortcuts;
|
||||||
|
|
||||||
|
bool m_darkAppThemeActive;
|
||||||
|
bool m_darkSystemThemeActive;
|
||||||
|
|
||||||
Q_DISABLE_COPY(WinUtils)
|
Q_DISABLE_COPY(WinUtils)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue