r/macosprogramming • u/B8edbreth • Feb 06 '24
QuickLookThumbnailReply not working
I've attempted to create a quicklook thumbnail extension for my app. The problem is it doesn't work, never seems to be called, no break points are stopped at and nothing gets logged either to xcode's console or to the console app.
This is my code What am I doing wrong?
NSImage * image;
if([pe isEqualTo:@"dmp"]){
image = [self getIconFromSerialData:request.fileURL];
}
else if([pe isEqualTo:@"dmf"]){
image = [self getIconFromProject:request.fileURL];
}
NSRect rect = NSMakeRect(0, 0, request.maximumSize.width, request.maximumSize.height);
DMImageViewExtension * iv = [[DMImageViewExtension alloc]initWithFrame:rect];
handler([QLThumbnailReply replyWithContextSize:request.maximumSize drawingBlock:^BOOL(CGContextRef _Nonnull context) {
NSGraphicsContext * ctx = [NSGraphicsContext graphicsContextWithCGContext:context flipped:NO];
[iv drawIntoContext:ctx withRect:iv.bounds];
return YES;
}], nil);This is the property list for the extension:
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>QLSupportedContentTypes</key>
<array>
<string>com.dm.serialized</string>
<string>com.dm.project</string>
</array>
<key>QLThumbnailMinimumDimension</key>
<integer>10</integer>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.quicklook.thumbnail</string>
<key>NSExtensionPrincipalClass</key>
<string>ThumbnailProvider</string>
</dict>Do I need to take out the icon file information from my app's info.plist file?
1
Upvotes
View all comments
Show parent comment
1
u/B8edbreth Feb 08 '24
I manually created a request and the request gets an image back but it's an empty image. Even if I get the image from the default icon in the bundle it's still just an empty image.
This is what I'm drawing it with:
"[iv imageRepresentation:NO];" is just a method in my NSImageView subclass that converts the imageview's contents in to a NSImage. It works in the main application. And again if I get the icon from the main bundle I still get a blank image so I'm sure the problem is my drawing code.