Revert "meh"

This reverts commit 9d9204430e.
This commit is contained in:
Nayla Hanegan 2024-05-23 17:35:22 -04:00
commit d07549505a
9 changed files with 219 additions and 2 deletions

View file

@ -241,6 +241,11 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters,
ConnectMenuBar();
ConnectHotkeys();
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this,
[](Qt::ColorScheme colorScheme) { Settings::Instance().ApplyStyle(); });
#endif
connect(m_cheats_manager, &CheatsManager::OpenGeneralSettings, this,
&MainWindow::ShowGeneralWindow);
@ -1860,6 +1865,29 @@ QSize MainWindow::sizeHint() const
#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.ApplyStyle();
// force the colors in the Skylander window to update
if (m_skylander_window)
m_skylander_window->RefreshList();
}
// 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