Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add external preview (QuickLook) support #2082

Merged
merged 53 commits into from
Jun 16, 2024

Conversation

VictoriousRaptor
Copy link
Contributor

@VictoriousRaptor VictoriousRaptor commented Apr 22, 2023

Refined version of #859. Too many merging conflict so I just create a new branch instead. Compatible with our preview function.

Changes

  • Add a property FilePath for Result.Preview to indicate what file should QuickLook preview.
    • Explorer Plugin support
  • An option to choose using QuickLook or not. Default is false.

Behavior

  • Preview Hotkey is used to toggle QuickLook in Flow.
  • If built-in preview is already open, QuickLook won't be triggered before user closes built-in preview. It's to deal with "Always Preview" option and switching between results that supports QuickLook or not.
  • When a result has non-null Preview.FilePath try to use QuickLook to preview.
  • Flow's preview and QuickLook don't open at the same time. If a result has non-null Preview.FilePath pressing hotkey only triggers QuickLook.
  • When QuickLook is unavailable, a notification is sent to tell users to check status.
  • QL is forcibly closed when hiding flow.
  • If Flow "thinks" QL is open, a lost focus won't close Flow. This is to make sure users can interact with QL's UI controls. But when QL is closed by clicking its close button, opening QL again and interact with it will close Flow.

