Changeset 13412


Ignore:
Timestamp:
Jul 25, 2012, 12:48:13 PM (9 years ago)
Author:
livings124
Message:

More 10.8 better file size formatting.

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r13252 r13412  
    3232#import "InfoOptionsViewController.h"
    3333#import "InfoTabButtonCell.h"
     34#import "NSApplicationAdditions.h"
    3435#import "NSStringAdditions.h"
    3536#import "Torrent.h"
     
    449450                    [NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
    450451                        [NSString stringForFileSize: size]]]];
    451                 [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes",
    452                                                 "Inspector -> selected torrents"), [NSString formattedUInteger: size]]];
     452               
     453                NSString * byteString;
     454                if ([NSApp isOnMountainLionOrBetter])
     455                {
     456                    NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
     457                    [formatter setAllowedUnits: NSByteCountFormatterUseBytes];
     458                    byteString = [formatter stringFromByteCount: size];
     459                    [formatter release];
     460                }
     461                else
     462                    byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: size]];
     463                [fBasicInfoField setToolTip: byteString];
    453464            }
    454465            else
     
    498509            }
    499510            [fBasicInfoField setStringValue: basicString];
    500             [fBasicInfoField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"),
    501                                             [NSString formattedUInteger: [torrent size]]]];
     511           
     512            NSString * byteString;
     513            if ([NSApp isOnMountainLionOrBetter])
     514            {
     515                NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
     516                [formatter setAllowedUnits: NSByteCountFormatterUseBytes];
     517                byteString = [formatter stringFromByteCount: [torrent size]];
     518                [formatter release];
     519            }
     520            else
     521                byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: [torrent size]]];
     522            [fBasicInfoField setToolTip: byteString];
    502523        }
    503524        else
  • trunk/macosx/StatsWindowController.m

    r13352 r13412  
    182182    tr_sessionGetStats(fLib, &statsSession);
    183183   
     184    NSByteCountFormatter * byteFormatter = nil;
     185    if ([NSApp isOnMountainLionOrBetter])
     186    {
     187        byteFormatter = [[NSByteCountFormatterMtLion alloc] init];
     188        [byteFormatter setAllowedUnits: NSByteCountFormatterUseBytes];
     189    }
     190   
    184191    [fUploadedField setStringValue: [NSString stringForFileSize: statsSession.uploadedBytes]];
    185     [fUploadedField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
    186                                     [NSString formattedUInteger: statsSession.uploadedBytes]]];
    187     [fUploadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
    188                                         [NSString stringForFileSize: statsAll.uploadedBytes]]];
    189     [fUploadedAllField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
    190                                     [NSString formattedUInteger: statsAll.uploadedBytes]]];
     192    [fUploadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.uploadedBytes]]];
     193    [fUploadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.uploadedBytes]]];
     194    [fUploadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.uploadedBytes]]];
    191195   
    192196    [fDownloadedField setStringValue: [NSString stringForFileSize: statsSession.downloadedBytes]];
    193     [fDownloadedField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
    194                                     [NSString formattedUInteger: statsSession.downloadedBytes]]];
    195     [fDownloadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
    196                                         [NSString stringForFileSize: statsAll.downloadedBytes]]];
    197     [fDownloadedAllField setToolTip: [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"),
    198                                         [NSString formattedUInteger: statsAll.downloadedBytes]]];
     197    [fDownloadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.downloadedBytes]]];
     198    [fDownloadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.downloadedBytes]]];
     199    [fDownloadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.downloadedBytes]]];
     200   
     201    [byteFormatter release];
    199202   
    200203    [fRatioField setStringValue: [NSString stringForRatio: statsSession.ratio]];
     
    206209   
    207210    [fTimeField setStringValue: [NSString timeString: statsSession.secondsActive showSeconds: NO]];
    208     [fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"),
    209                                         [NSString timeString: statsAll.secondsActive showSeconds: NO]]];
     211    [fTimeAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString timeString: statsAll.secondsActive showSeconds: NO]]];
    210212   
    211213    if (statsAll.sessionCount == 1)
    212214        [fNumOpenedField setStringValue: NSLocalizedString(@"1 time", "stats window -> times opened")];
    213215    else
    214         [fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ times", "stats window -> times opened"),
    215                                             [NSString formattedUInteger: statsAll.sessionCount]]];
     216        [fNumOpenedField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ times", "stats window -> times opened"), [NSString formattedUInteger: statsAll.sessionCount]]];
    216217}
    217218
Note: See TracChangeset for help on using the changeset viewer.