Abandoned: macOS: support QuickLook preview #107014
@ -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)
|
||||
|
@ -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>
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user