1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

Clicking in general area of status string in minimal view will toggle between speeds and remaining time for downloading transfers.

This commit is contained in:
Mitchell Livingston 2006-07-25 00:59:14 +00:00
parent 42a838d155
commit 2d66761e19
5 changed files with 70 additions and 16 deletions

View file

@ -45,7 +45,7 @@
NSUserDefaults * fDefaults;
NSImage * fIcon, * fIconFlipped, * fIconSmall;
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString;
NSMutableString * fNameString, * fProgressString, * fStatusString, * fShortStatusString, * fRemainingTimeString;
int fStopRatioSetting;
float fRatioLimit;
@ -114,9 +114,10 @@
- (BOOL) isPaused;
- (BOOL) justFinished;
- (NSString *) progressString;
- (NSString *) statusString;
- (NSString *) shortStatusString;
- (NSString *) progressString;
- (NSString *) statusString;
- (NSString *) shortStatusString;
- (NSString *) remainingTimeString;
- (int) seeders;
- (int) leechers;

View file

@ -119,6 +119,7 @@
[fProgressString release];
[fStatusString release];
[fShortStatusString release];
[fRemainingTimeString release];
}
[super dealloc];
}
@ -187,6 +188,7 @@
[fStatusString setString: tempString];
[fShortStatusString setString: tempString];
[fRemainingTimeString setString: tempString];
break;
@ -196,18 +198,27 @@
@"Downloading from %d of %d peer%s", [self peersUploading], [self totalPeers],
[self totalPeers] == 1 ? "" : "s"];
[fRemainingTimeString setString: @""];
int eta = [self eta];
if (eta < 0)
{
[fRemainingTimeString setString: @"Unknown"];
[fProgressString appendString: @" - remaining time unknown"];
else if (eta < 60)
[fProgressString appendFormat: @" - %d sec remaining", eta];
else if (eta < 3600) //60 * 60
[fProgressString appendFormat: @" - %d min %02d sec remaining", eta / 60, eta % 60];
else if (eta < 86400) //24 * 60 * 60
[fProgressString appendFormat: @" - %d hr %02d min remaining", eta / 3600, (eta / 60) % 60];
}
else
[fProgressString appendFormat: @" - %d day%s %d hr remaining",
eta / 86400, eta / 86400 == 1 ? "" : "s", (eta / 3600) % 24];
{
if (eta < 60)
[fRemainingTimeString appendFormat: @"%d sec", eta];
else if (eta < 3600) //60 * 60
[fRemainingTimeString appendFormat: @"%d min %02d sec", eta / 60, eta % 60];
else if (eta < 86400) //24 * 60 * 60
[fRemainingTimeString appendFormat: @"%d hr %02d min", eta / 3600, (eta / 60) % 60];
else
[fRemainingTimeString appendFormat: @"%d day%s %d hr",
eta / 86400, eta / 86400 == 1 ? "" : "s", (eta / 3600) % 24];
[fProgressString appendFormat: @" - %@ remaining", fRemainingTimeString];
}
break;
@ -510,6 +521,11 @@
return fShortStatusString;
}
- (NSString *) remainingTimeString
{
return fRemainingTimeString;
}
- (int) seeders
{
return fStat->seeders;
@ -667,7 +683,8 @@
fProgressString = [[NSMutableString alloc] initWithCapacity: 50];
fStatusString = [[NSMutableString alloc] initWithCapacity: 75];
fShortStatusString = [[NSMutableString alloc] initWithCapacity: 50];
fShortStatusString = [[NSMutableString alloc] initWithCapacity: 30];
fRemainingTimeString = [[NSMutableString alloc] initWithCapacity: 30];
[self update];
return self;

View file

@ -31,10 +31,15 @@
@interface TorrentCell : NSCell
{
Torrent * fTorrent;
BOOL fNormalStatus;
NSUserDefaults * fDefaults;
}
- (void) setTorrent: (Torrent *) torrent;
- (void) setTorrent: (Torrent *) torrent;
- (void) toggleMinimalStatus;
@end
#endif

View file

@ -63,6 +63,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
{
if ((self = [super init]))
{
fNormalStatus = YES;
fDefaults = [NSUserDefaults standardUserDefaults];
NSSize startSize = NSMakeSize(100.0, BAR_HEIGHT);
@ -280,6 +282,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[fProgressEndAdvanced compositeToPoint: point operation: NSCompositeSourceOver];
}
- (void) toggleMinimalStatus
{
fNormalStatus = !fNormalStatus;
}
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) view
{
BOOL highlighted = [self isHighlighted] && [[self highlightColorWithFrame: cellFrame inView: view]
@ -355,7 +362,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
//name and status string
float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
NSAttributedString * statusString = [[[NSAttributedString alloc] initWithString: [fTorrent shortStatusString]
NSString * realStatusString = !fNormalStatus && [fTorrent isActive] && [fTorrent progress] < 1.0
? [fTorrent remainingTimeString] : [fTorrent shortStatusString];
NSAttributedString * statusString = [[[NSAttributedString alloc] initWithString: realStatusString
attributes: statusAttributes] autorelease];
NSAttributedString * nameString = [[fTorrent name] attributedStringFittingInWidth:
mainWidth - [statusString size].width - LINE_PADDING attributes: nameAttributes];

View file

@ -23,6 +23,7 @@
*****************************************************************************/
#import "TorrentTableView.h"
#import "TorrentCell.h"
#import "Controller.h"
#import "Torrent.h"
@ -41,6 +42,7 @@
- (BOOL) pointInPauseRect: (NSPoint) point;
- (BOOL) pointInRevealRect: (NSPoint) point;
- (BOOL) pointInIconRect: (NSPoint) point;
- (BOOL) pointInMinimalStatusRect: (NSPoint) point;
@end
@ -94,7 +96,12 @@
fClickPoint = NSZeroPoint;
}
else if (![self pointInPauseRect: fClickPoint] && ![self pointInRevealRect: fClickPoint])
{
if ([self pointInMinimalStatusRect: fClickPoint])
[(TorrentCell *)[[self tableColumnWithIdentifier: @"Torrent"] dataCell] toggleMinimalStatus];
[super mouseDown: event];
}
else;
[self display];
@ -274,6 +281,20 @@
return NSPointInRect(point, iconRect);
}
- (BOOL) pointInMinimalStatusRect: (NSPoint) point
{
int row = [self rowAtPoint: point];
if (row < 0 || ![fDefaults boolForKey: @"SmallView"])
return NO;
const STATUS_WIDTH = 130.0;
NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row];
NSRect statusRect = NSMakeRect(NSMaxX(cellRect) - STATUS_WIDTH, cellRect.origin.y,
STATUS_WIDTH, cellRect.size.height - BUTTON_WIDTH);
return NSPointInRect(point, statusRect);
}
- (BOOL) pointInPauseRect: (NSPoint) point
{
return NSPointInRect(point, [self pauseRectForRow: [self rowAtPoint: point]]);