From 78e14360442d5493f5d80993eeafb81c39ab1546 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Thu, 10 Sep 2020 02:42:53 -0300 Subject: [PATCH] macosx: Replace deprecated NSRunAlertPanel call in Controller.m --- macosx/Controller.m | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 5c5f39bb1..b7e212f24 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -853,11 +853,15 @@ static void removeKeRangerRansomware() fPendingTorrentDownloads = nil; } - NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"), - [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.", - "Download not a torrent -> message"), suggestedName, - [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]], - NSLocalizedString(@"OK", "Download not a torrent -> button"), nil, nil); + NSString * message = [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.", + "Download not a torrent -> message"), suggestedName, + [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; + + NSAlert * alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Download not a torrent -> button")]; + [alert setMessageText: NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title")]; + [alert setInformativeText: message]; + [alert runModal]; } else [download setDestination: [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]] @@ -872,11 +876,16 @@ static void removeKeRangerRansomware() - (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error { - NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Torrent download error -> title"), - [NSString stringWithFormat: NSLocalizedString(@"The torrent could not be downloaded from %@: %@.", - "Torrent download failed -> message"), - [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding], - [error localizedDescription]], NSLocalizedString(@"OK", "Torrent download failed -> button"), nil, nil); + NSString * message = [NSString stringWithFormat: NSLocalizedString(@"The torrent could not be downloaded from %@: %@.", + "Torrent download failed -> message"), + [[[[download request] URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding], + [error localizedDescription]]; + + NSAlert * alert = [[NSAlert alloc] init]; + [alert addButtonWithTitle: NSLocalizedString(@"OK", "Torrent download failed -> button")]; + [alert setMessageText: NSLocalizedString(@"Torrent download failed", "Torrent download error -> title")]; + [alert setInformativeText: message]; + [alert runModal]; [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]]; if ([fPendingTorrentDownloads count] == 0)