Changeset 880


Ignore:
Timestamp:
Sep 22, 2006, 2:08:57 AM (15 years ago)
Author:
livings124
Message:

Simplified queue and autostart prefs

Location:
branches/nat-traversal/macosx
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/nat-traversal/macosx/Controller.m

    r877 r880  
    333333    [nc addObserver: self selector: @selector(globalStartSettingChange:)
    334334                    name: @"GlobalStartSettingChange" object: nil];
    335 
    336     //check if torrent should now start
    337     [nc addObserver: self selector: @selector(torrentStartSettingChange:)
    338                     name: @"TorrentStartSettingChange" object: nil];
    339335   
    340336    //check if torrent should now start
     
    547543    [panel setMessage: [NSString stringWithFormat: @"Select the download folder for \"%@\"", [torrent name]]];
    548544   
    549     NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
    550                                     torrent, @"Torrent", files, @"Files", nil];
     545    NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files", nil];
    551546
    552547    [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
     
    14181413{
    14191414    //don't try to start a transfer if there should be none waiting
    1420     if (![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
     1415    if (![fDefaults boolForKey: @"Queue"])
    14211416        return;
    14221417
     
    15051500- (void) attemptToStartMultipleAuto: (NSArray *) torrents
    15061501{
    1507     NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
    1508     if ([startSetting isEqualToString: @"Start"])
     1502    if (![fDefaults boolForKey: @"Queue"])
    15091503    {
    15101504        NSEnumerator * enumerator = [torrents objectEnumerator];
     
    15161510        return;
    15171511    }
    1518     else if (![startSetting isEqualToString: @"Wait"])
    1519         return;
    1520     else;
    15211512   
    15221513    //determine the number of downloads needed to start
     
    21792170    if (action == @selector(resumeWaitingTorrents:))
    21802171    {
    2181         if (![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
     2172        if (![fDefaults boolForKey: @"Queue"])
    21822173            return NO;
    21832174   
     
    21932184    if (action == @selector(resumeSelectedTorrentsNoWait:))
    21942185    {
    2195         if (![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
     2186        if (![fDefaults boolForKey: @"Queue"])
    21962187            return NO;
    21972188   
  • branches/nat-traversal/macosx/Defaults.plist

    r868 r880  
    5959        <key>PlaySeedingSound</key>
    6060        <false/>
     61        <key>Queue</key>
     62        <false/>
    6163        <key>RatioCheck</key>
    6264        <false/>
     
    8991        <key>SpeedLimitUploadLimit</key>
    9092        <integer>10</integer>
    91         <key>StartSetting</key>
    92         <string>Start</string>
     93        <key>StartAtOpen</key>
     94        <true/>
    9395        <key>StatusBar</key>
    9496        <true/>
  • branches/nat-traversal/macosx/English.lproj/InfoWindow.nib/classes.nib

    r797 r880  
    99        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
    1010        {
    11             ACTIONS = {
    12                 revealFile = id;
    13                 setRatioCheck = id;
    14                 setRatioLimit = id;
    15                 setWaitToStart = id;
    16             };
     11            ACTIONS = {revealFile = id; setRatioCheck = id; setRatioLimit = id; };
    1712            CLASS = InfoWindowController;
    1813            LANGUAGE = ObjC;
     
    4742                fUploadedTotalField = NSTextField;
    4843                fUploadingToField = NSTextField;
    49                 fWaitToStartButton = NSButton;
    5044            };
    5145            SUPERCLASS = NSWindowController;
  • branches/nat-traversal/macosx/English.lproj/PrefsWindow.nib/classes.nib

    r868 r880  
    2121                setPlaySound = id;
    2222                setPort = id;
     23                setQueueNumber = id;
    2324                setRatio = id;
    2425                setRatioCheck = id;
     
    2627                setSound = id;
    2728                setSpeedLimit = id;
    28                 setStartNumber = id;
    29                 setStartSetting = id;
     29                setStartAtOpen = id;
    3030                setUpdate = id;
     31                setUseQueue = id;
    3132            };
    3233            CLASS = PrefsController;
     
    5152                fPlaySeedingSoundCheck = NSButton;
    5253                fPortField = NSTextField;
     54                fQueueCheck = NSButton;
     55                fQueueNumberField = NSTextField;
    5356                fQuitCheck = NSButton;
    5457                fQuitDownloadingCheck = NSButton;
     
    6366                fSpeedLimitDownloadField = NSTextField;
    6467                fSpeedLimitUploadField = NSTextField;
    65                 fStartMatrix = NSMatrix;
    66                 fStartNumberField = NSTextField;
     68                fStartAtOpenCheck = NSButton;
    6769                fTransfersView = NSView;
    6870                fUpdatePopUp = NSPopUpButton;
  • branches/nat-traversal/macosx/English.lproj/PrefsWindow.nib/info.nib

    r879 r880  
    88        <dict>
    99                <key>153</key>
    10                 <string>285 445 582 267 0 0 1152 842 </string>
     10                <string>215 269 582 267 0 0 1152 842 </string>
    1111                <key>28</key>
    1212                <string>285 434 582 290 0 0 1152 842 </string>
    1313                <key>41</key>
    14                 <string>200 343 582 304 0 0 1152 842 </string>
     14                <string>270 449 582 304 0 0 1152 842 </string>
    1515                <key>66</key>
    1616                <string>285 507 582 144 0 0 1152 842 </string>
  • branches/nat-traversal/macosx/InfoWindowController.h

    r797 r880  
    5353    IBOutlet NSMatrix * fRatioMatrix;
    5454    IBOutlet NSTextField * fRatioLimitField;
    55     IBOutlet NSButton * fWaitToStartButton;
    5655}
    5756
     
    6766- (void) setRatioLimit: (id) sender;
    6867
    69 - (void) setWaitToStart: (id) sender;
    70 
    7168@end
  • branches/nat-traversal/macosx/InfoWindowController.m

    r842 r880  
    4444#define TAB_PEERS_HEIGHT 255.0
    4545#define TAB_FILES_HEIGHT 255.0
    46 #define TAB_OPTIONS_HEIGHT 116.0
     46#define TAB_OPTIONS_HEIGHT 83.0
    4747
    4848@interface InfoWindowController (Private)
     
    287287    int numberSelected = [fTorrents count];
    288288
    289     //set wait to start
    290     BOOL waiting = NO, notWaiting = NO, canEnableWaiting = numberSelected > 0,
    291         waitingSettingOn = [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"]
    292                                 isEqualToString: @"Wait"];
    293    
    294     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    295     Torrent * torrent;
    296     while ((torrent = [enumerator nextObject]))
    297     {
    298         if ([torrent waitingToStart])
    299             waiting = YES;
    300         else
    301             notWaiting = YES;
    302        
    303         if (canEnableWaiting && !(![torrent isActive] && [torrent progress] < 1.0 && waitingSettingOn))
    304             canEnableWaiting = NO;
    305     }
    306    
    307     [fWaitToStartButton setState: waiting && notWaiting ? NSMixedState : (waiting ? NSOnState : NSOffState)];
    308     [fWaitToStartButton setEnabled: canEnableWaiting];
    309 
    310289    //set ratio settings
    311290    if (numberSelected > 0)
    312291    {
    313         enumerator = [fTorrents objectEnumerator];
    314         torrent = [enumerator nextObject]; //first torrent
     292        NSEnumerator * enumerator = [fTorrents objectEnumerator];
     293        Torrent * torrent = [enumerator nextObject]; //first torrent
    315294        const int INVALID = -99;
    316295        int ratioSetting = [torrent stopRatioSetting];
     
    593572}
    594573
    595 - (void) setWaitToStart: (id) sender
    596 {
    597     int state = [sender state];
    598 
    599     NSEnumerator * enumerator = [fTorrents objectEnumerator];
    600     Torrent * torrent;
    601     while ((torrent = [enumerator nextObject]))
    602         [torrent setWaitToStart: state];
    603    
    604     [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentStartSettingChange" object: fTorrents];
    605 }
    606 
    607574@end
  • branches/nat-traversal/macosx/PrefsController.h

    r868 r880  
    5757    IBOutlet NSTextField    * fRatioField;
    5858   
    59     IBOutlet NSMatrix       * fStartMatrix;
    60     IBOutlet NSTextField    * fStartNumberField;
     59    IBOutlet NSButton       * fQueueCheck, * fStartAtOpenCheck;
     60    IBOutlet NSTextField    * fQueueNumberField;
    6161   
    6262    IBOutlet SUUpdater      * fUpdater;
     
    7575- (void) checkUpdate;
    7676
    77 - (void) setStartSetting:   (id) sender;
    78 - (void) setStartNumber:    (id) sender;
     77- (void) setStartAtOpen:    (id) sender;
     78
     79- (void) setUseQueue:       (id) sender;
     80- (void) setQueueNumber:    (id) sender;
    7981
    8082- (void) setMoveTorrent:        (id) sender;
  • branches/nat-traversal/macosx/PrefsController.m

    r868 r880  
    3434#define DOWNLOAD_ASK        3
    3535
    36 #define START_YES_CHECK_TAG     0
    37 #define START_WAIT_CHECK_TAG    1
    38 #define START_NO_CHECK_TAG      2
    39 
    4036#define UPDATE_DAILY    0
    4137#define UPDATE_WEEKLY   1
     
    256252        [fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
    257253   
    258     //set start setting
    259     NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
    260     int tag;
    261     if ([startSetting isEqualToString: @"Start"])
    262         tag = START_YES_CHECK_TAG;
    263     else if ([startSetting isEqualToString: @"Wait"])
    264         tag = START_WAIT_CHECK_TAG;
    265     else
    266         tag = START_NO_CHECK_TAG;
    267    
    268     [fStartMatrix selectCellWithTag: tag];
    269     [fStartNumberField setEnabled: tag == START_WAIT_CHECK_TAG];
    270     [fStartNumberField setIntValue: [fDefaults integerForKey: @"WaitToStartNumber"]];
     254    //set start settings
     255    BOOL useQueue = [fDefaults boolForKey: @"Queue"];
     256    [fQueueCheck setState: useQueue];
     257    [fQueueNumberField setEnabled: useQueue];
     258    [fQueueNumberField setIntValue: [fDefaults integerForKey: @"WaitToStartNumber"]];
     259   
     260    [fStartAtOpenCheck setState: [fDefaults boolForKey: @"StartAtOpen"]];
    271261   
    272262    //set private torrents
     
    675665}
    676666
    677 - (void) setStartSetting: (id) sender
    678 {
    679     NSString * startSetting;
    680 
    681     int tag = [[fStartMatrix selectedCell] tag];
    682     if (tag == START_YES_CHECK_TAG)
    683         startSetting = @"Start";
    684     else if (tag == START_WAIT_CHECK_TAG)
    685         startSetting = @"Wait";
    686     else
    687         startSetting = @"Manual";
    688    
    689     [fDefaults setObject: startSetting forKey: @"StartSetting"];
    690    
    691     [self setStartNumber: fStartNumberField];
    692     [fStartNumberField setEnabled: tag == START_WAIT_CHECK_TAG];
    693 }
    694 
    695 - (void) setStartNumber: (id) sender
    696 {
    697     int waitNumber = [sender intValue];
    698     if (![[sender stringValue] isEqualToString: [NSString stringWithInt: waitNumber]] || waitNumber < 1)
     667- (void) setStartAtOpen: (id) sender
     668{
     669    [fDefaults setBool: [sender state] == NSOnState forKey: @"StartAtOpen"];
     670}
     671
     672- (void) setUseQueue: (id) sender
     673{
     674    BOOL useQueue = [sender state] == NSOnState;
     675   
     676    [fDefaults setBool: useQueue forKey: @"Queue"];
     677    [self setQueueNumber: fQueueNumberField];
     678    [fQueueNumberField setEnabled: useQueue];
     679}
     680
     681- (void) setQueueNumber: (id) sender
     682{
     683    int queueNumber = [sender intValue];
     684    if (![[sender stringValue] isEqualToString: [NSString stringWithInt: queueNumber]] || queueNumber < 1)
    699685    {
    700686        NSBeep();
    701         waitNumber = [fDefaults floatForKey: @"WaitToStartNumber"];
    702         [sender setIntValue: waitNumber];
    703     }
    704     else
    705         [fDefaults setInteger: waitNumber forKey: @"WaitToStartNumber"];
     687        queueNumber = [fDefaults integerForKey: @"WaitToStartNumber"];
     688        [sender setIntValue: queueNumber];
     689    }
     690    else
     691        [fDefaults setInteger: queueNumber forKey: @"WaitToStartNumber"];
    706692   
    707693    [[NSNotificationCenter defaultCenter] postNotificationName: @"GlobalStartSettingChange" object: self];
  • branches/nat-traversal/macosx/Torrent.m

    r861 r880  
    193193            if (fFinishedSeeding)
    194194                tempString = @"Seeding complete";
    195             else if (fWaitToStart && [[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
     195            else if (fWaitToStart)
    196196                tempString = [@"Waiting to start" stringByAppendingEllipsis];
    197197            else
     
    836836    fFinishedSeeding = NO;
    837837   
    838     fWaitToStart = waitToStart ? [waitToStart boolValue]
    839                     : ![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Manual"];
     838    fWaitToStart = waitToStart ? [waitToStart boolValue] : [fDefaults boolForKey: @"StartAtOpen"];
    840839    fOrderValue = orderValue ? [orderValue intValue] : tr_torrentCount(fLib) - 1;
    841840   
Note: See TracChangeset for help on using the changeset viewer.