Problems

  • Should "Always Preview" open QuickLook? No
  • When "Always Preview" is on (which means internal preview is on), selecting another result that can use QuickLook triggers QuickLook. Looks bad.
  • When "Use QuickLook" is on but QuickLook is not launched or installed what kind of warning should be send to users? Send a notification
  • No QuickLook API to set on top. (Open selected result in quicklook #859 (comment)) Manually set it.
  • Switching from external preview result to builtin result doesn't properly trigger builtin preview.

TODO

  • Roughly tested but need some more tests and code review. Generally looking good so far.
  • A better glyph in settings.

Screenshot

image

Summary by CodeRabbit

  • New Features

    • Added QuickLook plugin for file previews, enabling functionalities like toggling, opening, closing, and switching previews.
    • Introduced settings for always using the preview feature.
  • Enhancements

    • Improved preview functionality with new properties and default values for better user experience.
    • Extended support for file previews in various result types (folders, drives, files).
  • Bug Fixes

    • Fixed visibility bindings in the main window for more consistent UI behavior.
  • Documentation

    • Updated language resource files with new translations related to QuickLook.

@VictoriousRaptor VictoriousRaptor requested a review from Garulf April 22, 2023 09:43
@github-actions

This comment has been minimized.

@Garulf
Copy link
Member

Garulf commented Apr 22, 2023

Just got a chance to test run this. It looks very good! I have a few opinions on some of your problems listed:

Should "Always Preview" open QuickLook?

I don't think this works well with quick look as both windows overlap.

When "Use QuickLook" is on but QuickLook is not launched or installed what kind of warning should be send to users?

I think we can resolve this by greying out this option if a QuickLook installation is not detected. This can be tricky though as QuickLook is available in many different forms including the Windows app store.

Instead of tracking all this down we could send a pipe message and check its status to see if quick look is available and determine to enable the option.

No QuickLook API to set on top. (#859 (comment))

This was also an issue with the original PR.

@Garulf Garulf mentioned this pull request Apr 22, 2023
3 tasks
@jjw24
Copy link
Member

jjw24 commented Apr 22, 2023

QuickLook functionality should be provided fully by a plugin. To achieve this we need to use this #1013, and this pr is a working POC already.

@jjw24 jjw24 added the enhancement New feature or request label Apr 22, 2023
@jjw24 jjw24 added this to the Future milestone Apr 22, 2023
@Garulf
Copy link
Member

Garulf commented Apr 23, 2023

QuickLook functionality should be provided fully by a plugin. To achieve this we need to use this #1013, and this pr is a working POC already.

I don't think @VictoriousRaptor was around for that. But yes as a plugin would be ideal.

Also I would use this PR in favor of my older code. This is more fleshed out.

@jjw24
Copy link
Member

jjw24 commented Apr 23, 2023

Maybe best that @VictoriousRaptor just continue work as is with this one so we can keep the momentum, once I helped onesound I will come back to finishing off that pr 1013 and migrate the finished code here into a plugin.

@VictoriousRaptor
Copy link
Contributor Author

Maybe best that @VictoriousRaptor just continue work as is with this one so we can keep the momentum, once I helped onesound I will come back to finishing off that pr 1013 and migrate the finished code here into a plugin.

Ok I'll do some more tests on this PR and try to figure out the problems.

@VictoriousRaptor
Copy link
Contributor Author

When "Use QuickLook" is on but QuickLook is not launched or installed what kind of warning should be send to users?

I think we can resolve this by greying out this option if a QuickLook installation is not detected. This can be tricky though as QuickLook is available in many different forms including the Windows app store.

Instead of tracking all this down we could send a pipe message and check its status to see if quick look is available and determine to enable the option.

Greying out option is good. And what if user enables this option (with QuickLook installed and running), and then quit QuickLook and preview in Flow? Should we fallback to Flow's preview? And what kind of message to tell users we are not able to launch QuickLook? Maybe a notification toast?

No QuickLook API to set on top. (#859 (comment))

This was also an issue with the original PR.

Not a big deal. Just manually set it once and for all.

@VictoriousRaptor VictoriousRaptor added this to the 1.19.0 milestone May 30, 2024
@VictoriousRaptor VictoriousRaptor disabled auto-merge May 30, 2024 13:51
@@ -871,7 +871,7 @@ public void ResetPreview()
{
if (Settings.AlwaysPreview)
{
ShowPreview();
ShowInternalPreview();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When AlwaysPreview is true, specify internal preview.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because QL is not suitable for using with always preview right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because QL is not suitable for using with always preview right?

Yep

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when we have other preview tools that is suitable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when we have other preview tools that is suitable?

Well maybe pass always preview to plugin and let plugin decide? If plugin returns false then use internal preview.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Let me know if good to merge.

@@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we merge is this plugin going to be a default one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I will take it out before merge. There is already a QL plugin repo in the org.

@jjw24 jjw24 removed the review in progress Indicates that a review is in progress for this PR label Jun 16, 2024
Copy link
Contributor

coderabbitai bot commented Jun 16, 2024

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Walkthrough

This update introduces enhancements to the Flow Launcher application, focusing on integration with external preview tools like QuickLook. Key changes involve new methods for async handling of file previews, additional boolean properties for settings, refinements in preview functionalities, and the inclusion of the QuickLook plugin with relevant configurations and resources.

Changes

File(s) Change Summary
.github/actions/spelling/expect.txt Added "quicklook" to the list of languages.
Flow.Launcher.Core/Plugin/PluginManager.cs Added async methods for handling external previews (open, close, switch) and checking preview settings.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Added AlwaysPreview and AlwaysStartEn properties with default values set to false.
Flow.Launcher.Plugin/Interfaces/IAsyncExternalPreview.cs Added AllowAlwaysPreview() method to IAsyncExternalPreview interface.
Flow.Launcher.Plugin/Result.cs Initialized PreviewInfo properties with default values and added FilePath property.
Flow.Launcher.sln Updated project references and configurations for various build platforms.
Flow.Launcher/Helper/QuickLookHelper.cs Introduced QuickLookHelper static class with methods for handling QuickLook previews.
Flow.Launcher/MainWindow.xaml, Flow.Launcher/MainWindow.xaml.cs Updated visibility bindings and conditions for preview visibility.
Flow.Launcher/ViewModel/MainViewModel.cs Refactored preview functionality with new methods for internal/external previews and related properties.
Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs Enhanced preview information in various result creation methods, including Preview property adjustments.
Plugins/Flow.Launcher.Plugin.QuickLook/ (various files) Introduced QuickLook plugin with helper methods, resource definitions, project setup, and configuration for preview functionality integration.

Sequence Diagram

sequenceDiagram
    participant User
    participant MainViewModel
    participant PluginManager
    participant QuickLookHelper
    participant ExternalApp

    User->>MainViewModel: Request preview for a file
    MainViewModel->>PluginManager: Check if external preview is enabled
    PluginManager-->>MainViewModel: Returns status
    alt External Preview Enabled
        MainViewModel->>QuickLookHelper: OpenQuickLookAsync(path)
        QuickLookHelper->>ExternalApp: Open preview for file
        ExternalApp-->>QuickLookHelper: Preview opened
        QuickLookHelper-->>MainViewModel: Confirm preview opened
        MainViewModel-->>User: Show external preview
    else
        MainViewModel->>InternalPreview: Open internal preview
        InternalPreview-->>MainViewModel: Confirm preview opened
        MainViewModel-->>User: Show internal preview
    end
Loading

Poem

In fields of code where rabbits play,
A new preview dawns today.
QuickLook glimmers with async might,
Enhancing files, day or night.
Plugins dance and settings refine,
Flow Launcher, truly divine.
🌠✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jjw24
Copy link
Member

jjw24 commented Jun 16, 2024

@coderabbitai pause

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Flow.Launcher/ViewModel/MainViewModel.cs Show resolved Hide resolved
Flow.Launcher/ViewModel/MainViewModel.cs Show resolved Hide resolved
Plugins/Flow.Launcher.Plugin.QuickLook/Main.cs Outdated Show resolved Hide resolved
Flow.Launcher.Core/Plugin/PluginManager.cs Show resolved Hide resolved
Flow.Launcher.Core/Plugin/PluginManager.cs Show resolved Hide resolved
Flow.Launcher.Core/Plugin/PluginManager.cs Show resolved Hide resolved
Flow.Launcher.Core/Plugin/PluginManager.cs Show resolved Hide resolved
@jjw24
Copy link
Member

jjw24 commented Jun 16, 2024

Actionable comments posted: 7

None applicable.

@jjw24 jjw24 force-pushed the quicklook branch 2 times, most recently from a0a8ec9 to bf15591 Compare June 16, 2024 02:54
@jjw24 jjw24 enabled auto-merge June 16, 2024 03:01
@jjw24 jjw24 disabled auto-merge June 16, 2024 03:01
@jjw24 jjw24 changed the title Add QuickLook support Add external preview (QuickLook) support Jun 16, 2024
@jjw24 jjw24 enabled auto-merge June 16, 2024 03:01
@jjw24 jjw24 merged commit ea65c8f into Flow-Launcher:dev Jun 16, 2024
4 checks passed
@VictoriousRaptor VictoriousRaptor deleted the quicklook branch June 16, 2024 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature request] Preview more files
6 participants