diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-07-31 23:22:53 +0200 |
|---|---|---|
| committer | Admiral H. Curtiss <pikachu025@gmail.com> | 2023-08-12 16:54:54 +0200 |
| commit | 250d5f55deb0febb9ea94090332bbbbd91d1af5c (patch) | |
| tree | c0c031c47e4adeb49a42404eeb4e50f19f7a7ff9 /Source/Core/DolphinQt/MainWindow.cpp | |
| parent | e2fb8fab2f695ee53ab0aa7a5ff2fe752c719ce8 (diff) | |
DolphinQt: Switch dark/light theme when Windows theme changes.
Diffstat (limited to 'Source/Core/DolphinQt/MainWindow.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/MainWindow.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index b193fe15c7..1f5223179c 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1715,6 +1715,30 @@ QSize MainWindow::sizeHint() const return QSize(800, 600); } +#ifdef _WIN32 +bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, qintptr* result) +{ + auto* msg = reinterpret_cast<MSG*>(message); + if (msg && msg->message == WM_SETTINGCHANGE && msg->lParam != NULL && + std::wstring_view(L"ImmersiveColorSet") + .compare(reinterpret_cast<const wchar_t*>(msg->lParam)) == 0) + { + // Windows light/dark theme has changed. Update our flag and refresh the theme. + auto& settings = Settings::Instance(); + const bool was_dark_before = settings.IsSystemDark(); + settings.UpdateSystemDark(); + if (settings.IsSystemDark() != was_dark_before) + settings.SetCurrentUserStyle(settings.GetCurrentUserStyle()); + + // TODO: When switching from light to dark, the window decorations remain light. Qt seems very + // convinced that it needs to change these in response to this message, so even if we set them + // to dark here, Qt sets them back to light afterwards. + } + + return false; +} +#endif + void MainWindow::OnBootGameCubeIPL(DiscIO::Region region) { StartGame(std::make_unique<BootParameters>(BootParameters::IPL{region})); |
