clicking on the group speed rates will toggle with ratio
This commit is contained in:
parent
f00dd3cbd3
commit
af2339bb9e
|
@ -42,6 +42,7 @@
|
|||
#import "ExpandedPathToPathTransformer.h"
|
||||
#import "ExpandedPathToIconTransformer.h"
|
||||
#import "SpeedLimitToTurtleIconTransformer.h"
|
||||
#include "utils.h" //tr_getRatio()
|
||||
|
||||
#import <Sparkle/Sparkle.h>
|
||||
|
||||
|
@ -2495,14 +2496,32 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
return group != -1 ? [[GroupsWindowController groups] imageForIndex: group isSmall: YES]
|
||||
: [NSImage imageNamed: NSImageNameStopProgressTemplate];
|
||||
}
|
||||
else if ([ident isEqualToString: @"UL Image"])
|
||||
return [NSImage imageNamed: @"UpArrowGroupTemplate.png"];
|
||||
else if ([ident isEqualToString: @"DL Image"])
|
||||
return [NSImage imageNamed: @"DownArrowGroupTemplate.png"];
|
||||
return ![fDefaults boolForKey: @"DisplayGroupRowRatio"] ? [NSImage imageNamed: @"DownArrowGroupTemplate.png"] : nil;
|
||||
else if ([ident isEqualToString: @"UL Image"])
|
||||
return [NSImage imageNamed: [fDefaults boolForKey: @"DisplayGroupRowRatio"]
|
||||
? @"YingYangTemplate.png" : @"UpArrowGroupTemplate.png"];
|
||||
else
|
||||
{
|
||||
BOOL upload = [ident isEqualToString: @"UL"];
|
||||
if ([fDefaults boolForKey: @"DisplayGroupRowRatio"])
|
||||
{
|
||||
if (!upload)
|
||||
return nil;
|
||||
|
||||
uint64_t uploaded = 0, downloaded = 0;
|
||||
NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
|
||||
Torrent * torrent;
|
||||
while ((torrent = [enumerator nextObject]))
|
||||
{
|
||||
uploaded += [torrent uploadedTotal];
|
||||
downloaded += [torrent downloadedTotal];
|
||||
}
|
||||
|
||||
return [NSString stringForRatio: tr_getRatio(uploaded, downloaded)];
|
||||
}
|
||||
else
|
||||
{
|
||||
float rate = 0.0;
|
||||
NSEnumerator * enumerator = [[item objectForKey: @"Torrents"] objectEnumerator];
|
||||
Torrent * torrent;
|
||||
|
@ -2512,6 +2531,7 @@ void sleepCallBack(void * controller, io_service_t y, natural_t messageType, voi
|
|||
return [NSString stringForSpeed: rate];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
return [item hashString];
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
<string>~/Desktop</string>
|
||||
<key>DeleteOriginalTorrent</key>
|
||||
<false/>
|
||||
<key>DisplayGroupRowRatio</key>
|
||||
<false/>
|
||||
<key>DisplayPeerProgressBarNumber</key>
|
||||
<false/>
|
||||
<key>DisplayProgressBarAvailable</key>
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
|
||||
- (BOOL) pointInProgressRect: (NSPoint) point;
|
||||
- (BOOL) pointInMinimalStatusRect: (NSPoint) point;
|
||||
|
||||
- (BOOL) pointInGroupStatusRect: (NSPoint) point;
|
||||
|
||||
- (void) updateFileMenu: (NSMenu *) menu forFiles: (NSArray *) files;
|
||||
|
||||
- (void) resizePiecesBarIncrement;
|
||||
|
@ -338,6 +341,14 @@
|
|||
{
|
||||
NSPoint point = [self convertPoint: [event locationInWindow] fromView: nil];
|
||||
|
||||
//check to toggle group status before anything else
|
||||
if ([self pointInGroupStatusRect: point])
|
||||
{
|
||||
[fDefaults setBool: ![fDefaults boolForKey: @"DisplayGroupRowRatio"] forKey: @"DisplayGroupRowRatio"];
|
||||
[self reloadData];
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL pushed = [self pointInControlRect: point] || [self pointInRevealRect: point] || [self pointInActionRect: point]
|
||||
|| [self pointInProgressRect: point] || [self pointInMinimalStatusRect: point];
|
||||
|
||||
|
@ -753,6 +764,18 @@
|
|||
return NSPointInRect(point, [cell minimalStatusRectForBounds: [self rectOfRow: row]]);
|
||||
}
|
||||
|
||||
- (BOOL) pointInGroupStatusRect: (NSPoint) point
|
||||
{
|
||||
int row = [self rowAtPoint: point];
|
||||
if (row < 0 || [[self itemAtRow: row] isKindOfClass: [Torrent class]])
|
||||
return NO;
|
||||
|
||||
NSString * ident = [[[self tableColumns] objectAtIndex: [self columnAtPoint: point]] identifier];
|
||||
return [ident isEqualToString: @"UL"] || [ident isEqualToString: @"UL Image"]
|
||||
|| (([ident isEqualToString: @"DL"] || [ident isEqualToString: @"DL Image"])
|
||||
&& ![fDefaults boolForKey: @"DisplayGroupRowRatio"]);
|
||||
}
|
||||
|
||||
- (void) updateFileMenu: (NSMenu *) menu forFiles: (NSArray *) files
|
||||
{
|
||||
BOOL create = [menu numberOfItems] <= 0;
|
||||
|
|
Loading…
Reference in New Issue