mirror of
https://github.com/transmission/transmission
synced 2025-01-03 13:35:36 +00:00
Update some selector-based alerts to block-based
This commit is contained in:
parent
7b815b766c
commit
4a4233feae
1 changed files with 24 additions and 25 deletions
|
@ -735,16 +735,21 @@ static void removeKeRangerRansomware()
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"CheckQuitDownloading"] ? downloading > 0 : active > 0)
|
if ([fDefaults boolForKey: @"CheckQuitDownloading"] ? downloading > 0 : active > 0)
|
||||||
{
|
{
|
||||||
NSString * message = active == 1
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
|
alert.alertStyle = NSAlertStyleInformational;
|
||||||
|
alert.messageText = NSLocalizedString(@"Are you sure you want to quit?", "Confirm Quit panel -> title");
|
||||||
|
alert.informativeText = active == 1
|
||||||
? NSLocalizedString(@"There is an active transfer that will be paused on quit."
|
? NSLocalizedString(@"There is an active transfer that will be paused on quit."
|
||||||
" The transfer will automatically resume on the next launch.", "Confirm Quit panel -> message")
|
" The transfer will automatically resume on the next launch.", "Confirm Quit panel -> message")
|
||||||
: [NSString stringWithFormat: NSLocalizedString(@"There are %d active transfers that will be paused on quit."
|
: [NSString stringWithFormat: NSLocalizedString(@"There are %d active transfers that will be paused on quit."
|
||||||
" The transfers will automatically resume on the next launch.", "Confirm Quit panel -> message"), active];
|
" The transfers will automatically resume on the next launch.", "Confirm Quit panel -> message"), active];
|
||||||
|
[alert addButtonWithTitle:NSLocalizedString(@"Quit", "Confirm Quit panel -> button")];
|
||||||
|
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Confirm Quit panel -> button")];
|
||||||
|
|
||||||
NSBeginAlertSheet(NSLocalizedString(@"Are you sure you want to quit?", "Confirm Quit panel -> title"),
|
[alert beginSheetModalForWindow:fWindow
|
||||||
NSLocalizedString(@"Quit", "Confirm Quit panel -> button"),
|
completionHandler:^(NSModalResponse returnCode) {
|
||||||
NSLocalizedString(@"Cancel", "Confirm Quit panel -> button"), nil, fWindow, self,
|
[NSApp replyToApplicationShouldTerminate: returnCode == NSAlertFirstButtonReturn];
|
||||||
@selector(quitSheetDidEnd:returnCode:contextInfo:), nil, nil, @"%@", message);
|
}];
|
||||||
return NSTerminateLater;
|
return NSTerminateLater;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,11 +757,6 @@ static void removeKeRangerRansomware()
|
||||||
return NSTerminateNow;
|
return NSTerminateNow;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
|
||||||
{
|
|
||||||
[NSApp replyToApplicationShouldTerminate: returnCode == NSAlertDefaultReturn];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) applicationWillTerminate: (NSNotification *) notification
|
- (void) applicationWillTerminate: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
fQuitting = YES;
|
fQuitting = YES;
|
||||||
|
@ -1401,9 +1401,6 @@ static void removeKeRangerRansomware()
|
||||||
|
|
||||||
if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0)
|
if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0)
|
||||||
{
|
{
|
||||||
NSDictionary * dict = @{ @"Torrents" : torrents,
|
|
||||||
@"DeleteData" : @(deleteData) };
|
|
||||||
|
|
||||||
NSString * title, * message;
|
NSString * title, * message;
|
||||||
|
|
||||||
const NSUInteger selected = [torrents count];
|
const NSUInteger selected = [torrents count];
|
||||||
|
@ -1446,9 +1443,19 @@ static void removeKeRangerRansomware()
|
||||||
"Removal confirm panel -> message part 2")];
|
"Removal confirm panel -> message part 2")];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSBeginAlertSheet(title, NSLocalizedString(@"Remove", "Removal confirm panel -> button"),
|
NSAlert *alert = [[NSAlert alloc] init];
|
||||||
NSLocalizedString(@"Cancel", "Removal confirm panel -> button"), nil, fWindow, self,
|
alert.alertStyle = NSAlertStyleInformational;
|
||||||
nil, @selector(removeSheetDidEnd:returnCode:contextInfo:), (__bridge_retained void *)(dict), @"%@", message);
|
alert.messageText = title;
|
||||||
|
alert.informativeText = message;
|
||||||
|
[alert addButtonWithTitle:NSLocalizedString(@"Remove", "Removal confirm panel -> button")];
|
||||||
|
[alert addButtonWithTitle:NSLocalizedString(@"Cancel", "Removal confirm panel -> button")];
|
||||||
|
|
||||||
|
[alert beginSheetModalForWindow:fWindow
|
||||||
|
completionHandler:^(NSModalResponse returnCode) {
|
||||||
|
if (returnCode == NSAlertFirstButtonReturn) {
|
||||||
|
[self confirmRemoveTorrents: torrents deleteData: deleteData];
|
||||||
|
}
|
||||||
|
}];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1456,14 +1463,6 @@ static void removeKeRangerRansomware()
|
||||||
[self confirmRemoveTorrents: torrents deleteData: deleteData];
|
[self confirmRemoveTorrents: torrents deleteData: deleteData];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
|
||||||
{
|
|
||||||
NSDictionary * dict = (__bridge_transfer NSDictionary *)contextInfo;
|
|
||||||
NSArray * torrents = dict[@"Torrents"];
|
|
||||||
if (returnCode == NSAlertDefaultReturn)
|
|
||||||
[self confirmRemoveTorrents: torrents deleteData: [dict[@"DeleteData"] boolValue]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
|
- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
|
||||||
{
|
{
|
||||||
//miscellaneous
|
//miscellaneous
|
||||||
|
|
Loading…
Reference in a new issue