Qt: Tidy up theme change workaround

This commit is contained in:
Stenzek 2024-06-24 13:25:16 +10:00
parent db305660c1
commit 8c1228a7aa
No known key found for this signature in database
2 changed files with 11 additions and 14 deletions

View File

@ -27,10 +27,7 @@ LogWindow::LogWindow(bool attach_to_main)
Log::RegisterCallback(&LogWindow::logCallback, this); Log::RegisterCallback(&LogWindow::logCallback, this);
} }
LogWindow::~LogWindow() LogWindow::~LogWindow() = default;
{
Log::UnregisterCallback(&LogWindow::logCallback, this);
}
void LogWindow::updateSettings() void LogWindow::updateSettings()
{ {

View File

@ -39,7 +39,6 @@
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
#include <QtCore/QOperatingSystemVersion>
#include <QtCore/QUrl> #include <QtCore/QUrl>
#include <QtGui/QActionGroup> #include <QtGui/QActionGroup>
#include <QtGui/QCursor> #include <QtGui/QCursor>
@ -134,7 +133,6 @@ MainWindow::~MainWindow()
Assert(!m_display_widget); Assert(!m_display_widget);
Assert(!m_debugger_window); Assert(!m_debugger_window);
cancelGameListRefresh(); cancelGameListRefresh();
destroySubWindows();
// we compare here, since recreate destroys the window later // we compare here, since recreate destroys the window later
if (g_main_window == this) if (g_main_window == this)
@ -596,6 +594,7 @@ void MainWindow::onSystemDestroyed()
// If we're closing or in batch mode, quit the whole application now. // If we're closing or in batch mode, quit the whole application now.
if (m_is_closing || QtHost::InBatchMode()) if (m_is_closing || QtHost::InBatchMode())
{ {
destroySubWindows();
quit(); quit();
return; return;
} }
@ -744,6 +743,11 @@ void MainWindow::recreate()
new_main_window->show(); new_main_window->show();
deleteLater(); deleteLater();
// Recreate log window as well. Then make sure we're still on top.
LogWindow::updateSettings();
new_main_window->raise();
new_main_window->activateWindow();
// Reload the sources we just closed. // Reload the sources we just closed.
g_emu_thread->reloadInputSources(); g_emu_thread->reloadInputSources();
@ -2204,21 +2208,17 @@ void MainWindow::connectSignals()
void MainWindow::setTheme(const QString& theme) void MainWindow::setTheme(const QString& theme)
{ {
[[maybe_unused]] const QString old_theme = [[maybe_unused]] const QString old_style_name = qApp->style()->name();
QString::fromStdString(Host::GetStringSettingValue("UI", "Theme", InterfaceSettingsWidget::DEFAULT_THEME_NAME));
Host::SetBaseStringSettingValue("UI", "Theme", theme.toUtf8().constData()); Host::SetBaseStringSettingValue("UI", "Theme", theme.toUtf8().constData());
Host::CommitBaseSettingChanges(); Host::CommitBaseSettingChanges();
updateTheme(); updateTheme();
#ifdef _WIN32 #ifdef _WIN32
if (((old_theme.isEmpty() && QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) || // Work around a bug where the background colour of menus is broken when changing to/from the windowsvista theme.
old_theme == QStringLiteral("windowsvista")) != const QString new_style_name = qApp->style()->name();
((old_theme.isEmpty() && QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows11) || if ((old_style_name == QStringLiteral("windowsvista")) != (new_style_name == QStringLiteral("windowsvista")))
theme == QStringLiteral("windowsvista")))
{
recreate(); recreate();
}
#endif #endif
} }