Set window size of QuickLook module

I am creating a QuickLook plugin. I want to change the width of the windows that appear when the user falls into a space.

I read that there are two keys in the project info.plist file, where the height and width are adjustable. Even if I change these values, I cannot get the size of the preview windows as I wish.

I do not know what else to try. Any idea?

Thanks!

+7
objective-c cocoa quicklook
source share
2 answers

Thought I'd do something. I have not tried any of the following suggestions, so no one hopes. I assume you are using a generator callback:

OSStatus (*GeneratePreviewForURL)( void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options ); 

First of all, you can manually check the argument of the options dictionary and make sure that the kQLPreviewPropertyWidthKey and kQLPreviewPropertyHeightKey indeed mapped to the desired CFNumber values.

Referring to each of these properties, the Apple QuickLook Programming Guide says:

Note that this property is a hint; Quick Look can set the width automatically for some types of previews. The value must be encapsulated in a CFNumber object.

( Edit: If your preview view is flexible, you can try to find a type of preview for which QuickLook estimates your tooltips by size, as described above. Just a thought.)

Running nm on the QuickLook binary system revealed some of the undocumented kQLPreviewProperty-- constants, as well as the aforementioned width and height keys. I got the attention of kQLPreviewPropertyAutoSizeKey . Remembering Apple's expression about ignoring prompts to set the size automatically, can it be significant? Following the convention in QuickLook.framework/Headers/QLBase.h , you can try declaring

 extern const CFStringRef kQLPreviewPropertyAutoSizeKey; 

You can then try to associate CFNumber 0 with this property key in the options dictionary. There are other undocumented keys, for example kQLPreviewPropertyAttributesKey .

Back to the Info.plist that you mentioned, Apple talks about these QLPreviewWidth and QLPreviewHeight :

This number gives Quick Look a hint for the width (in dots) of the previews. It uses these values ​​if the generator takes too long a preview. (in italics)

Here, someone makes a scary suggestion to call sleep () in your generator. But I wonder why Apple will make the following size hints, depending on the delay of the generator. (?)

Edit: Also note that the above statement suggests that Info.plist hints should be expressed in points (not pixels), a unit on the user screen.

+4
source share

I recently developed Quick Look Plugin myself, which uses HTML + CSS and faced the same problem. The solution for me was to test the plugin not in Xcode and qlmanage as an executable file, but instead try real.qlgenerator from my user library .

When the generator was called from my user library, the quick view window was changed exactly as I indicated in * -Info.plist.

+2
source share

All Articles