Adds download rate limit to OS X interface

This commit is contained in:
Eric Petit 2006-04-07 14:22:27 +00:00
parent ca267ac99a
commit c6afb1c534
6 changed files with 64 additions and 29 deletions

View File

@ -12,12 +12,16 @@
<true/>
<key>CheckRemove</key>
<true/>
<key>CheckDownload</key>
<false/>
<key>CheckUpload</key>
<true/>
<key>DownloadChoice</key>
<string>Constant</string>
<key>DownloadFolder</key>
<string>~/Desktop</string>
<key>DownloadLimit</key>
<integer>100</integer>
<key>InfoVisible</key>
<false/>
<key>Move</key>

View File

@ -65,12 +65,12 @@
folderSheetShow = id;
setBadge = id;
setDownloadLocation = id;
setLimitUploadCheck = id;
setLimit = id;
setLimitCheck = id;
setPort = id;
setQuitMessage = id;
setRemoveMessage = id;
setUpdate = id;
setUploadLimit = id;
};
CLASS = PrefsController;
LANGUAGE = ObjC;
@ -78,6 +78,8 @@
fBadgeDownloadRateCheck = NSButton;
fBadgeUploadRateCheck = NSButton;
fBlankView = NSView;
fDownloadCheck = NSButton;
fDownloadField = NSTextField;
fFolderPopUp = NSPopUpButton;
fGeneralView = NSView;
fNetworkView = NSView;

View File

@ -17,7 +17,7 @@
<key>783</key>
<string>411 429 420 250 0 0 1280 832 </string>
<key>796</key>
<string>484 520 420 129 0 0 1440 878 </string>
<string>411 472 420 164 0 0 1280 832 </string>
<key>825</key>
<string>544 501 155 107 0 0 1280 832 </string>
</dict>
@ -27,6 +27,7 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>796</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>

Binary file not shown.

View File

@ -44,6 +44,8 @@
IBOutlet NSTextField * fPortField;
IBOutlet NSButton * fUploadCheck;
IBOutlet NSTextField * fUploadField;
IBOutlet NSButton * fDownloadCheck;
IBOutlet NSTextField * fDownloadField;
IBOutlet NSWindow * fWindow;
@ -60,8 +62,8 @@
- (void) setDownloadLocation: (id) sender;
- (void) folderSheetShow: (id) sender;
- (void) setLimitUploadCheck: (id) sender;
- (void) setPort: (id) sender;
- (void) setUploadLimit: (id) sender;
- (void) setLimitCheck: (id) sender;
- (void) setLimit: (id) sender;
@end

View File

@ -125,6 +125,16 @@
[fUploadField setEnabled: checkUpload];
tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
//set download limit
BOOL checkDownload = [fDefaults boolForKey: @"CheckDownload"];
int downloadLimit = [fDefaults integerForKey: @"DownloadLimit"];
[fDownloadCheck setState: checkDownload ? NSOnState : NSOffState];
[fDownloadField setIntValue: downloadLimit];
[fDownloadField setEnabled: checkDownload];
tr_setDownloadLimit( fHandle, checkDownload ? downloadLimit : -1 );
//set remove and quit prompts
[fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"] ?
@ -220,36 +230,52 @@
}
}
- (void) setLimitUploadCheck: (id) sender
- (void) setLimitCheck: (id) sender
{
BOOL checkUpload = [fUploadCheck state] == NSOnState;
[fDefaults setBool: checkUpload forKey: @"CheckUpload"];
[self setUploadLimit: nil];
[fUploadField setEnabled: checkUpload];
}
- (void) setUploadLimit: (id) sender
{
int uploadLimit = [fUploadField intValue];
//if value entered is not an int or is less than 0 do not change
if (![[fUploadField stringValue] isEqualToString:
[NSString stringWithInt: uploadLimit]] || uploadLimit < 0)
NSString * key;
NSTextField * field;
if( sender == fUploadCheck )
{
NSBeep();
uploadLimit = [fDefaults integerForKey: @"UploadLimit"];
[fUploadField setIntValue: uploadLimit];
key = @"CheckUpload";
field = fUploadField;
}
else
{
[fDefaults setInteger: uploadLimit forKey: @"UploadLimit"];
key = @"CheckDownload";
field = fDownloadField;
}
BOOL check = [sender state] == NSOnState;
[fDefaults setBool: check forKey: key];
[self setLimit: field];
[field setEnabled: check];
}
- (void) setLimit: (id) sender
{
int limit = [sender intValue];
NSString * key = ( sender == fUploadField ) ?
@"CheckUpload" : @"CheckDownload";
//if value entered is not an int or is less than 0 do not change
if (![[sender stringValue] isEqualToString:
[NSString stringWithInt: limit]] || limit < 0)
{
NSBeep();
limit = [fDefaults integerForKey: key];
[sender setIntValue: limit];
}
else
{
[fDefaults setInteger: limit forKey: key];
if( sender == fUploadField )
tr_setUploadLimit( fHandle,
( [fUploadCheck state] == NSOffState ) ? -1 : limit );
else
tr_setDownloadLimit( fHandle,
( [fDownloadCheck state] == NSOffState ) ? -1 : limit );
}
if ([fUploadCheck state] == NSOffState || uploadLimit == 0)
uploadLimit = -1;
tr_setUploadLimit( fHandle, uploadLimit );
}
- (void) setQuitMessage: (id) sender