Changeset 497


Ignore:
Timestamp:
Jul 1, 2006, 9:34:53 PM (16 years ago)
Author:
livings124
Message:

Auto-start check in the inspector now can be applied to multiple torrents.

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r496 r497  
    122122    NSView * contentView = [fWindow contentView];
    123123    [contentView addSubview: fStatusBar];
    124     [fStatusBar setFrameOrigin: NSMakePoint(0, [fScrollView frame].origin.y
    125                                                 + [fScrollView frame].size.height)];
     124    [fStatusBar setFrameOrigin: NSMakePoint(0, [fScrollView frame].origin.y + [fScrollView frame].size.height)];
    126125    [self showStatusBar: [fDefaults boolForKey: @"StatusBar"] animate: NO];
    127126   
    128127    //set speed limit
    129     BOOL speedLimit = [fDefaults boolForKey: @"SpeedLimit"];
    130     if (speedLimit)
    131     {
    132         [fSpeedLimitItem setState: speedLimit];
    133         [fSpeedLimitDockItem setState: speedLimit];
     128    if ([fDefaults boolForKey: @"SpeedLimit"])
     129    {
     130        [fSpeedLimitItem setState: NSOnState];
     131        [fSpeedLimitDockItem setState: NSOnState];
    134132        [fSpeedLimitButton setState: NSOnState];
    135133    }
    136    
     134
    137135    [fActionButton setToolTip: @"Shortcuts for changing global settings."];
    138136    [fSpeedLimitButton setToolTip: @"Speed Limit overrides the total bandwidth limits with its own limits."];
     
    241239    fTimer = [NSTimer scheduledTimerWithTimeInterval: 1.0 target: self
    242240        selector: @selector( updateUI: ) userInfo: nil repeats: YES];
    243     [[NSRunLoop currentRunLoop] addTimer: fTimer
    244         forMode: NSModalPanelRunLoopMode];
    245     [[NSRunLoop currentRunLoop] addTimer: fTimer
    246         forMode: NSEventTrackingRunLoopMode];
     241    [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
     242    [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
    247243   
    248244    [self sortTorrents];
    249245   
    250     //show windows
    251246    [fWindow makeKeyAndOrderFront: nil];
    252247
     
    10381033- (void) globalStartSettingChange: (NSNotification *) notification
    10391034{
     1035    #warning redo
    10401036    NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
    10411037   
     
    10781074                amountToStart = waitingCount;
    10791075           
    1080             //sort torrents by date to start earliest added
     1076            //sort torrents by order
    10811077            if (amountToStart < waitingCount)
    10821078            {
     
    11061102- (void) torrentStartSettingChange: (NSNotification *) notification
    11071103{
    1108     [self attemptToStartAuto: [notification object]];
     1104    //sort torrents by order value
     1105    NSSortDescriptor * orderDescriptor = [[[NSSortDescriptor alloc] initWithKey:
     1106                                                @"orderValue" ascending: YES] autorelease];
     1107    NSArray * descriptors = [[NSArray alloc] initWithObjects: orderDescriptor, nil];
     1108               
     1109    NSArray * torrents = [[notification object] sortedArrayUsingDescriptors: descriptors];
     1110    [descriptors release];
     1111
     1112    //attempt to start all torrents
     1113    NSEnumerator * enumerator = [torrents objectEnumerator];
     1114    Torrent * torrent;
     1115
     1116    while ((torrent = [enumerator nextObject]))
     1117        [self attemptToStartAuto: torrent];
    11091118
    11101119    [self updateUI: nil];
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r496 r497  
    3131        <array>
    3232                <integer>29</integer>
    33                 <integer>581</integer>
    3433                <integer>21</integer>
    3534        </array>
  • trunk/macosx/InfoWindowController.m

    r463 r497  
    192192   
    193193    //set wait to start
    194     if (numberSelected == 1)
    195     {
    196         #warning make work for multiple torrents
    197         Torrent * torrent = [fTorrents objectAtIndex: 0];
    198         [fWaitToStartButton setState: [torrent waitingToStart]];
    199 
    200         [fWaitToStartButton setEnabled: ![torrent isActive] && [torrent progress] < 1.0 &&
    201             [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"] isEqualToString: @"Wait"]];
    202     }
    203     else
    204     {
    205         [fWaitToStartButton setState: NSOffState];
    206         [fWaitToStartButton setEnabled: NO];
    207     }
    208    
     194    BOOL waiting = NO, notWaiting = NO, canEnableWaiting = numberSelected > 0,
     195        waitingSettingOn = [[[NSUserDefaults standardUserDefaults] stringForKey: @"StartSetting"]
     196                                isEqualToString: @"Wait"];
     197   
     198    enumerator = [fTorrents objectEnumerator];
     199    while ((torrent = [enumerator nextObject]))
     200    {
     201        if ([torrent waitingToStart])
     202            waiting = YES;
     203        else
     204            notWaiting = YES;
     205       
     206        if (canEnableWaiting && !(![torrent isActive] && [torrent progress] < 1.0 && waitingSettingOn))
     207            canEnableWaiting = NO;
     208    }
     209   
     210    [fWaitToStartButton setState: waiting && notWaiting ? NSMixedState : (waiting ? NSOnState : NSOffState)];
     211    [fWaitToStartButton setEnabled: canEnableWaiting];
     212
    209213    //set ratio settings
    210214    if (numberSelected > 0)
    211215    {
    212         NSEnumerator * enumerator = [fTorrents objectEnumerator];
    213         Torrent * torrent = [enumerator nextObject]; //first torrent
     216        enumerator = [fTorrents objectEnumerator];
     217        torrent = [enumerator nextObject]; //first torrent
    214218        const int INVALID = -99;
    215219        int ratioSetting = [torrent stopRatioSetting];
     
    471475- (void) setWaitToStart: (id) sender
    472476{
    473     #warning make work with multiples
    474     Torrent * torrent = [fTorrents objectAtIndex: 0];
    475     [torrent setWaitToStart: [sender state]];
    476    
    477     [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentStartSettingChange" object: torrent];
     477    int state = [sender state];
     478
     479    NSEnumerator * enumerator = [fTorrents objectEnumerator];
     480    Torrent * torrent;
     481    while ((torrent = [enumerator nextObject]))
     482        [torrent setWaitToStart: state];
     483   
     484    [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentStartSettingChange" object: fTorrents];
    478485}
    479486
  • trunk/macosx/MenuButton.m

    r272 r497  
    3232    [self setImage: [self alternateImage]];
    3333
    34     NSPoint location = NSMakePoint(3, -2);
    35 
    36     NSEvent * theEvent= [NSEvent mouseEventWithType: [event type]
    37                         location: location
     34    NSEvent * newEvent= [NSEvent mouseEventWithType: [event type]
     35                        location: NSMakePoint(3, -2)
    3836                        modifierFlags: [event modifierFlags]
    3937                        timestamp: [event timestamp]
     
    4442                        pressure: [event pressure]];
    4543
    46     [NSMenu popUpContextMenu: [self menu] withEvent: theEvent forView: self];
     44    [NSMenu popUpContextMenu: [self menu] withEvent: newEvent forView: self];
    4745
    4846    [self setImage: image];
    4947}
    5048
    51 - (NSMenu *) menuForEvent: (NSEvent *) e
     49- (NSMenu *) menuForEvent: (NSEvent *) event
    5250{
    5351    return nil;
Note: See TracChangeset for help on using the changeset viewer.