diff --git a/macosx/Controller.m b/macosx/Controller.m index 557b1e31d..2337327b6 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -258,14 +258,19 @@ static void sleepCallBack(void * controller, io_service_t y, { if (!fUpdateInProgress && [fDefaults boolForKey: @"CheckQuit"]) { - int active = 0; + int active = 0, downloading = 0; Torrent * torrent; NSEnumerator * enumerator = [fTorrents objectEnumerator]; while ((torrent = [enumerator nextObject])) if ([torrent isActive]) + { active++; + if (![torrent isSeeding]) + downloading++; + } - if (active > 0) + BOOL shouldAsk = [fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0; + if (shouldAsk) { NSString * message = active == 1 ? @"There is an active transfer. Do you really want to quit?" @@ -516,15 +521,23 @@ static void sleepCallBack(void * controller, io_service_t y, deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent { NSArray * torrents = [[self torrentsAtIndexes: indexSet] retain]; - int active = 0; + int active = 0, downloading = 0; - Torrent * torrent; - NSEnumerator * enumerator = [torrents objectEnumerator]; - while ((torrent = [enumerator nextObject])) - if ([torrent isActive]) - active++; + if ([fDefaults boolForKey: @"CheckRemove"]) + { + Torrent * torrent; + NSEnumerator * enumerator = [torrents objectEnumerator]; + while ((torrent = [enumerator nextObject])) + if ([torrent isActive]) + { + active++; + if (![torrent isSeeding]) + downloading++; + } + } - if (active > 0 && [fDefaults boolForKey: @"CheckRemove"]) + BOOL shouldAsk = [fDefaults boolForKey: @"CheckRemoveDownloading"] ? downloading > 0 : active > 0; + if (shouldAsk) { NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: torrents, @"Torrents", diff --git a/macosx/Defaults.plist b/macosx/Defaults.plist index 17662f1ba..abff4432c 100644 --- a/macosx/Defaults.plist +++ b/macosx/Defaults.plist @@ -12,8 +12,12 @@ CheckQuit + CheckQuitDownloading + CheckRemove + CheckRemoveDownloading + CheckUpload DeleteOriginalTorrent @@ -30,8 +34,6 @@ Info InfoVisible - Move - MoveChoice Constant MoveFolder diff --git a/macosx/English.lproj/PrefsWindow.nib/classes.nib b/macosx/English.lproj/PrefsWindow.nib/classes.nib index 55638deba..406a7ec04 100644 --- a/macosx/English.lproj/PrefsWindow.nib/classes.nib +++ b/macosx/English.lproj/PrefsWindow.nib/classes.nib @@ -32,9 +32,11 @@ fNetworkView = NSView; fPortField = NSTextField; fQuitCheck = NSButton; + fQuitDownloadingCheck = NSButton; fRatioCheck = NSButton; fRatioField = NSTextField; fRemoveCheck = NSButton; + fRemoveDownloadingCheck = NSButton; fStartMatrix = NSMatrix; fTransfersView = NSView; fUpdatePopUp = NSPopUpButton; diff --git a/macosx/English.lproj/PrefsWindow.nib/info.nib b/macosx/English.lproj/PrefsWindow.nib/info.nib index 733b5a034..68a22b4ec 100644 --- a/macosx/English.lproj/PrefsWindow.nib/info.nib +++ b/macosx/English.lproj/PrefsWindow.nib/info.nib @@ -7,7 +7,7 @@ IBEditorPositions 28 - 308 472 535 212 0 0 1152 842 + 308 454 535 247 0 0 1152 842 41 308 405 535 345 0 0 1152 842 66 @@ -17,7 +17,6 @@ 446.1 IBOpenObjects - 41 28 IBSystem Version diff --git a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib index 782f2db34..8e89ccb62 100644 Binary files a/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib and b/macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib differ diff --git a/macosx/PrefsController.h b/macosx/PrefsController.h index 15e75cc3a..d86da5adb 100644 --- a/macosx/PrefsController.h +++ b/macosx/PrefsController.h @@ -35,6 +35,7 @@ IBOutlet NSPopUpButton * fFolderPopUp; IBOutlet NSButton * fQuitCheck, * fRemoveCheck, + * fQuitDownloadingCheck, * fRemoveDownloadingCheck, * fBadgeDownloadRateCheck, * fBadgeUploadRateCheck, * fCopyTorrentCheck, * fDeleteOriginalTorrentCheck; IBOutlet NSPopUpButton * fUpdatePopUp; diff --git a/macosx/PrefsController.m b/macosx/PrefsController.m index 5fbc70b80..9921f36f5 100644 --- a/macosx/PrefsController.m +++ b/macosx/PrefsController.m @@ -139,8 +139,16 @@ [fRatioField setFloatValue: [fDefaults floatForKey: @"RatioLimit"]]; //set remove and quit prompts - [fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"]]; - [fRemoveCheck setState: [fDefaults boolForKey: @"CheckRemove"]]; + BOOL isQuitCheck = [fDefaults boolForKey: @"CheckQuit"], + isRemoveCheck = [fDefaults boolForKey: @"CheckRemove"]; + + [fQuitCheck setState: isQuitCheck]; + [fRemoveCheck setState: isRemoveCheck]; + + [fQuitDownloadingCheck setState: [fDefaults boolForKey: @"CheckQuitDownloading"]]; + [fQuitDownloadingCheck setEnabled: isQuitCheck]; + [fRemoveDownloadingCheck setState: [fDefaults boolForKey: @"CheckRemoveDownloading"]]; + [fRemoveDownloadingCheck setEnabled: isRemoveCheck]; //set dock badging [fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]]; @@ -382,10 +390,22 @@ - (void) setShowMessage: (id) sender { + BOOL state = [sender state]; + if (sender == fQuitCheck) - [fDefaults setBool: [sender state] forKey: @"CheckQuit"]; + { + [fDefaults setBool: state forKey: @"CheckQuit"]; + [fQuitDownloadingCheck setEnabled: state]; + } else if (sender == fRemoveCheck) - [fDefaults setBool: [fRemoveCheck state] forKey: @"CheckRemove"]; + { + [fDefaults setBool: state forKey: @"CheckRemove"]; + [fRemoveDownloadingCheck setEnabled: state]; + } + if (sender == fQuitDownloadingCheck) + [fDefaults setBool: state forKey: @"CheckQuitDownloading"]; + else if (sender == fRemoveDownloadingCheck) + [fDefaults setBool: state forKey: @"CheckRemoveDownloading"]; else; }