Abandoned: macOS: support QuickLook preview #107014

Closed
Ankit Meel wants to merge 8 commits from ankitm:ankitm/quicklook into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
5 changed files with 42 additions and 15 deletions
Showing only changes of commit d843b71fd5 - Show all commits

View File

@ -76,8 +76,8 @@ if(APPLE)
set_target_properties(blender-thumbnailer PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/src/Info.plist
MACOSX_FRAMEWORK_IDENTIFIER org.blenderfoundation.blender.thumbnailer)
set_target_properties(blender-thumbnailer PROPERTIES
XIB_RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/Base.lproj")
# set_target_properties(blender-thumbnailer PROPERTIES
# XIB_RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/Base.lproj")
# Doesn't affect other generators. So need to specify extension for others.
set_target_properties(blender-thumbnailer PROPERTIES
XCODE_PRODUCT_TYPE com.apple.product-type.app-extension)

View File

@ -34,13 +34,11 @@
<array>
<string>org.blenderfoundation.blender.file</string>
</array>
<key>QLThumbnailMinimumDimension</key>
<integer>0</integer>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.quicklook.preview</string>
<key>NSExtensionPrincipalClass</key>
<string>PreviewProvider</string>
<string>com.apple.quicklook.thumbnail</string>
<key>com.apple.showsInExtensionsManager</key>
<true/>
</dict>
</dict>
</plist>

View File

@ -1,8 +1,14 @@
#include <AppKit/AppKit.h>
#import <Quartz/Quartz.h>
#import <QuickLookThumbnailing/QuickLookThumbnailing.h>
NS_ASSUME_NONNULL_BEGIN
@interface ThumbnailProvider : QLThumbnailProvider
@end
@interface PreviewViewController : NSViewController <QLPreviewingController>
@end

View File

@ -61,6 +61,30 @@ static eThumbStatus creator_impl(const char *src_blend_path)
return err;
}
@implementation ThumbnailProvider
- (void)provideThumbnailForFileRequest:(QLFileThumbnailRequest *)request
completionHandler:(void (^)(QLThumbnailReply *_Nullable reply,
NSError *_Nullable error))handler
{
@autoreleasepool { // Add the supported content types to the QLSupportedContentTypes array in
// the Info.plist of the
// extension.
std::cout << "Hello World from blender Blender thumbnailer" << std::endl;
NSLog(@"hello world from blender");
NSURL *foo = [[NSURL alloc]
initFileURLWithFileSystemRepresentation:"/Users/ankitkumar/Pictures/IMG_3158.JPG"
isDirectory:NO
relativeToURL:nil];
QLThumbnailReply *reply = [QLThumbnailReply replyWithImageFileURL:foo];
handler(reply, nil);
}
}
@end
@implementation PreviewViewController
- (NSString *)nibName
@ -103,14 +127,14 @@ extension if you support CoreSpotlight.
// Quick Look will display a loading spinner while the completion handler is not called.
NSLog(@"blender preparePreviewOfFileAtURL: %@", url);
std::ofstream file("/Users/ankit.kumar/apps/build_xcode/foobar.txt",
std::ofstream file("/Users/ankitkumar/blender-build/build_darwin_debug_lite/foobar.txt",
std::ios::out | std::ios::trunc | std::ios::binary);
file << "Hello World";
file.close();
std::cout << "Hello World" << std::endl;
// set image to file path /Users/ankit.kumar/Desktop/Screenshot 2021-09-02 at 1.59.47 PM.png
[[[self view] imageRepresentation]
setFileURL:[NSURL fileURLWithPath:@"file:///Users/ankit.kumar/Desktop/Screenshot.png"
setFileURL:[NSURL fileURLWithPath:@"/Users/ankitkumar/Pictures/IMG_3158.JPG"
isDirectory:NO]];
[[self view] display];
handler(nil);

View File

@ -1354,12 +1354,11 @@ elseif(APPLE)
TARGETS blender-thumbnailer
DESTINATION Blender.app/Contents/Plugins
)
get_target_property(XIB_RESOURCE blender-thumbnailer XIB_RESOURCE)
install_dir(
${XIB_RESOURCE}
Blender.app/Contents/Plugins/blender-thumbnailer.appex/Contents/Resources
)
# get_target_property(XIB_RESOURCE blender-thumbnailer XIB_RESOURCE)
# install_dir(
# ${XIB_RESOURCE}
# Blender.app/Contents/Plugins/blender-thumbnailer.appex/Contents/Resources
# )
endif()
if(PLATFORM_BUNDLED_LIBRARIES AND TARGETDIR_LIB)