Ignore:
Timestamp:
Aug 12, 2012, 8:14:26 PM (10 years ago)
Author:
livings124
Message:

better spacing of the file/tracker/webseed list in Quick Look

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/QuickLookPlugin/GeneratePreviewForURL.m

    r13425 r13433  
    5959   
    6060    const NSUInteger width = 32;
    61     [htmlString appendFormat: @"<h2><img class=\"icon\" src=\"%@\" width=\"%ld\" height=\"%ld\">%@</h2>", generateIconData(fileTypeString, width, allImgProps), width, width, name];
     61    [htmlString appendFormat: @"<h2><img class=\"icon\" src=\"%@\" width=\"%ld\" height=\"%ld\" />%@</h2>", generateIconData(fileTypeString, width, allImgProps), width, width, name];
    6262   
    6363    NSString * fileSizeString = [NSString stringForFileSize: inf.totalSize];
     
    9393    }
    9494   
    95     [htmlString appendString: @"<hr/>"];
     95    NSMutableArray * lists = [NSMutableArray array];
    9696   
    9797    if (inf.webseedCount > 0)
    9898    {
    99         [htmlString appendString: @"<br><br><table>"];
     99        NSMutableString * listSection = [NSMutableString string];
     100        [listSection appendString: @"<table>"];
    100101       
    101102        NSString * headerTitleString = inf.webseedCount == 1 ? NSLocalizedString(@"1 Web Seed", "quicklook web seed header") : [NSString stringWithFormat: NSLocalizedString(@"%@ Web Seeds", "quicklook web seed header"), [NSString formattedUInteger: inf.webseedCount]];
    102         [htmlString appendFormat: @"<tr><th>%@</th></tr>", headerTitleString];
     103        [listSection appendFormat: @"<tr><th>%@</th></tr>", headerTitleString];
    103104       
    104105        for (int i = 0; i < inf.webseedCount; ++i)
    105             [htmlString appendFormat: @"<tr><td>%s<td></tr>", inf.webseeds[i]];
     106            [listSection appendFormat: @"<tr><td>%s<td></tr>", inf.webseeds[i]];
    106107       
    107         [htmlString appendString:@"</table>"];
     108        [listSection appendString:@"</table>"];
     109       
     110        [lists addObject: listSection];
    108111    }
    109112   
    110113    if (inf.trackerCount > 0)
    111114    {
    112         [htmlString appendString: @"<br><br><table>"];
     115        NSMutableString * listSection = [NSMutableString string];
     116        [listSection appendString: @"<table>"];
    113117       
    114118        NSString * headerTitleString = inf.trackerCount == 1 ? NSLocalizedString(@"1 Tracker", "quicklook tracker header") : [NSString stringWithFormat: NSLocalizedString(@"%@ Trackers", "quicklook tracker header"), [NSString formattedUInteger: inf.trackerCount]];
    115         [htmlString appendFormat: @"<tr><th>%@</th></tr>", headerTitleString];
     119        [listSection appendFormat: @"<tr><th>%@</th></tr>", headerTitleString];
    116120       
    117121#warning handle tiers?
    118122        for (int i = 0; i < inf.trackerCount; ++i)
    119             [htmlString appendFormat: @"<tr><td>%s<td></tr>", inf.trackers[i].announce];
     123            [listSection appendFormat: @"<tr><td>%s<td></tr>", inf.trackers[i].announce];
    120124       
    121         [htmlString appendString:@"</table>"];
     125        [listSection appendString:@"</table>"];
     126       
     127        [lists addObject: listSection];
    122128    }
    123129   
    124130    if (inf.isMultifile)
    125131    {
    126         [htmlString appendString: @"<br><br><table>"];
     132        NSMutableString * listSection = [NSMutableString string];
     133        [listSection appendString: @"<table>"];
    127134       
    128135        NSString * fileTitleString = inf.fileCount == 1 ? NSLocalizedString(@"1 File", "quicklook file header") : [NSString stringWithFormat: NSLocalizedString(@"%@ Files", "quicklook file header"), [NSString formattedUInteger: inf.fileCount]];
    129         [htmlString appendFormat: @"<tr><th>%@</th></tr>", fileTitleString];
     136        [listSection appendFormat: @"<tr><th>%@</th></tr>", fileTitleString];
    130137       
    131138#warning display size?
     
    139146           
    140147            const NSUInteger width = 16;
    141             [htmlString appendFormat: @"<tr><td><img class=\"icon\" src=\"%@\" width=\"%ld\" height=\"%ld\">%@<td></tr>", generateIconData([shortenedFilePath pathExtension], width, allImgProps), width, width, shortenedFilePath];
     148            [listSection appendFormat: @"<tr><td><img class=\"icon\" src=\"%@\" width=\"%ld\" height=\"%ld\" />%@<td></tr>", generateIconData([shortenedFilePath pathExtension], width, allImgProps), width, width, shortenedFilePath];
    142149        }
    143150       
    144         [htmlString appendString:@"</table>"];
     151        [listSection appendString:@"</table>"];
     152       
     153        [lists addObject: listSection];
    145154    }
     155   
     156    if ([lists count] > 0)
     157        [htmlString appendFormat: @"<hr/><br>%@", [lists componentsJoinedByString: @"<br><br>"]];
    146158   
    147159    [htmlString appendString: @"</body></html>"];
Note: See TracChangeset for help on using the changeset viewer.