mirror of
https://github.com/transmission/transmission
synced 2025-01-31 19:34:05 +00:00
simplify options for download limits in inspector with 3 check states: mixed for system defaults, checked for override with limit, and no check for no limit
This commit is contained in:
parent
50fbe60adb
commit
5d2ae4eb61
10 changed files with 70 additions and 113 deletions
|
@ -151,7 +151,8 @@ struct tr_torrent_s
|
|||
tr_handle_t * handle;
|
||||
tr_info_t info;
|
||||
|
||||
int customSpeedLimit;
|
||||
int customUploadLimit;
|
||||
int customDownloadLimit;
|
||||
tr_ratecontrol_t * upload;
|
||||
tr_ratecontrol_t * download;
|
||||
tr_ratecontrol_t * swarmspeed;
|
||||
|
|
|
@ -211,7 +211,14 @@ int tr_peerRead( tr_peer_t * peer )
|
|||
{
|
||||
if( tor )
|
||||
{
|
||||
if( !tor->customSpeedLimit )
|
||||
if( tor->customDownloadLimit )
|
||||
{
|
||||
if( !tr_rcCanTransfer( tor->download ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_lockUnlock( &tor->lock );
|
||||
if( !tr_rcCanGlobalTransfer( tor->handle, 0 ) )
|
||||
|
@ -221,10 +228,6 @@ int tr_peerRead( tr_peer_t * peer )
|
|||
}
|
||||
tr_lockLock( &tor->lock );
|
||||
}
|
||||
else if( !tr_rcCanTransfer( tor->download ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( peer->size < 1 )
|
||||
|
@ -398,7 +401,14 @@ writeBegin:
|
|||
/* Send pieces if we can */
|
||||
while( ( p = blockPending( tor, peer, &size ) ) )
|
||||
{
|
||||
if( !tor->customSpeedLimit )
|
||||
if( tor->customUploadLimit )
|
||||
{
|
||||
if( !tr_rcCanTransfer( tor->upload ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tr_lockUnlock( &tor->lock );
|
||||
if( !tr_rcCanGlobalTransfer( tor->handle, 1 ) )
|
||||
|
@ -408,10 +418,6 @@ writeBegin:
|
|||
}
|
||||
tr_lockLock( &tor->lock );
|
||||
}
|
||||
else if( !tr_rcCanTransfer( tor->upload ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
ret = tr_netSend( peer->socket, p, size );
|
||||
if( ret & TR_NET_CLOSE )
|
||||
|
|
|
@ -97,7 +97,7 @@ int tr_rcCanGlobalTransfer( tr_handle_t * h, int isUpload )
|
|||
tr_sharedLock( h->shared );
|
||||
for( tor = h->torrentList; tor; tor = tor->next )
|
||||
{
|
||||
if( tor->customSpeedLimit )
|
||||
if( isUpload ? tor->customUploadLimit : tor->customDownloadLimit )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,14 @@ static tr_torrent_t * torrentRealInit( tr_handle_t *, tr_torrent_t * tor,
|
|||
static void torrentReallyStop( tr_torrent_t * );
|
||||
static void downloadLoop( void * );
|
||||
|
||||
void tr_setUseCustomLimit( tr_torrent_t * tor, int limit )
|
||||
void tr_setUseCustomUpload( tr_torrent_t * tor, int limit )
|
||||
{
|
||||
tor->customSpeedLimit = limit;
|
||||
tor->customUploadLimit = limit;
|
||||
}
|
||||
|
||||
void tr_setUseCustomDownload( tr_torrent_t * tor, int limit )
|
||||
{
|
||||
tor->customDownloadLimit = limit;
|
||||
}
|
||||
|
||||
void tr_setUploadLimit( tr_torrent_t * tor, int limit )
|
||||
|
|
2
macosx/English.lproj/InfoWindow.nib/classes.nib
generated
2
macosx/English.lproj/InfoWindow.nib/classes.nib
generated
|
@ -9,7 +9,6 @@
|
|||
revealFile = id;
|
||||
revealTorrentFile = id;
|
||||
setLimitCheck = id;
|
||||
setLimitCustom = id;
|
||||
setRatioCustom = id;
|
||||
setRatioLimit = id;
|
||||
setRatioSetting = id;
|
||||
|
@ -37,7 +36,6 @@
|
|||
fHashField = NSTextField;
|
||||
fImageView = NSImageView;
|
||||
fLeechersField = NSTextField;
|
||||
fLimitCustomCheck = NSButton;
|
||||
fNameField = NSTextField;
|
||||
fPeerTable = NSTableView;
|
||||
fPiecesField = NSTextField;
|
||||
|
|
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/InfoWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -56,8 +56,7 @@
|
|||
IBOutlet NSOutlineView * fFileOutline;
|
||||
IBOutlet NSTextField * fFileTableStatusField;
|
||||
|
||||
IBOutlet NSButton * fRatioCustomCheck, * fRatioStopCheck,
|
||||
* fLimitCustomCheck, * fUploadLimitCheck, * fDownloadLimitCheck;
|
||||
IBOutlet NSButton * fRatioCustomCheck, * fRatioStopCheck, * fUploadLimitCheck, * fDownloadLimitCheck;
|
||||
IBOutlet NSTextField * fUploadLimitField, * fDownloadLimitField, * fRatioLimitField,
|
||||
* fUploadLimitLabel, * fDownloadLimitLabel;
|
||||
}
|
||||
|
@ -72,7 +71,6 @@
|
|||
- (void) revealDataFile: (id) sender;
|
||||
- (void) revealFile: (id) sender;
|
||||
|
||||
- (void) setLimitCustom: (id) sender;
|
||||
- (void) setLimitCheck: (id) sender;
|
||||
- (void) setSpeedLimit: (id) sender;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#define TAB_ACTIVITY_HEIGHT 170.0
|
||||
#define TAB_PEERS_HEIGHT 268.0
|
||||
#define TAB_FILES_HEIGHT 268.0
|
||||
#define TAB_OPTIONS_HEIGHT 142.0
|
||||
#define TAB_OPTIONS_HEIGHT 127.0
|
||||
|
||||
#define INVALID -99
|
||||
|
||||
|
@ -393,54 +393,41 @@
|
|||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
torrent = [enumerator nextObject]; //first torrent
|
||||
|
||||
int limitCustom = [torrent customLimitSetting] ? 1 : 0,
|
||||
checkUpload = [torrent checkUpload] ? 1 : 0,
|
||||
checkDownload = [torrent checkDownload] ? 1 : 0,
|
||||
int checkUpload = [torrent checkUpload],
|
||||
checkDownload = [torrent checkDownload],
|
||||
uploadLimit = [torrent uploadLimit],
|
||||
downloadLimit = [torrent downloadLimit];
|
||||
|
||||
while ((limitCustom != INVALID
|
||||
|| checkUpload != INVALID || uploadLimit != INVALID
|
||||
|| checkDownload != INVALID || downloadLimit != INVALID)
|
||||
while ((checkUpload != NSMixedState || uploadLimit != INVALID
|
||||
|| checkDownload != NSMixedState || downloadLimit != INVALID)
|
||||
&& (torrent = [enumerator nextObject]))
|
||||
{
|
||||
if (limitCustom != INVALID && limitCustom != ([torrent customLimitSetting] ? 1 : 0))
|
||||
limitCustom = INVALID;
|
||||
|
||||
if (checkUpload != INVALID && checkUpload != ([torrent checkUpload] ? 1 : 0))
|
||||
checkUpload = INVALID;
|
||||
if (checkUpload != NSMixedState && checkUpload != [torrent checkUpload])
|
||||
checkUpload = NSMixedState;
|
||||
|
||||
if (uploadLimit != INVALID && uploadLimit != [torrent uploadLimit])
|
||||
uploadLimit = INVALID;
|
||||
|
||||
if (checkDownload != INVALID && checkDownload != ([torrent checkDownload] ? 1 : 0))
|
||||
checkDownload = INVALID;
|
||||
if (checkDownload != NSMixedState && checkDownload != [torrent checkDownload])
|
||||
checkDownload = NSMixedState;
|
||||
|
||||
if (downloadLimit != INVALID && downloadLimit != [torrent downloadLimit])
|
||||
downloadLimit = INVALID;
|
||||
}
|
||||
|
||||
[fLimitCustomCheck setEnabled: YES];
|
||||
[fLimitCustomCheck setState: limitCustom == INVALID ? NSMixedState
|
||||
: (limitCustom == 1 ? NSOnState : NSOffState)];
|
||||
|
||||
[fUploadLimitCheck setEnabled: limitCustom == 1];
|
||||
[fUploadLimitLabel setEnabled: limitCustom == 1];
|
||||
[fUploadLimitCheck setState: checkUpload == INVALID ? NSMixedState
|
||||
: (checkUpload == 1 ? NSOnState : NSOffState)];
|
||||
|
||||
[fDownloadLimitCheck setEnabled: limitCustom == 1];
|
||||
[fDownloadLimitLabel setEnabled: limitCustom == 1];
|
||||
[fDownloadLimitCheck setState: checkDownload == INVALID ? NSMixedState
|
||||
: (checkDownload == 1 ? NSOnState : NSOffState)];
|
||||
|
||||
[fUploadLimitField setEnabled: limitCustom == 1 && checkUpload == 1];
|
||||
[fUploadLimitCheck setEnabled: YES];
|
||||
[fUploadLimitCheck setState: checkUpload];
|
||||
[fUploadLimitLabel setEnabled: checkUpload == NSOnState];
|
||||
[fUploadLimitField setEnabled: checkUpload == NSOnState];
|
||||
if (uploadLimit != INVALID)
|
||||
[fUploadLimitField setIntValue: uploadLimit];
|
||||
else
|
||||
[fUploadLimitField setStringValue: @""];
|
||||
|
||||
[fDownloadLimitField setEnabled: limitCustom == 1 && checkDownload == 1];
|
||||
|
||||
[fDownloadLimitCheck setEnabled: YES];
|
||||
[fDownloadLimitCheck setState: checkDownload];
|
||||
[fDownloadLimitLabel setEnabled: checkDownload == NSOnState];
|
||||
[fDownloadLimitField setEnabled: checkDownload == NSOnState];
|
||||
if (downloadLimit != INVALID)
|
||||
[fDownloadLimitField setIntValue: downloadLimit];
|
||||
else
|
||||
|
@ -483,9 +470,6 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
[fLimitCustomCheck setEnabled: NO];
|
||||
[fLimitCustomCheck setState: NSOffState];
|
||||
|
||||
[fUploadLimitCheck setEnabled: NO];
|
||||
[fUploadLimitCheck setState: NSOffState];
|
||||
[fUploadLimitField setEnabled: NO];
|
||||
|
@ -835,42 +819,19 @@
|
|||
[[fFileOutline itemAtRow: i] objectForKey: @"Path"]] inFileViewerRootedAtPath: nil];
|
||||
}
|
||||
|
||||
- (void) setLimitCustom: (id) sender
|
||||
{
|
||||
BOOL custom = [sender state] != NSOffState;
|
||||
if (custom)
|
||||
[sender setState: NSOnState];
|
||||
|
||||
Torrent * torrent;
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
[torrent setCustomLimitSetting: custom];
|
||||
|
||||
[fUploadLimitCheck setEnabled: custom];
|
||||
[fUploadLimitLabel setEnabled: custom];
|
||||
[fUploadLimitField setEnabled: custom && [fUploadLimitCheck state] == NSOnState];
|
||||
|
||||
[fDownloadLimitCheck setEnabled: custom];
|
||||
[fDownloadLimitLabel setEnabled: custom];
|
||||
[fDownloadLimitField setEnabled: custom && [fDownloadLimitCheck state] == NSOnState];
|
||||
}
|
||||
|
||||
- (void) setLimitCheck: (id) sender
|
||||
{
|
||||
BOOL upload = sender == fUploadLimitCheck,
|
||||
limit = [sender state] != NSOffState;
|
||||
|
||||
if (limit)
|
||||
[sender setState: NSOnState];
|
||||
BOOL upload = sender == fUploadLimitCheck;
|
||||
int state = [sender state];
|
||||
|
||||
Torrent * torrent;
|
||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
upload ? [torrent setLimitUpload: limit] : [torrent setLimitDownload: limit];
|
||||
upload ? [torrent setCheckUpload: state] : [torrent setCheckDownload: state];
|
||||
|
||||
NSTextField * field = upload ? fUploadLimitField : fDownloadLimitField;
|
||||
|
||||
[field setEnabled: limit];
|
||||
[field setEnabled: state == NSOnState];
|
||||
}
|
||||
|
||||
- (void) setSpeedLimit: (id) sender
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
|
||||
int fUploadLimit, fDownloadLimit;
|
||||
float fRatioLimit;
|
||||
BOOL fLimitCustom, fCheckUpload, fCheckDownload, fRatioCustom, fShouldStopAtRatio,
|
||||
int fCheckUpload, fCheckDownload;
|
||||
BOOL fRatioCustom, fShouldStopAtRatio,
|
||||
fFinishedSeeding, fWaitToStart, fError, fChecking;
|
||||
|
||||
int fOrderValue;
|
||||
|
@ -92,17 +93,15 @@
|
|||
- (float) ratioLimit;
|
||||
- (void) setRatioLimit: (float) limit;
|
||||
|
||||
- (BOOL) checkUpload;
|
||||
- (void) setLimitUpload: (BOOL) limit;
|
||||
- (int) checkUpload;
|
||||
- (void) setCheckUpload: (int) setting;
|
||||
- (int) uploadLimit;
|
||||
- (void) setUploadLimit: (int) limit;
|
||||
- (BOOL) checkDownload;
|
||||
- (void) setLimitDownload: (BOOL) limit;
|
||||
- (int) checkDownload;
|
||||
- (void) setCheckDownload: (int) setting;
|
||||
- (int) downloadLimit;
|
||||
- (void) setDownloadLimit: (int) limit;
|
||||
|
||||
- (BOOL) customLimitSetting;
|
||||
- (void) setCustomLimitSetting: (BOOL) setting;
|
||||
- (void) updateSpeedSetting;
|
||||
|
||||
- (void) setWaitToStart: (BOOL) wait;
|
||||
|
|
|
@ -152,10 +152,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
[NSNumber numberWithBool: fRatioCustom], @"StopRatioCustom",
|
||||
[NSNumber numberWithBool: fShouldStopAtRatio], @"ShouldStopAtRatio",
|
||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||
[NSNumber numberWithBool: fLimitCustom], @"LimitSpeedCustom",
|
||||
[NSNumber numberWithBool: fCheckUpload], @"CheckUpload",
|
||||
[NSNumber numberWithInt: fCheckUpload], @"CheckUpload",
|
||||
[NSNumber numberWithInt: fUploadLimit], @"UploadLimit",
|
||||
[NSNumber numberWithBool: fCheckDownload], @"CheckDownload",
|
||||
[NSNumber numberWithInt: fCheckDownload], @"CheckDownload",
|
||||
[NSNumber numberWithInt: fDownloadLimit], @"DownloadLimit",
|
||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||
[self orderValue], @"OrderValue", nil];
|
||||
|
@ -559,14 +558,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
fRatioLimit = limit;
|
||||
}
|
||||
|
||||
- (BOOL) checkUpload
|
||||
- (int) checkUpload
|
||||
{
|
||||
return fCheckUpload;
|
||||
}
|
||||
|
||||
- (void) setLimitUpload: (BOOL) limit
|
||||
- (void) setCheckUpload: (int) setting
|
||||
{
|
||||
fCheckUpload = limit;
|
||||
fCheckUpload = setting;
|
||||
[self updateSpeedSetting];
|
||||
}
|
||||
|
||||
|
@ -581,14 +580,14 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
[self updateSpeedSetting];
|
||||
}
|
||||
|
||||
- (BOOL) checkDownload
|
||||
- (int) checkDownload
|
||||
{
|
||||
return fCheckDownload;
|
||||
}
|
||||
|
||||
- (void) setLimitDownload: (BOOL) limit
|
||||
- (void) setCheckDownload: (int) setting
|
||||
{
|
||||
fCheckDownload = limit;
|
||||
fCheckDownload = setting;
|
||||
[self updateSpeedSetting];
|
||||
}
|
||||
|
||||
|
@ -603,22 +602,13 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
[self updateSpeedSetting];
|
||||
}
|
||||
|
||||
- (BOOL) customLimitSetting
|
||||
{
|
||||
return fLimitCustom;
|
||||
}
|
||||
|
||||
- (void) setCustomLimitSetting: (BOOL) setting
|
||||
{
|
||||
fLimitCustom = setting;
|
||||
[self updateSpeedSetting];
|
||||
}
|
||||
|
||||
- (void) updateSpeedSetting
|
||||
{
|
||||
tr_setUseCustomLimit(fHandle, fLimitCustom);
|
||||
tr_setUploadLimit(fHandle, fCheckUpload ? fUploadLimit : -1);
|
||||
tr_setDownloadLimit(fHandle, fCheckDownload ? fDownloadLimit : -1);
|
||||
tr_setUseCustomUpload(fHandle, fCheckUpload != NSMixedState);
|
||||
tr_setUploadLimit(fHandle, fCheckUpload == NSOnState ? fUploadLimit : -1);
|
||||
|
||||
tr_setUseCustomDownload(fHandle, fCheckDownload != NSMixedState);
|
||||
tr_setDownloadLimit(fHandle, fCheckDownload == NSOnState ? fDownloadLimit : -1);
|
||||
}
|
||||
|
||||
- (void) setWaitToStart: (BOOL) wait
|
||||
|
@ -1167,10 +1157,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
|
||||
fFinishedSeeding = NO;
|
||||
|
||||
fLimitCustom = limitCustom ? [limitCustom boolValue] : NO;
|
||||
fCheckUpload = checkUpload ? [checkUpload boolValue] : NO;
|
||||
fCheckUpload = checkUpload ? [checkUpload intValue] : NSMixedState;
|
||||
fUploadLimit = uploadLimit ? [uploadLimit intValue] : [fDefaults integerForKey: @"UploadLimit"];
|
||||
fCheckDownload = checkDownload ? [checkDownload boolValue] : NO;
|
||||
fCheckDownload = checkDownload ? [checkDownload intValue] : NSMixedState;
|
||||
fDownloadLimit = downloadLimit ? [downloadLimit intValue] : [fDefaults integerForKey: @"DownloadLimit"];
|
||||
[self updateSpeedSetting];
|
||||
|
||||
|
|
Loading…
Reference in a new issue