cocoa/darwin: remove checking for legacy OS versions

Remove redundant OS version checking (via @available) and stop
supporting legacy macOS (< 11) an iOS (< 14) versions that were
already unsupported in previous 6.5 LTS.

Change-Id: I772d6ca9ca638f00116c9782315e0d0b7139fe23
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 95c7e6565dc0a182f6ca8ec7c73dce58ceb04f47)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Vladimir Belyavsky 2024-06-12 20:32:02 +03:00 committed by Qt Cherry-pick Bot
parent 3a70e669ef
commit e05a60c75a
5 changed files with 25 additions and 70 deletions

View File

@ -103,19 +103,15 @@ struct PermissionRequest
- (CLAuthorizationStatus)authorizationStatus
{
if (self.manager) {
if (@available(macOS 11, iOS 14, *))
return self.manager.authorizationStatus;
}
if (self.manager)
return self.manager.authorizationStatus;
return QT_IGNORE_DEPRECATIONS(CLLocationManager.authorizationStatus);
}
- (Qt::PermissionStatus)accuracyAuthorization:(QLocationPermission)permission
{
auto status = CLAccuracyAuthorizationReducedAccuracy;
if (@available(macOS 11, iOS 14, *))
status = self.manager.accuracyAuthorization;
auto status = self.manager.accuracyAuthorization;
switch (status) {
case CLAccuracyAuthorizationFullAccuracy:

View File

@ -455,23 +455,21 @@ const QAppleKeyMapper::KeyMap &QAppleKeyMapper::keyMapForKey(VirtualKeyCode virt
if (err == noErr && actualStringLength)
carbonUnicodeKey = QChar(unicodeString[0]);
if (@available(macOS 10.15, *)) {
if (canMapCocoaEvent) {
// Until we've verified that the Cocoa API works as expected
// we first run the event through the Carbon APIs and then
// compare the results to Cocoa.
auto cocoaModifiers = toCocoaModifiers(qtModifiers);
auto *charactersWithModifiers = [NSApp.currentEvent charactersByApplyingModifiers:cocoaModifiers];
if (canMapCocoaEvent) {
// Until we've verified that the Cocoa API works as expected
// we first run the event through the Carbon APIs and then
// compare the results to Cocoa.
auto cocoaModifiers = toCocoaModifiers(qtModifiers);
auto *charactersWithModifiers = [NSApp.currentEvent charactersByApplyingModifiers:cocoaModifiers];
QChar cocoaUnicodeKey;
if (charactersWithModifiers.length > 0)
cocoaUnicodeKey = QChar([charactersWithModifiers characterAtIndex:0]);
QChar cocoaUnicodeKey;
if (charactersWithModifiers.length > 0)
cocoaUnicodeKey = QChar([charactersWithModifiers characterAtIndex:0]);
if (cocoaUnicodeKey != carbonUnicodeKey) {
qCWarning(lcQpaKeyMapper) << "Mismatch between Cocoa" << cocoaUnicodeKey
<< "and Carbon" << carbonUnicodeKey << "for virtual key" << virtualKey
<< "with" << qtModifiers;
}
if (cocoaUnicodeKey != carbonUnicodeKey) {
qCWarning(lcQpaKeyMapper) << "Mismatch between Cocoa" << cocoaUnicodeKey
<< "and Carbon" << carbonUnicodeKey << "for virtual key" << virtualKey
<< "with" << qtModifiers;
}
}

View File

@ -951,15 +951,13 @@ void QCoreTextFontDatabase::populateThemeFonts()
};
// Try populating the font variants based on its UI design trait, if available
if (@available(macos 10.15, ios 13.0, *)) {
auto fontTraits = QCFType<CFDictionaryRef>(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontTraitsAttribute));
static const NSString *kUIFontDesignTrait = @"NSCTFontUIFontDesignTrait";
if (id uiFontDesignTrait = fontTraits.as<NSDictionary*>()[kUIFontDesignTrait]) {
QCFType<CTFontDescriptorRef> designTraitDescriptor = CTFontDescriptorCreateWithAttributes(
CFDictionaryRef(@{ (id)kCTFontTraitsAttribute: @{ kUIFontDesignTrait: uiFontDesignTrait }
}));
addFontVariants(designTraitDescriptor);
}
auto fontTraits = QCFType<CFDictionaryRef>(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontTraitsAttribute));
static const NSString *kUIFontDesignTrait = @"NSCTFontUIFontDesignTrait";
if (id uiFontDesignTrait = fontTraits.as<NSDictionary*>()[kUIFontDesignTrait]) {
QCFType<CTFontDescriptorRef> designTraitDescriptor = CTFontDescriptorCreateWithAttributes(
CFDictionaryRef(@{ (id)kCTFontTraitsAttribute: @{ kUIFontDesignTrait: uiFontDesignTrait }
}));
addFontVariants(designTraitDescriptor);
}
if (themeFontVariants.isEmpty()) {

View File

@ -170,8 +170,7 @@ bool QCocoaMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality w
else if ([button.keyEquivalent isEqualToString:@"\e"])
button.keyEquivalent = @"";
if (@available(macOS 11, *))
button.hasDestructiveAction = role == DestructiveRole;
button.hasDestructiveAction = role == DestructiveRole;
// The NSModalResponse of showing an NSAlert normally depends on the order of the
// button that was clicked, starting from the right with NSAlertFirstButtonReturn (1000),

View File

@ -197,38 +197,6 @@ QCocoaScreen::~QCocoaScreen()
dispatch_release(m_displayLinkSource);
}
static QString displayName(CGDirectDisplayID displayID)
{
QIOType<io_iterator_t> iterator;
if (IOServiceGetMatchingServices(kIOMainPortDefault,
IOServiceMatching("IODisplayConnect"), &iterator))
return QString();
QIOType<io_service_t> display;
while ((display = IOIteratorNext(iterator)) != 0)
{
NSDictionary *info = [(__bridge NSDictionary*)IODisplayCreateInfoDictionary(
display, kIODisplayOnlyPreferredName) autorelease];
if ([[info objectForKey:@kDisplayVendorID] unsignedIntValue] != CGDisplayVendorNumber(displayID))
continue;
if ([[info objectForKey:@kDisplayProductID] unsignedIntValue] != CGDisplayModelNumber(displayID))
continue;
if ([[info objectForKey:@kDisplaySerialNumber] unsignedIntValue] != CGDisplaySerialNumber(displayID))
continue;
NSDictionary *localizedNames = [info objectForKey:@kDisplayProductName];
if (![localizedNames count])
break; // Correct screen, but no name in dictionary
return QString::fromNSString([localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]]);
}
return QString();
}
void QCocoaScreen::update(CGDirectDisplayID displayId)
{
if (displayId != m_displayId) {
@ -274,11 +242,7 @@ void QCocoaScreen::update(CGDirectDisplayID displayId)
float refresh = CGDisplayModeGetRefreshRate(displayMode);
m_refreshRate = refresh > 0 ? refresh : 60.0;
m_rotation = CGDisplayRotation(displayId);
if (@available(macOS 10.15, *))
m_name = QString::fromNSString(nsScreen.localizedName);
else
m_name = displayName(m_displayId);
m_name = QString::fromNSString(nsScreen.localizedName);
const bool didChangeGeometry = m_geometry != previousGeometry || m_availableGeometry != previousAvailableGeometry;