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 QuickLook support #2082

Open
wants to merge 50 commits into
base: dev
Choose a base branch
from

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

@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.

@jjw24 jjw24 added the review in progress Indicates that a review is in progress for this PR label May 26, 2024
@jjw24 jjw24 enabled auto-merge (squash) May 26, 2024 00:28
@jjw24
Copy link
Member

jjw24 commented May 26, 2024

Can't this be detected from user settings, preview -> built-in or QuickLook

@VictoriousRaptor
Copy link
Contributor Author

Can't this be detected from user settings, preview -> built-in or QuickLook

This is the current implementation but logic to deciding to use which preview is not clear. I spent quite a lot of time on it.

I don't have time to review this PR this week so if we want to merge now it requires more detailed review from the team.

@jjw24
Copy link
Member

jjw24 commented May 29, 2024

Updated this PR with (see commits):

  • support plugin with external preview via functionality interface.
  • enable/disable external preview by toggling plugin on/off
  • updated preview visibility logic.
  • added a QuickLook plugin for testing, but will be a published standalone plugin and not merging with this PR.

@@ -622,7 +622,7 @@ private async void OnDeactivated(object sender, EventArgs e)
if (_settings.UseAnimation)
await Task.Delay(100);

if (_settings.HideWhenDeactivated)
if (_settings.HideWhenDeactivated && !_viewModel.ExternalPreviewVisible)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

why?

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 for when you click away from the mouse it doesnt hide both the search window and preview. Not sure which is user-friendlier, hide when deactivated or do not.

break;

case true
when !ExternalPreviewVisible && Settings.AlwaysPreview && CanExternalPreviewSelectedResult(out var path):
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 I enable AlwaysPreview QuickLook automatically pops whenever I type. Not usable imo.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah i know, there is the option to switch AlwaysPreview off. The real problem is QuickLook doesnt remember last position, but nothing we can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So AlwaysPreview shouldn't control external preview.

Copy link
Member

@jjw24 jjw24 Jun 3, 2024

Choose a reason for hiding this comment

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

I want to align the behaviour for both internal and external so logic is a bit more straightforward, and also not just build logic for QuickLook because in the future we may integrate with another preview tool that works well with always preview option. For now user can just switch it off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it possible to set a "always external preview" in preview plugin?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, let's not not add additional logic when there is already a button that does exactly that.

@VictoriousRaptor VictoriousRaptor modified the milestones: Future, 1.19.0 May 30, 2024
@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request review in progress Indicates that a review is in progress for this PR
Projects
Status: Wait for merge
Development

Successfully merging this pull request may close these issues.

[Feature request] Preview more files
6 participants