#import "InfoFileViewController.h"
#import "InfoOptionsViewController.h"
#import "InfoTabButtonCell.h"
+#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h"
#import "Torrent.h"
[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
{
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
{
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]];
[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