diff options
Diffstat (limited to 'src/corelib/kernel/qcore_mac_objc.mm')
-rw-r--r-- | src/corelib/kernel/qcore_mac_objc.mm | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 6b11e90a4e..4ca9c2e996 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -40,8 +40,13 @@ #include <private/qcore_mac_p.h> -#ifdef Q_OS_OSX -#include <AppKit/NSText.h> +#ifdef Q_OS_MACOS +# include <AppKit/AppKit.h> +# if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSApplication (MojaveForwardDeclarations) +@property (strong) NSAppearance *effectiveAppearance NS_AVAILABLE_MAC(10_14); +@end +# endif #endif #if defined(QT_PLATFORM_UIKIT) @@ -91,19 +96,20 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY QT_END_NAMESPACE QT_USE_NAMESPACE @interface QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) : NSObject -{ +@end + +@implementation QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) { NSAutoreleasePool **m_pool; } --(id)initWithPool:(NSAutoreleasePool**)pool; -@end -@implementation QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) --(id)initWithPool:(NSAutoreleasePool**)pool + +- (instancetype)initWithPool:(NSAutoreleasePool **)pool { - if (self = [super init]) + if ((self = [self init])) m_pool = pool; return self; } --(void)dealloc + +- (void)dealloc { if (*m_pool) { // The pool is still valid, which means we're not being drained from @@ -165,6 +171,16 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool) } #endif // !QT_NO_DEBUG_STREAM +#ifdef Q_OS_MACOS +bool qt_mac_applicationIsInDarkMode() +{ + if (__builtin_available(macOS 10.14, *)) + return [NSApp.effectiveAppearance.name hasSuffix:@"DarkAqua"]; + else + return false; +} +#endif + bool qt_apple_isApplicationExtension() { static bool isExtension = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSExtension"]; @@ -432,16 +448,23 @@ void qt_apple_check_os_version() version / 10000, version / 100 % 100, version % 100}; const NSOperatingSystemVersion current = NSProcessInfo.processInfo.operatingSystemVersion; if (![NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:required]) { - fprintf(stderr, "You can't use this version of %s with this version of %s. " - "You have %s %ld.%ld.%ld. Qt requires %s %ld.%ld.%ld or later.\n", - (reinterpret_cast<const NSString *>( - NSBundle.mainBundle.infoDictionary[@"CFBundleName"]).UTF8String), - os, - os, long(current.majorVersion), long(current.minorVersion), long(current.patchVersion), - os, long(required.majorVersion), long(required.minorVersion), long(required.patchVersion)); - abort(); + NSDictionary *plist = NSBundle.mainBundle.infoDictionary; + NSString *applicationName = plist[@"CFBundleDisplayName"]; + if (!applicationName) + applicationName = plist[@"CFBundleName"]; + if (!applicationName) + applicationName = NSProcessInfo.processInfo.processName; + + fprintf(stderr, "Sorry, \"%s\" can not be run on this version of %s. " + "Qt requires %s %ld.%ld.%ld or later, you have %s %ld.%ld.%ld.\n", + applicationName.UTF8String, os, + os, long(required.majorVersion), long(required.minorVersion), long(required.patchVersion), + os, long(current.majorVersion), long(current.minorVersion), long(current.patchVersion)); + + exit(1); } } +Q_CONSTRUCTOR_FUNCTION(qt_apple_check_os_version); // ------------------------------------------------------------------------- |