diff --git a/src/libs/utils/theme/theme.cpp b/src/libs/utils/theme/theme.cpp index e45662012e5..3cb43de469c 100644 --- a/src/libs/utils/theme/theme.cpp +++ b/src/libs/utils/theme/theme.cpp @@ -67,6 +67,18 @@ void setThemeApplicationPalette() QApplication::setPalette(m_creatorTheme->palette()); } +static void maybeForceMacOSLight(Theme *theme) +{ +#ifdef Q_OS_MACOS + // Match the native UI theme and palette with the creator + // theme by forcing light aqua for light creator themes. + if (theme && !theme->flag(Theme::DarkUserInterface)) + Internal::forceMacOSLightAquaApperance(); +#else + Q_UNUSED(theme) +#endif +} + void setCreatorTheme(Theme *theme) { if (m_creatorTheme == theme) @@ -74,13 +86,7 @@ void setCreatorTheme(Theme *theme) delete m_creatorTheme; m_creatorTheme = theme; -#ifdef Q_OS_MACOS - // Match the native UI theme and palette with the creator - // theme by forcing light aqua for light creator themes. - if (theme && !theme->flag(Theme::DarkUserInterface)) - Internal::forceMacOSLightAquaApperance(); -#endif - + maybeForceMacOSLight(theme); setThemeApplicationPalette(); } @@ -270,6 +276,12 @@ static QPalette copyPalette(const QPalette &p) return res; } +void Theme::setInitialPalette(Theme *initTheme) +{ + maybeForceMacOSLight(initTheme); + initialPalette(); +} + QPalette Theme::initialPalette() { static QPalette palette = copyPalette(QApplication::palette()); diff --git a/src/libs/utils/theme/theme.h b/src/libs/utils/theme/theme.h index a4fd112786d..3af43ed6f9e 100644 --- a/src/libs/utils/theme/theme.h +++ b/src/libs/utils/theme/theme.h @@ -481,6 +481,8 @@ public: static bool systemUsesDarkMode(); static QPalette initialPalette(); + static void setInitialPalette(Theme *initTheme); + protected: Theme(Theme *originTheme, QObject *parent = nullptr); ThemePrivate *d; diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 3043a7dd1e6..77875a7ac4d 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -160,10 +160,11 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) return false; } const CoreArguments args = parseArguments(arguments); - Theme::initialPalette(); // Initialize palette before setting it Theme *themeFromArg = ThemeEntry::createTheme(args.themeId); - setCreatorTheme(themeFromArg ? themeFromArg - : ThemeEntry::createTheme(ThemeEntry::themeSetting())); + Theme *theme = themeFromArg ? themeFromArg + : ThemeEntry::createTheme(ThemeEntry::themeSetting()); + Theme::setInitialPalette(theme); // Initialize palette before setting it + setCreatorTheme(theme); InfoBar::initialize(ICore::settings()); new ActionManager(this); ActionManager::setPresentationModeEnabled(args.presentationMode);