|
|
@@ -0,0 +1,58 @@ |
|
|
From 1e0848d745910e942907a81ca4743553ee8e635b Mon Sep 17 00:00:00 2001 |
|
|
From: Gabriel de Dietrich <[email protected]> |
|
|
Date: Fri, 15 Jun 2018 23:15:10 +0200 |
|
|
Subject: [PATCH] macOS: Force light theme on macOS 10.14+ |
|
|
MIME-Version: 1.0 |
|
|
Content-Type: text/plain; charset=utf8 |
|
|
Content-Transfer-Encoding: 8bit |
|
|
|
|
|
Until we can properly fix QPalette and QMacStyle, |
|
|
we should disable dark appearance in Qt applications. |
|
|
|
|
|
Disable by setting NSApp.appearance to aqua, unless |
|
|
dark mode support has been requested via Info.plist |
|
|
or environment variable. |
|
|
|
|
|
Read the NSRequiresAquaSystemAppearance Info.plist |
|
|
key, donât set NSApp.appearance if its value is false. |
|
|
|
|
|
Also check the QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE |
|
|
environment variable and apply similar logic. You then |
|
|
enable dark mode support by setting |
|
|
QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE=0 |
|
|
which is slightly awkward, but matches Info.plist |
|
|
behavior. |
|
|
|
|
|
Task-number: QTBUG-68891 |
|
|
Change-Id: I86dc6cf3dee951d46c953396c57d2c31f2e4afcc |
|
|
--- |
|
|
src/plugins/platforms/cocoa/qcocoaintegration.mm | 13 +++++++++++++ |
|
|
1 file changed, 13 insertions(+) |
|
|
|
|
|
diff --git a/qtbase/src/plugins/platforms/cocoa/qcocoaintegration.mm b/qtbase/src/plugins/platforms/cocoa/qcocoaintegration.mm |
|
|
index 55b3805df3d..54d692f2172 100644 |
|
|
--- a/qtbase/src/plugins/platforms/cocoa/qcocoaintegration.mm |
|
|
+++ b/qtbase/src/plugins/platforms/cocoa/qcocoaintegration.mm |
|
|
@@ -131,6 +131,19 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) |
|
|
NSApplication *cocoaApplication = [QNSApplication sharedApplication]; |
|
|
qt_redirectNSApplicationSendEvent(); |
|
|
|
|
|
+ // Disable dark apperance by default, unless the Info.plist or environment requests that it may be enabled. |
|
|
+ NSNumber *plistRequiresAquaAppearance = |
|
|
+ [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSRequiresAquaSystemAppearance"]; |
|
|
+ bool plistEnableDarkAppearance = plistRequiresAquaAppearance != nil && ![plistRequiresAquaAppearance boolValue]; |
|
|
+ bool hasEnvironmentRequiresAquaAppearance; |
|
|
+ int environmentRequiresAquaAppearance = |
|
|
+ qEnvironmentVariableIntValue("QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE", &hasEnvironmentRequiresAquaAppearance); |
|
|
+ bool environmentEnableDarkAppearance = hasEnvironmentRequiresAquaAppearance && environmentRequiresAquaAppearance == 0; |
|
|
+ bool forceAquaAppearance = !plistEnableDarkAppearance && !environmentEnableDarkAppearance; |
|
|
+ if (forceAquaAppearance) |
|
|
+ if (__builtin_available(macOS 10.14, *)) |
|
|
+ NSApp.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; |
|
|
+ |
|
|
if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { |
|
|
// Applications launched from plain executables (without an app |
|
|
// bundle) are "background" applications that does not take keybaord |
|
|
-- |
|
|
2.16.3 |
|
|
|