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