Qt: Fix game list background on MacOS

This commit is contained in:
Stenzek
2025-11-22 14:26:06 +10:00
parent 30a0b94a4f
commit 6146d33fa2
4 changed files with 13 additions and 11 deletions

View File

@@ -1930,7 +1930,7 @@ void GameListWidget::updateBackground(bool reload_image)
m_ui.stack->setAutoFillBackground(true);
m_list_view->setAlternatingRowColors(false);
if (QtHost::IsStyleSheetApplicationTheme())
if (QtHost::HasGlobalStylesheet())
{
// Stylesheets override palette, so we need to set background: transparent on the grid and list view.
const QString style_sheet = QStringLiteral("QAbstractScrollArea { background-color: transparent; }");

View File

@@ -349,14 +349,11 @@ void UpdateApplicationTheme();
bool IsDarkApplicationTheme();
/// Returns true if the application theme is using stylesheet overrides.
bool IsStyleSheetApplicationTheme();
bool HasGlobalStylesheet();
/// Sets the icon theme, based on the current style (light/dark).
void UpdateThemeOnStyleChange();
/// Returns true if using the native theme and it has stylesheet overrides.
bool NativeThemeStylesheetNeedsUpdate();
/// Sets batch mode (exit after game shutdown).
bool InBatchMode();

View File

@@ -16,6 +16,7 @@
namespace QtHost {
static void SetThemeAttributes(bool is_stylesheet_theme, bool is_variable_color_theme, bool is_dark_theme);
static bool NativeThemeStylesheetNeedsUpdate();
static void SetStyleFromSettings();
static QString GetNativeThemeStylesheet();
@@ -827,10 +828,14 @@ QTextBrowser {
#endif
else
{
SetThemeAttributes(false, true, false);
const QString stylesheet = GetNativeThemeStylesheet();
SetThemeAttributes(!stylesheet.isEmpty(), true, false);
qApp->setStyle(s_state.unthemed_style_name);
qApp->setPalette(s_state.unthemed_palette);
qApp->setStyleSheet(GetNativeThemeStylesheet());
// Cleared above.
if (!stylesheet.isEmpty())
qApp->setStyleSheet(stylesheet);
}
}
@@ -847,7 +852,7 @@ bool QtHost::IsDarkApplicationTheme()
return (palette.windowText().color().value() > palette.window().color().value());
}
bool QtHost::IsStyleSheetApplicationTheme()
bool QtHost::HasGlobalStylesheet()
{
return s_state.is_stylesheet_theme;
}

View File

@@ -246,7 +246,7 @@ void QtUtils::SetMessageBoxStyle(QMessageBox* const dlg)
{
#ifdef __APPLE__
// Can't have a stylesheet set even if it doesn't affect the widget.
if (QtHost::IsStyleSheetApplicationTheme() || QtHost::NativeThemeStylesheetNeedsUpdate())
if (QtHost::HasGlobalStylesheet())
{
dlg->setStyleSheet("");
dlg->setAttribute(Qt::WA_StyleSheet, false);
@@ -292,7 +292,7 @@ QMessageBox* QtUtils::NewMessageBox(QMessageBox::Icon icon, const QString& title
void QtUtils::StylePopupMenu(QMenu* menu)
{
if (QtHost::IsStyleSheetApplicationTheme())
if (QtHost::HasGlobalStylesheet())
{
menu->setWindowFlags(menu->windowFlags() | Qt::NoDropShadowWindowHint | Qt::FramelessWindowHint);
menu->setAttribute(Qt::WA_TranslucentBackground, true);
@@ -316,7 +316,7 @@ void QtUtils::StyleChildMenus(QWidget* widget)
QMenu* QtUtils::NewPopupMenu(QWidget* parent, bool delete_on_close /*= true*/)
{
QMenu* menu = new QMenu(parent);
if (QtHost::IsStyleSheetApplicationTheme())
if (QtHost::HasGlobalStylesheet())
{
menu->setWindowFlags(menu->windowFlags() | Qt::NoDropShadowWindowHint | Qt::FramelessWindowHint);
menu->setAttribute(Qt::WA_TranslucentBackground, true);