Remove qt_mac_applicationIsInDarkMode in favour of QStyleHints::colorScheme()

Now that we have the information available in QStyleHints we don't
need to expose it as a dedicated helper function, and definitely not
in QtCore.

Change-Id: If5ad3991d78810457b51a30aadc3bf3af593940c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Tor Arne Vestbø 2025-04-15 23:21:43 +02:00
parent a7136c3e7b
commit 48f161e129
3 changed files with 4 additions and 9 deletions

View File

@ -323,13 +323,6 @@ QDebug operator<<(QDebug debug, const QCFString &string)
#endif // !QT_NO_DEBUG_STREAM
#if defined(Q_OS_MACOS) && !defined(QT_BOOTSTRAPPED)
bool qt_mac_applicationIsInDarkMode()
{
auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:
@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
return [appearance isEqualToString:NSAppearanceNameDarkAqua];
}
bool qt_mac_runningUnderRosetta()
{
int translated = 0;

View File

@ -185,7 +185,6 @@ private:
};
#ifdef Q_OS_MACOS
Q_CORE_EXPORT bool qt_mac_applicationIsInDarkMode();
Q_CORE_EXPORT bool qt_mac_runningUnderRosetta();
Q_CORE_EXPORT std::optional<uint32_t> qt_mac_sipConfiguration();
#ifdef QT_BUILD_INTERNAL

View File

@ -505,7 +505,10 @@ void QCocoaTheme::requestColorScheme(Qt::ColorScheme scheme)
*/
void QCocoaTheme::updateColorScheme()
{
m_colorScheme = qt_mac_applicationIsInDarkMode() ? Qt::ColorScheme::Dark : Qt::ColorScheme::Light;
auto appearance = [NSApp.effectiveAppearance bestMatchFromAppearancesWithNames:
@[ NSAppearanceNameAqua, NSAppearanceNameDarkAqua ]];
m_colorScheme = [appearance isEqualToString:NSAppearanceNameDarkAqua] ?
Qt::ColorScheme::Dark : Qt::ColorScheme::Light;
}
Qt::ContrastPreference QCocoaTheme::contrastPreference() const