#4109 Recycle: Show a confirmation dialog

This commit is contained in:
Mitchell Livingston 2011-03-17 01:06:31 +00:00
parent 13514e16a7
commit 5d85125777
3 changed files with 74 additions and 21 deletions

View File

@ -1233,13 +1233,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
if ([fDefaults boolForKey: @"CheckRemove"]) if ([fDefaults boolForKey: @"CheckRemove"])
{ {
NSInteger active = 0, downloading = 0; NSUInteger active = 0, downloading = 0;
for (Torrent * torrent in torrents) for (Torrent * torrent in torrents)
if ([torrent isActive]) if ([torrent isActive])
{ {
active++; ++active;
if (![torrent isSeeding]) if (![torrent isSeeding])
downloading++; ++downloading;
} }
if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0) if ([fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0)
@ -1272,19 +1272,19 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
{ {
if (deleteData) if (deleteData)
title = [NSString stringWithFormat: title = [NSString stringWithFormat:
NSLocalizedString(@"Are you sure you want to remove %d transfers from the transfer list" NSLocalizedString(@"Are you sure you want to remove %@ transfers from the transfer list"
" and trash the data files?", "Removal confirm panel -> title"), selected]; " and trash the data files?", "Removal confirm panel -> title"), [NSString formattedUInteger: selected]];
else else
title = [NSString stringWithFormat: title = [NSString stringWithFormat:
NSLocalizedString(@"Are you sure you want to remove %d transfers from the transfer list?", NSLocalizedString(@"Are you sure you want to remove %@ transfers from the transfer list?",
"Removal confirm panel -> title"), selected]; "Removal confirm panel -> title"), [NSString formattedUInteger: selected]];
if (selected == active) if (selected == active)
message = [NSString stringWithFormat: NSLocalizedString(@"There are %d active transfers.", message = [NSString stringWithFormat: NSLocalizedString(@"There are %@ active transfers.",
"Removal confirm panel -> message part 1"), active]; "Removal confirm panel -> message part 1"), [NSString formattedUInteger: active]];
else else
message = [NSString stringWithFormat: NSLocalizedString(@"There are %d transfers (%d active).", message = [NSString stringWithFormat: NSLocalizedString(@"There are %@ transfers (%@ active).",
"Removal confirm panel -> message part 1"), selected, active]; "Removal confirm panel -> message part 1"), [NSString formattedUInteger: selected], [NSString formattedUInteger: active]];
message = [message stringByAppendingFormat: @" %@", message = [message stringByAppendingFormat: @" %@",
NSLocalizedString(@"Once removed, continuing the transfers will require the torrent files or magnet links.", NSLocalizedString(@"Once removed, continuing the transfers will require the torrent files or magnet links.",
"Removal confirm panel -> message part 2")]; "Removal confirm panel -> message part 2")];
@ -1368,6 +1368,43 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
if ([torrent isFinishedSeeding]) if ([torrent isFinishedSeeding])
[torrents addObject: torrent]; [torrents addObject: torrent];
if ([fDefaults boolForKey: @"WarningRemoveCompleted"])
{
NSString * message, * info;
if ([torrents count] == 1)
{
NSString * torrentName = [[torrents objectAtIndex: 0] name];
message = [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove \"%@\" from the transfer list?",
"Remove completed confirm panel -> title"), torrentName];
info = NSLocalizedString(@"Once removed, continuing the transfer will require the torrent file or magnet link.",
"Remove completed confirm panel -> message");
}
else
{
message = [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove %@ completed transfers from the transfer list?",
"Remove completed confirm panel -> title"), [NSString formattedUInteger: [torrents count]]];
info = NSLocalizedString(@"Once removed, continuing the transfers will require the torrent files or magnet links.",
"Remove completed confirm panel -> message");
}
NSAlert * alert = [[[NSAlert alloc] init] autorelease];
[alert setMessageText: message];
[alert setInformativeText: info];
[alert setAlertStyle: NSWarningAlertStyle];
[alert addButtonWithTitle: NSLocalizedString(@"Remove", "Remove completed confirm panel -> button")];
[alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Remove completed confirm panel -> button")];
[alert setShowsSuppressionButton: YES];
const NSInteger returnCode = [alert runModal];
if ([[alert suppressionButton] state])
[fDefaults setBool: NO forKey: @"WarningRemoveCompleted"];
if (returnCode != NSAlertFirstButtonReturn)
return;
}
[self confirmRemoveTorrents: torrents deleteData: NO]; [self confirmRemoveTorrents: torrents deleteData: NO];
} }
@ -3604,6 +3641,19 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
//remove all completed transfers item //remove all completed transfers item
if (action == @selector(clearCompleted:)) if (action == @selector(clearCompleted:))
{ {
//append or remove ellipsis when needed
NSString * title = [menuItem title], * ellipsis = [NSString ellipsis];
if ([fDefaults boolForKey: @"WarningRemoveCompleted"])
{
if (![title hasSuffix: ellipsis])
[menuItem setTitle: [title stringByAppendingEllipsis]];
}
else
{
if ([title hasSuffix: ellipsis])
[menuItem setTitle: [title substringToIndex: [title rangeOfString: ellipsis].location]];
}
for (Torrent * torrent in fTorrents) for (Torrent * torrent in fTorrents)
if ([torrent isFinishedSeeding]) if ([torrent isFinishedSeeding])
return YES; return YES;

View File

@ -16,10 +16,10 @@
<true/> <true/>
<key>BindPort</key> <key>BindPort</key>
<integer>51413</integer> <integer>51413</integer>
<key>BlocklistNew</key>
<false/>
<key>BlocklistAutoUpdate</key> <key>BlocklistAutoUpdate</key>
<false/> <false/>
<key>BlocklistNew</key>
<false/>
<key>CheckDownload</key> <key>CheckDownload</key>
<false/> <false/>
<key>CheckQuit</key> <key>CheckQuit</key>
@ -98,12 +98,12 @@
<string>Constant</string> <string>Constant</string>
<key>NatTraversal</key> <key>NatTraversal</key>
<true/> <true/>
<key>PEXGlobal</key>
<true/>
<key>PeersTorrent</key> <key>PeersTorrent</key>
<integer>60</integer> <integer>60</integer>
<key>PeersTotal</key> <key>PeersTotal</key>
<integer>200</integer> <integer>200</integer>
<key>PEXGlobal</key>
<true/>
<key>PiecesBar</key> <key>PiecesBar</key>
<false/> <false/>
<key>PiecesViewShowAvailability</key> <key>PiecesViewShowAvailability</key>
@ -132,16 +132,14 @@
<false/> <false/>
<key>RPCAuthorize</key> <key>RPCAuthorize</key>
<false/> <false/>
<key>RPCUseWhitelist</key>
<false/>
<key>RPCPort</key> <key>RPCPort</key>
<integer>9091</integer> <integer>9091</integer>
<key>RPCUsername</key> <key>RPCUsername</key>
<string>admin</string> <string>admin</string>
<key>RPCUseWhitelist</key>
<false/>
<key>RPCWebDiscovery</key> <key>RPCWebDiscovery</key>
<false/> <false/>
<key>SUEnableAutomaticChecks</key>
<true/>
<key>SeedingSound</key> <key>SeedingSound</key>
<string>Submarine</string> <string>Submarine</string>
<key>ShowInspector</key> <key>ShowInspector</key>
@ -160,12 +158,12 @@
<false/> <false/>
<key>SpeedLimitAuto</key> <key>SpeedLimitAuto</key>
<false/> <false/>
<key>SpeedLimitAutoDay</key>
<integer>127</integer>
<key>SpeedLimitAutoOffDate</key> <key>SpeedLimitAutoOffDate</key>
<date>2000-01-01T13:00:00Z</date> <date>2000-01-01T13:00:00Z</date>
<key>SpeedLimitAutoOnDate</key> <key>SpeedLimitAutoOnDate</key>
<date>2000-01-01T03:00:00Z</date> <date>2000-01-01T03:00:00Z</date>
<key>SpeedLimitAutoDay</key>
<integer>127</integer>
<key>SpeedLimitDownloadLimit</key> <key>SpeedLimitDownloadLimit</key>
<integer>10</integer> <integer>10</integer>
<key>SpeedLimitUploadLimit</key> <key>SpeedLimitUploadLimit</key>
@ -176,6 +174,8 @@
<true/> <true/>
<key>StatusLabel</key> <key>StatusLabel</key>
<string>RatioTotal</string> <string>RatioTotal</string>
<key>SUEnableAutomaticChecks</key>
<true/>
<key>UploadLimit</key> <key>UploadLimit</key>
<integer>50</integer> <integer>50</integer>
<key>UseIncompleteDownloadFolder</key> <key>UseIncompleteDownloadFolder</key>
@ -198,6 +198,8 @@
<true/> <true/>
<key>WarningRemainingSpace</key> <key>WarningRemainingSpace</key>
<true/> <true/>
<key>WarningRemoveCompleted</key>
<true/>
<key>WarningRemoveTrackers</key> <key>WarningRemoveTrackers</key>
<true/> <true/>
<key>WarningResetStats</key> <key>WarningResetStats</key>

View File

@ -727,6 +727,7 @@ tr_session * fHandle;
[fDefaults removeObjectForKey: @"WarningCreatorPrivateBlankAddress"]; [fDefaults removeObjectForKey: @"WarningCreatorPrivateBlankAddress"];
[fDefaults removeObjectForKey: @"WarningRemoveTrackers"]; [fDefaults removeObjectForKey: @"WarningRemoveTrackers"];
[fDefaults removeObjectForKey: @"WarningInvalidOpen"]; [fDefaults removeObjectForKey: @"WarningInvalidOpen"];
[fDefaults removeObjectForKey: @"WarningRemoveCompleted"];
[fDefaults removeObjectForKey: @"WarningDonate"]; [fDefaults removeObjectForKey: @"WarningDonate"];
//[fDefaults removeObjectForKey: @"WarningLegal"]; //[fDefaults removeObjectForKey: @"WarningLegal"];
} }