Skip to content

Commit

Permalink
first view of .gradle preview
Browse files Browse the repository at this point in the history
  • Loading branch information
vrunoa committed Feb 11, 2015
1 parent 48857a4 commit 5a71569
Showing 1 changed file with 7 additions and 49 deletions.
56 changes: 7 additions & 49 deletions QLGradle/GeneratePreviewForURL.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,58 +22,16 @@ OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
@autoreleasepool {

NSURL *URL = (__bridge NSURL *)url;
NSLog(@"url %@", url);

NSString *dataType = (__bridge NSString *)contentTypeUTI;
NSLog(@"type %@", dataType);

NSMutableDictionary *maxSize = [NSMutableDictionary alloc];

float width = 1024.0;
float height = 800.0;

NSData* data = [NSData dataWithContentsOfURL:URL];

if (data) {
NSRect viewRect = NSMakeRect(0.0, 0.0, 600.0, 800.0);
float scale = height / 800.0;
NSSize scaleSize = NSMakeSize(scale, scale);
CGSize thumbSize = NSSizeToCGSize(
NSMakeSize((width * (600.0/800.0)),
height));

WebView* webView = [[WebView alloc] initWithFrame: viewRect];
[webView scaleUnitSquareToSize: scaleSize];
[[[webView mainFrame] frameView] setAllowsScrolling:NO];
[[webView mainFrame] loadData: data
MIMEType: @"text/html"
textEncodingName: @"utf-8"
baseURL: nil];

while([webView isLoading]) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
}

[webView display];

//CGContextRef context =
//QLThumbnailRequestCreateContext(thumbnail, thumbSize, false, NULL);
if([dataType isEqualToString:@"dyn.ah62d4rv4ge80s6xbqv0gn"]) {

/*
if (context) {
NSGraphicsContext* nsContext =
[NSGraphicsContext
graphicsContextWithGraphicsPort: (void*) context
flipped: [webView isFlipped]];
[webView displayRectIgnoringOpacity: [webView bounds]
inContext: nsContext];
QLThumbnailRequestFlushContext(thumbnail, context);
CFRelease(context);
}
*/
QLPreviewRequestSetURLRepresentation(
preview,
url,
kUTTypePlainText,
NULL
);
}

}
Expand Down

0 comments on commit 5a71569

Please sign in to comment.