sbarex / QLMarkdown

macOS Quick Look extension for Markdown files.
GNU General Public License v3.0
1.38k stars 34 forks source link

Quicklook window is way to big for 1.0.4 onward #87

Closed Ken0sis closed 2 years ago

Ken0sis commented 2 years ago

Whenever I activate quicklook on Monterey using version 1.0.4 or later, it takes up the entire screen and is very disruptive. I don't think this was a normal behavior before 1.0.4, so I had to downgrade. I would like to be able to use newer versions, so is this something I can adjust on my end or will I have to accept staying with old version?

Maybe this thread from Stackoverflow has something to do with it: https://stackoverflow.com/questions/65633750/set-quicklook-window-size-when-previewing-with-qlpreviewingcontroller-preparepre

sbarex commented 2 years ago

I cannot reproduce this behavior on my system.

Anyway I have implemented in version 1.0.9 a way to set a fixed size for the preview window. Try using the Quick Look size option in the advanced settings panel.

Ken0sis commented 2 years ago

Thanks! This update does seem to give ability to adjust default size of quicklook window! Just so everyone else knows, settings are not saved or updated automatically and you need to save on exit or hit "save" for the change to take effect.

As a quick side question to @sbarex , is it always possible to change the default quicklook window size on the user end, or is it a feature that the developer has to enable first?

sbarex commented 2 years ago

Dear @Ken0sis , I have found that customizing the window size is quite simple for the developer of the Quick Look extension.

MacOS Monterey has extended the QLPreviewingController with a new API that is reminiscent of the old Quick Look generator. (Remeber, to use the new API you must set QLIsDataBasedPreview to YES in the NSExtension > NSExtensionAttributes dictionary inside the Info.plist of the Quick Look Extension.)

The new API QLPreviewingController.providePreview(for:completionHandler:) require to pass a QLPreviewReply instance to the completionHandler closure. You can initialize the QLPreviewReply with init(dataOfContentType contentType: UTType, contentSize: CGSize, createDataUsing closure: @escaping (QLPreviewReply) throws -> Data). The argument contentSize allow to set the preview size.

For macOS before Monterey you can use the preferredContentSize of the NSViewController.