Remove beginSheetModalForWindow: deprecation warnings

This commit is contained in:
Mitchell Livingston 2020-11-22 08:02:29 -05:00
parent a219f4e8e4
commit 185d6b78a5
5 changed files with 45 additions and 80 deletions

View File

@ -40,8 +40,6 @@
- (void) setGroupsMenu;
- (void) changeGroupValue: (id) sender;
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
@end
@implementation AddMagnetWindowController
@ -210,8 +208,13 @@
[alert addButtonWithTitle: NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
[alert setShowsSuppressionButton: YES];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(sameNameAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
}];
}
else
[self confirmAdd];
@ -306,14 +309,4 @@
else;
}
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
}
@end

View File

@ -45,8 +45,6 @@
- (void) setGroupsMenu;
- (void) changeGroupValue: (id) sender;
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
@end
@implementation AddWindowController
@ -200,8 +198,13 @@
[alert addButtonWithTitle: NSLocalizedString(@"Add", "Add torrent -> same name -> button")];
[alert setShowsSuppressionButton: YES];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(sameNameAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
}];
}
else
[self confirmAdd];
@ -384,14 +387,4 @@
}
}
- (void) sameNameAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningFolderDataSameName"];
if (returnCode == NSAlertSecondButtonReturn)
[self performSelectorOnMainThread: @selector(confirmAdd) withObject: nil waitUntilDone: NO];
}
@end

View File

@ -29,7 +29,6 @@
- (id) initWithPrefsController: (PrefsController *) prefsController;
- (void) startDownload;
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info;
@end
@ -118,8 +117,11 @@ BlocklistDownloaderViewController * fBLViewController = nil;
[alert setInformativeText: error];
[alert beginSheetModalForWindow: [fPrefsController window] modalDelegate: self
didEndSelector: @selector(failureSheetClosed:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[fPrefsController window] completionHandler:^(NSModalResponse returnCode) {
[[alert window] orderOut: self];
fBLViewController = nil;
}];
}
@end
@ -147,11 +149,4 @@ BlocklistDownloaderViewController * fBLViewController = nil;
[NSApp beginSheet: fStatusWindow modalForWindow: [fPrefsController window] modalDelegate: nil didEndSelector: nil contextInfo: nil];
}
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
{
[[alert window] orderOut: self];
fBLViewController = nil;
}
@end

View File

@ -36,10 +36,8 @@
+ (NSURL *) chooseFile;
- (void) updateLocationField;
- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
- (void) createReal;
- (void) checkProgress;
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info;
@end
@ -288,8 +286,17 @@ NSMutableSet *creatorWindowControllerSet = nil;
[alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Create torrent -> blank address -> button")];
[alert setShowsSuppressionButton: YES];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(createBlankAddressAlertDidEnd:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
if ([[alert suppressionButton] state] == NSOnState)
{
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorBlankAddress"]; //set regardless of private/public
if ([fPrivateCheck state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"];
}
if (returnCode == NSAlertFirstButtonReturn)
[self performSelectorOnMainThread: @selector(createReal) withObject: nil waitUntilDone: NO];
}];
}
else
[self createReal];
@ -462,20 +469,6 @@ NSMutableSet *creatorWindowControllerSet = nil;
return success ? [panel URLs][0] : nil;
}
- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
if ([[alert suppressionButton] state] == NSOnState)
{
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorBlankAddress"]; //set regardless of private/public
if ([fPrivateCheck state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningCreatorPrivateBlankAddress"];
}
if (returnCode == NSAlertFirstButtonReturn)
[self performSelectorOnMainThread: @selector(createReal) withObject: nil waitUntilDone: NO];
}
- (void) createReal
{
//check if the location currently exists
@ -492,7 +485,7 @@ NSMutableSet *creatorWindowControllerSet = nil;
[[fLocation URLByDeletingLastPathComponent] path]]];
[alert setAlertStyle: NSWarningAlertStyle];
[alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:nil];
return;
}
@ -513,7 +506,7 @@ NSMutableSet *creatorWindowControllerSet = nil;
pathComponents[count-1], pathComponents[count-2]]];
[alert setAlertStyle: NSWarningAlertStyle];
[alert beginSheetModalForWindow: [self window] modalDelegate: self didEndSelector: nil contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:nil];
return;
}
@ -586,8 +579,10 @@ NSMutableSet *creatorWindowControllerSet = nil;
[alert setInformativeText: [NSString stringWithFormat: @"%@ (%d)",
NSLocalizedString(@"An unknown error has occurred.", "Create torrent -> failed -> warning"), fInfo->result]];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(failureSheetClosed:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
[[alert window] orderOut: nil];
[[self window] close];
}];
}
}
else
@ -622,10 +617,4 @@ NSMutableSet *creatorWindowControllerSet = nil;
}
}
- (void) failureSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
{
[[alert window] orderOut: nil];
[[self window] close];
}
@end

View File

@ -32,7 +32,6 @@
- (void) updateStats;
- (void) performResetStats;
- (void) resetSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info;
@end
@ -145,8 +144,15 @@ tr_session * fLib = NULL;
[alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Stats reset -> button")];
[alert setShowsSuppressionButton: YES];
[alert beginSheetModalForWindow: [self window] modalDelegate: self
didEndSelector: @selector(resetSheetClosed:returnCode:contextInfo:) contextInfo: nil];
[alert beginSheetModalForWindow:[self window] completionHandler:^(NSModalResponse returnCode) {
[[alert window] orderOut: nil];
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningResetStats"];
if (returnCode == NSAlertFirstButtonReturn)
[self performResetStats];
}];
}
- (NSString *) windowFrameAutosaveName
@ -215,15 +221,4 @@ tr_session * fLib = NULL;
[self updateStats];
}
- (void) resetSheetClosed: (NSAlert *) alert returnCode: (NSInteger) code contextInfo: (void *) info
{
[[alert window] orderOut: nil];
if ([[alert suppressionButton] state] == NSOnState)
[[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningResetStats"];
if (code == NSAlertFirstButtonReturn)
[self performResetStats];
}
@end