Changeset 213


Ignore:
Timestamp:
Apr 7, 2006, 2:22:27 PM (16 years ago)
Author:
titer
Message:

Adds download rate limit to OS X interface

Location:
trunk/macosx
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Defaults.plist

    r106 r213  
    1313        <key>CheckRemove</key>
    1414        <true/>
     15        <key>CheckDownload</key>
     16        <false/>
    1517        <key>CheckUpload</key>
    1618        <true/>
     
    1921        <key>DownloadFolder</key>
    2022        <string>~/Desktop</string>
     23        <key>DownloadLimit</key>
     24        <integer>100</integer>
    2125        <key>InfoVisible</key>
    2226        <false/>
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r165 r213  
    6666                setBadge = id;
    6767                setDownloadLocation = id;
    68                 setLimitUploadCheck = id;
     68                setLimit = id;
     69                setLimitCheck = id;
    6970                setPort = id;
    7071                setQuitMessage = id;
    7172                setRemoveMessage = id;
    7273                setUpdate = id;
    73                 setUploadLimit = id;
    7474            };
    7575            CLASS = PrefsController;
     
    7979                fBadgeUploadRateCheck = NSButton;
    8080                fBlankView = NSView;
     81                fDownloadCheck = NSButton;
     82                fDownloadField = NSTextField;
    8183                fFolderPopUp = NSPopUpButton;
    8284                fGeneralView = NSView;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r211 r213  
    1818                <string>411 429 420 250 0 0 1280 832 </string>
    1919                <key>796</key>
    20                 <string>484 520 420 129 0 0 1440 878 </string>
     20                <string>411 472 420 164 0 0 1280 832 </string>
    2121                <key>825</key>
    2222                <string>544 501 155 107 0 0 1280 832 </string>
     
    2828        <key>IBOpenObjects</key>
    2929        <array>
     30                <integer>796</integer>
    3031                <integer>21</integer>
    3132        </array>
  • trunk/macosx/PrefsController.h

    r106 r213  
    4545    IBOutlet NSButton       * fUploadCheck;
    4646    IBOutlet NSTextField    * fUploadField;
     47    IBOutlet NSButton       * fDownloadCheck;
     48    IBOutlet NSTextField    * fDownloadField;
    4749   
    4850    IBOutlet NSWindow       * fWindow;
     
    6163- (void) folderSheetShow:       (id) sender;
    6264
    63 - (void) setLimitUploadCheck:   (id) sender;
    6465- (void) setPort:               (id) sender;
    65 - (void) setUploadLimit:        (id) sender;
     66- (void) setLimitCheck:         (id) sender;
     67- (void) setLimit:              (id) sender;
    6668
    6769@end
  • trunk/macosx/PrefsController.m

    r191 r213  
    126126   
    127127    tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
     128
     129    //set download limit
     130    BOOL checkDownload = [fDefaults boolForKey: @"CheckDownload"];
     131    int downloadLimit = [fDefaults integerForKey: @"DownloadLimit"];
     132   
     133    [fDownloadCheck setState: checkDownload ? NSOnState : NSOffState];
     134    [fDownloadField setIntValue: downloadLimit];
     135    [fDownloadField setEnabled: checkDownload];
     136   
     137    tr_setDownloadLimit( fHandle, checkDownload ? downloadLimit : -1 );
    128138   
    129139    //set remove and quit prompts
     
    221231}
    222232
    223 - (void) setLimitUploadCheck: (id) sender
    224 {
    225     BOOL checkUpload = [fUploadCheck state] == NSOnState;
    226 
    227     [fDefaults setBool: checkUpload forKey: @"CheckUpload"];
    228    
    229     [self setUploadLimit: nil];
    230     [fUploadField setEnabled: checkUpload];
    231 }
    232 
    233 - (void) setUploadLimit: (id) sender
    234 {
    235     int uploadLimit = [fUploadField intValue];
    236    
     233- (void) setLimitCheck: (id) sender
     234{
     235    NSString * key;
     236    NSTextField * field;
     237    if( sender == fUploadCheck )
     238    {
     239        key = @"CheckUpload";
     240        field = fUploadField;
     241    }
     242    else
     243    {
     244        key = @"CheckDownload";
     245        field = fDownloadField;
     246    }
     247
     248    BOOL check = [sender state] == NSOnState;
     249    [fDefaults setBool: check forKey: key];
     250
     251    [self setLimit: field];
     252    [field setEnabled: check];
     253}
     254
     255- (void) setLimit: (id) sender
     256{
     257    int limit = [sender intValue];
     258    NSString * key = ( sender == fUploadField ) ?
     259                        @"CheckUpload" : @"CheckDownload";
     260
    237261    //if value entered is not an int or is less than 0 do not change
    238     if (![[fUploadField stringValue] isEqualToString:
    239             [NSString stringWithInt: uploadLimit]] || uploadLimit < 0)
     262    if (![[sender stringValue] isEqualToString:
     263            [NSString stringWithInt: limit]] || limit < 0)
    240264    {
    241265        NSBeep();
    242         uploadLimit = [fDefaults integerForKey: @"UploadLimit"];
    243         [fUploadField setIntValue: uploadLimit];
    244     }
    245     else
    246     {
    247         [fDefaults setInteger: uploadLimit forKey: @"UploadLimit"];
    248     }
    249    
    250     if ([fUploadCheck state] == NSOffState || uploadLimit == 0)
    251         uploadLimit = -1;
    252     tr_setUploadLimit( fHandle, uploadLimit );
     266        limit = [fDefaults integerForKey: key];
     267        [sender setIntValue: limit];
     268    }
     269    else
     270    {
     271        [fDefaults setInteger: limit forKey: key];
     272        if( sender == fUploadField )
     273            tr_setUploadLimit( fHandle,
     274                ( [fUploadCheck state] == NSOffState ) ? -1 : limit );
     275        else
     276            tr_setDownloadLimit( fHandle,
     277                ( [fDownloadCheck state] == NSOffState ) ? -1 : limit );
     278    }
    253279}
    254280
Note: See TracChangeset for help on using the changeset viewer.