More 10.8 better file size formatting.
This commit is contained in:
parent
4021d39a63
commit
53576bfa85
|
@ -31,6 +31,7 @@
|
|||
#import "InfoFileViewController.h"
|
||||
#import "InfoOptionsViewController.h"
|
||||
#import "InfoTabButtonCell.h"
|
||||
#import "NSApplicationAdditions.h"
|
||||
#import "NSStringAdditions.h"
|
||||
#import "Torrent.h"
|
||||
|
||||
|
@ -448,8 +449,18 @@ typedef enum
|
|||
[fBasicInfoField setStringValue: [NSString stringWithFormat: @"%@, %@", fileString,
|
||||
[NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
|
||||
[NSString stringForFileSize: size]]]];
|
||||
[fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes",
|
||||
"Inspector -> selected torrents"), [NSString formattedUInteger: size]]];
|
||||
|
||||
NSString * byteString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
byteString = [formatter stringFromByteCount: size];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: size]];
|
||||
[fBasicInfoField setToolTip: byteString];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -497,8 +508,18 @@ typedef enum
|
|||
basicString = [NSString stringWithFormat: @"%@, %@", fileString, basicString];
|
||||
}
|
||||
[fBasicInfoField setStringValue: basicString];
|
||||
[fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"),
|
||||
[NSString formattedUInteger: [torrent size]]]];
|
||||
|
||||
NSString * byteString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
byteString = [formatter stringFromByteCount: [torrent size]];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: [torrent size]]];
|
||||
[fBasicInfoField setToolTip: byteString];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -181,21 +181,24 @@ tr_session * fLib = NULL;
|
|||
tr_sessionGetCumulativeStats(fLib, &statsAll);
|
||||
tr_sessionGetStats(fLib, &statsSession);
|
||||
|
||||
NSByteCountFormatter * byteFormatter = nil;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
byteFormatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[byteFormatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
}
|
||||
|
||||
[fUploadedField setStringValue: [NSString stringForFileSize: statsSession.uploadedBytes]];
|
||||
[fUploadedField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
|
||||
[NSString formattedUInteger: statsSession.uploadedBytes]]];
|
||||
[fUploadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
|
||||
[NSString stringForFileSize: statsAll.uploadedBytes]]];
|
||||
[fUploadedAllField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
|
||||
[NSString formattedUInteger: statsAll.uploadedBytes]]];
|
||||
[fUploadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.uploadedBytes]]];
|
||||
[fUploadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.uploadedBytes]]];
|
||||
[fUploadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.uploadedBytes]]];
|
||||
|
||||
[fDownloadedField setStringValue: [NSString stringForFileSize: statsSession.downloadedBytes]];
|
||||
[fDownloadedField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
|
||||
[NSString formattedUInteger: statsSession.downloadedBytes]]];
|
||||
[fDownloadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
|
||||
[NSString stringForFileSize: statsAll.downloadedBytes]]];
|
||||
[fDownloadedAllField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
|
||||
[NSString formattedUInteger: statsAll.downloadedBytes]]];
|
||||
[fDownloadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.downloadedBytes]]];
|
||||
[fDownloadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.downloadedBytes]]];
|
||||
[fDownloadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.downloadedBytes]]];
|
||||
|
||||
[byteFormatter release];
|
||||
|
||||
[fRatioField setStringValue: [NSString stringForRatio: statsSession.ratio]];
|
||||
|
||||
|
@ -205,14 +208,12 @@ tr_session * fLib = NULL;
|
|||
[fRatioAllField setStringValue: totalRatioString];
|
||||
|
||||
[fTimeField setStringValue: [NSString timeString: statsSession.secondsActive showSeconds: NO]];
|
||||
[fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
|
||||
[NSString timeString: statsAll.secondsActive showSeconds: NO]]];
|
||||
[fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString timeString: statsAll.secondsActive showSeconds: NO]]];
|
||||
|
||||
if (statsAll.sessionCount == 1)
|
||||
[fNumOpenedField setStringValue: NSLocalizedString(@"1 time", "stats window -> times opened")];
|
||||
else
|
||||
[fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ times", "stats window -> times opened"),
|
||||
[NSString formattedUInteger: statsAll.sessionCount]]];
|
||||
[fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ times", "stats window -> times opened"), [NSString formattedUInteger: statsAll.sessionCount]]];
|
||||
}
|
||||
|
||||
- (void) performResetStats
|
||||
|
|
Loading…
Reference in New Issue