1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-30 10:52:00 +00:00

build: use RECOMMENDED_MACOSX_DEPLOYMENT_TARGET (#5282)

This commit is contained in:
Cœur 2023-04-15 04:02:52 +08:00 committed by GitHub
parent d72cb67cfb
commit 6156d90917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 162 deletions

View file

@ -8,7 +8,7 @@ if(POLICY CMP0114)
endif()
# Value should follow latest stable Xcode's RECOMMENDED_MACOSX_DEPLOYMENT_TARGET
set(MACOS_SUPPORT_MINIMUM 10.13)
set(MACOS_SUPPORT_MINIMUM 10.14.6)
# The value of this variable should be set prior to the first project() command invocation.
# See: https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html

View file

@ -3907,7 +3907,7 @@
INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional";
INFOPLIST_PREFIX_HEADER = libtransmission/version.h;
INFOPLIST_PREPROCESS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"$(inherited)",
@ -4114,7 +4114,7 @@
INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional";
INFOPLIST_PREFIX_HEADER = libtransmission/version.h;
INFOPLIST_PREPROCESS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
OTHER_CFLAGS = (
"$(inherited)",
"-DFMT_HEADER_ONLY",
@ -4214,7 +4214,7 @@
INFOPLIST_OTHER_PREPROCESSOR_FLAGS = "-traditional";
INFOPLIST_PREFIX_HEADER = libtransmission/version.h;
INFOPLIST_PREPROCESS = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MACOSX_DEPLOYMENT_TARGET = 10.14.6;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = (
"$(inherited)",

View file

@ -26,7 +26,7 @@ typedef NS_ENUM(unsigned int, addType) { //
};
@interface Controller
: NSObject<NSApplicationDelegate, NSUserNotificationCenterDelegate, NSPopoverDelegate, NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate, SUUpdaterDelegate>
: NSObject<NSApplicationDelegate, NSPopoverDelegate, NSSharingServiceDelegate, NSSharingServicePickerDelegate, NSSoundDelegate, NSToolbarDelegate, NSWindowDelegate, QLPreviewPanelDataSource, QLPreviewPanelDelegate, VDKQueueDelegate, SUUpdaterDelegate>
- (void)openFiles:(NSArray<NSString*>*)filenames addType:(addType)type forcePath:(NSString*)path;

View file

@ -825,30 +825,22 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
- (void)applicationWillFinishLaunching:(NSNotification*)notification
{
// user notifications
if (@available(macOS 10.14, *))
{
UNUserNotificationCenter.currentNotificationCenter.delegate = self;
UNNotificationAction* actionShow = [UNNotificationAction actionWithIdentifier:@"actionShow"
title:NSLocalizedString(@"Show", "notification button")
options:UNNotificationActionOptionForeground];
UNNotificationCategory* categoryShow = [UNNotificationCategory categoryWithIdentifier:@"categoryShow" actions:@[ actionShow ]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
[UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:[NSSet setWithObject:categoryShow]];
[UNUserNotificationCenter.currentNotificationCenter
requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
completionHandler:^(BOOL /*granted*/, NSError* _Nullable error) {
if (error.code > 0)
{
NSLog(@"UserNotifications not configured: %@", error.localizedDescription);
}
}];
}
else
{
// Fallback on earlier versions
NSUserNotificationCenter.defaultUserNotificationCenter.delegate = self;
}
UNUserNotificationCenter.currentNotificationCenter.delegate = self;
UNNotificationAction* actionShow = [UNNotificationAction actionWithIdentifier:@"actionShow"
title:NSLocalizedString(@"Show", "notification button")
options:UNNotificationActionOptionForeground];
UNNotificationCategory* categoryShow = [UNNotificationCategory categoryWithIdentifier:@"categoryShow" actions:@[ actionShow ]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
[UNUserNotificationCenter.currentNotificationCenter setNotificationCategories:[NSSet setWithObject:categoryShow]];
[UNUserNotificationCenter.currentNotificationCenter
requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge)
completionHandler:^(BOOL /*granted*/, NSError* _Nullable error) {
if (error.code > 0)
{
NSLog(@"UserNotifications not configured: %@", error.localizedDescription);
}
}];
}
- (void)applicationDidFinishLaunching:(NSNotification*)notification
@ -886,24 +878,12 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
andEventID:kAEOpenContents];
//if we were opened from a user notification, do the corresponding action
if (@available(macOS 10.14, *))
UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter
didReceiveNotificationResponse:launchNotification withCompletionHandler:^{
}];
}
}
else
{
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter
didActivateNotification:launchNotification];
}
[self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter didReceiveNotificationResponse:launchNotification
withCompletionHandler:^{
}];
}
//auto importing
@ -2385,19 +2365,14 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
willPresentNotification:(UNNotification*)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler API_AVAILABLE(macos(10.14))
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
{
completionHandler(-1);
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center shouldPresentNotification:(NSUserNotification*)notification
{
return YES;
}
- (void)userNotificationCenter:(UNUserNotificationCenter*)center
didReceiveNotificationResponse:(UNNotificationResponse*)response
withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(macos(10.14))
withCompletionHandler:(void (^)(void))completionHandler
{
if (!response.notification.request.content.userInfo.count)
{
@ -2416,23 +2391,6 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
completionHandler();
}
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification
{
if (!notification.userInfo)
{
return;
}
if (notification.activationType == NSUserNotificationActivationTypeActionButtonClicked) //reveal
{
[self didActivateNotificationByActionShowWithUserInfo:notification.userInfo];
}
else if (notification.activationType == NSUserNotificationActivationTypeContentsClicked)
{
[self didActivateNotificationByDefaultActionWithUserInfo:notification.userInfo];
}
}
- (void)didActivateNotificationByActionShowWithUserInfo:(NSDictionary<NSString*, id>*)userInfo
{
Torrent* torrent = [self torrentForHash:userInfo[@"Hash"]];
@ -2555,30 +2513,15 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
userInfo[@"Location"] = location;
}
if (@available(macOS 10.14, *))
{
NSString* identifier = [@"Download Complete " stringByAppendingString:torrent.hashString];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
content.categoryIdentifier = @"categoryShow";
content.userInfo = userInfo;
NSString* identifier = [@"Download Complete " stringByAppendingString:torrent.hashString];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
content.categoryIdentifier = @"categoryShow";
content.userInfo = userInfo;
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
else
{
// Fallback on earlier versions
NSUserNotification* userNotification = [[NSUserNotification alloc] init];
userNotification.title = title;
userNotification.informativeText = body;
userNotification.hasActionButton = YES;
userNotification.actionButtonTitle = NSLocalizedString(@"Show", "notification button");
userNotification.userInfo = userInfo;
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:userNotification];
}
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
if (!self.fWindow.mainWindow)
{
@ -2622,30 +2565,15 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
userInfo[@"Location"] = location;
}
if (@available(macOS 10.14, *))
{
NSString* identifier = [@"Seeding Complete " stringByAppendingString:torrent.hashString];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
content.categoryIdentifier = @"categoryShow";
content.userInfo = userInfo;
NSString* identifier = [@"Seeding Complete " stringByAppendingString:torrent.hashString];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
content.categoryIdentifier = @"categoryShow";
content.userInfo = userInfo;
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
else
{
// Fallback on earlier versions
NSUserNotification* userNotification = [[NSUserNotification alloc] init];
userNotification.title = title;
userNotification.informativeText = body;
userNotification.hasActionButton = YES;
userNotification.actionButtonTitle = NSLocalizedString(@"Show", "notification button");
userNotification.userInfo = userInfo;
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:userNotification];
}
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
//removing from the list calls fullUpdateUI
if (torrent.removeWhenFinishSeeding)
@ -3503,26 +3431,13 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
NSLocalizedString(@"Speed Limit Auto Disabled", "notification title");
NSString* body = NSLocalizedString(@"Bandwidth settings changed", "notification description");
if (@available(macOS 10.14, *))
{
NSString* identifier = @"Bandwidth settings changed";
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
NSString* identifier = @"Bandwidth settings changed";
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = title;
content.body = body;
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
else
{
// Fallback on earlier versions
NSUserNotification* notification = [[NSUserNotification alloc] init];
notification.title = title;
notification.informativeText = body;
notification.hasActionButton = NO;
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
}
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
}
@ -3630,26 +3545,13 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
NSString* notificationTitle = NSLocalizedString(@"Torrent File Auto Added", "notification title");
if (@available(macOS 10.14, *))
{
NSString* identifier = [@"Torrent File Auto Added " stringByAppendingString:file];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = notificationTitle;
content.body = file;
NSString* identifier = [@"Torrent File Auto Added " stringByAppendingString:file];
UNMutableNotificationContent* content = [UNMutableNotificationContent new];
content.title = notificationTitle;
content.body = file;
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
else
{
// Fallback on earlier versions
NSUserNotification* notification = [[NSUserNotification alloc] init];
notification.title = notificationTitle;
notification.informativeText = file;
notification.hasActionButton = NO;
[NSUserNotificationCenter.defaultUserNotificationCenter deliverNotification:notification];
}
UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:nil];
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:nil];
}
}

View file

@ -8,14 +8,7 @@
- (BOOL)isDarkMode
{
if (@available(macOS 10.14, *))
{
return [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua];
}
else
{
return NO;
}
return [self.effectiveAppearance.name isEqualToString:NSAppearanceNameDarkAqua];
}
@end