Flow.Launcher icon indicating copy to clipboard operation
Flow.Launcher copied to clipboard

Add QuickLook support

Open VictoriousRaptor opened this issue 1 year ago • 30 comments

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. (https://github.com/Flow-Launcher/Flow.Launcher/pull/859#issuecomment-1028867907)~~ Manually set it.
  • ~~Switching from external preview result to builtin result doesn't properly trigger builtin preview.~~

TODO

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

VictoriousRaptor avatar Apr 22 '23 09:04 VictoriousRaptor

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/4772081283/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Apr 22 '23 09:04 github-actions[bot]

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. (https://github.com/Flow-Launcher/Flow.Launcher/pull/859#issuecomment-1028867907)

This was also an issue with the original PR.

Garulf avatar Apr 22 '23 18:04 Garulf

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 avatar Apr 22 '23 22:04 jjw24

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.

Garulf avatar Apr 23 '23 00:04 Garulf

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.

jjw24 avatar Apr 23 '23 00:04 jjw24

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 avatar Apr 23 '23 03:04 VictoriousRaptor

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. (https://github.com/Flow-Launcher/Flow.Launcher/pull/859#issuecomment-1028867907)

This was also an issue with the original PR.

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

VictoriousRaptor avatar Apr 23 '23 07:04 VictoriousRaptor

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/4778538569/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Apr 23 '23 13:04 github-actions[bot]

Just did some testing and noticed that if a plugin provides an URL for Flow Launcher to download for it's icon QuickLook is unable to view this file.

Garulf avatar Apr 24 '23 05:04 Garulf

Just did some testing and noticed that if a plugin provides an URL for Flow Launcher to download for it's icon QuickLook is unable to view this file.

Currently QL only previews if plugin fills the filepath field in preview because QL can only preview local FILES (correct me if I'm wrong). And only previewing an icon doesn't provide much info so no real need to support it.

VictoriousRaptor avatar Apr 24 '23 05:04 VictoriousRaptor

I think it might be hard for a plugin to have a quicklook functionality. Because there need to be a contract to communicate about the file path for previewing. This can only be done either statically by adding an api to Result.cs or dynamically dispatch some data.

Though, I would say this might be a great extensibility. Maybe we can add a field that is dynamic for additional information? I don't know whether that works for jsonrpc though.

taooceros avatar Apr 30 '23 18:04 taooceros

I think we should release this feature for the time being and come back to addign it as an extension.

This could be a very helpful feature!

Garulf avatar May 13 '23 15:05 Garulf

works on the first run, but after trying to move the quicklook pane position, the quicklook pane has a problem (the preview doesn't open properly after that) I have to reopen the quicklook for it to work.

Aside from the window position situation I mentioned, it seems to be working fine. I thought it should be to work independently of the preview settings, but it seems to work fine as it is.

onesounds avatar May 13 '23 23:05 onesounds

works on the first run, but after trying to move the quicklook pane position, the quicklook pane has a problem (the preview doesn't open properly after that) I have to reopen the quicklook for it to work.

Trying to fix this issue.

VictoriousRaptor avatar May 14 '23 01:05 VictoriousRaptor

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/4970350768/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 14 '23 03:05 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5033148586/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 20 '23 16:05 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5033173595/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 20 '23 16:05 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5046048870/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 22 '23 12:05 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5046074806/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 22 '23 12:05 github-actions[bot]

@VictoriousRaptor is this draft or ready for review?

jjw24 avatar Jun 23 '23 08:06 jjw24

@VictoriousRaptor is this draft or ready for review?

It's ready.

VictoriousRaptor avatar Jun 24 '23 02:06 VictoriousRaptor

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5519811688/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jul 11 '23 12:07 github-actions[bot]

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view or the :scroll:action log for details.

Unrecognized words (1)

quicklook

To accept :heavy_check_mark: these unrecognized words as correct and remove the previously acknowledged and now absent words, run the following commands

... in a clone of the [email protected]:VictoriousRaptor/Flow.Launcher.git repository on the quicklook branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/Flow-Launcher/Flow.Launcher/actions/runs/5519912100/attempts/1'
Errors (1)

See the :open_file_folder: files view or the :scroll:action log for details.

:x: Errors Count
:x: check-file-path 1

See :x: Event descriptions for more information.

If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar Jul 11 '23 12:07 github-actions[bot]

Hi, @VictoriousRaptor, Is this will support text files with other extensions, like. sql and. md? Any estimation when it will be available on pre release? If I want to try using this, I need to download this branch and build solution? Thanks a lot for your great work 🙏

bluckholl avatar Oct 05 '23 05:10 bluckholl

Hi, @VictoriousRaptor, Is this will support text files with other extensions, like. sql and. md? Any estimation when it will be available on pre release? If I want to try using this, I need to download this branch and build solution? Thanks a lot for your great work 🙏

You can use the artifact build, but I think they expire now.

taooceros avatar Oct 15 '23 03:10 taooceros

Hi, @VictoriousRaptor, Is this will support text files with other extensions, like. sql and. md? Any estimation when it will be available on pre release? If I want to try using this, I need to download this branch and build solution? Thanks a lot for your great work 🙏

Sorry I didn't see this message earlier. I just updated the branch and you can download the artifact build now.

VictoriousRaptor avatar Oct 15 '23 03:10 VictoriousRaptor

what's left for this one?

taooceros avatar Mar 12 '24 04:03 taooceros

This is good to demonstrate it can work, but I am not fond of having Quicklook specific code in the codebase for several reasons but main one is this doesn't extend/enable flow to be more capable.

I would still say use this PR https://github.com/Flow-Launcher/Flow.Launcher/pull/1013 to allow plugins to capture keyboard shortcuts so they can do more, and move this Quicklook specific code into its own plugin.

That makes sense. Though before we can capture the keystroke and have a relatively sophisticated model for registering hook for plugins, I think it's ok to temporarily make this inside the core?

taooceros avatar Mar 14 '24 14:03 taooceros

That makes sense. Though before we can capture the keystroke and have a relatively sophisticated model for registering hook for plugins, I think it's ok to temporarily make this inside the core?

Not that complicated, it's using the same model as what we currently have.

My main concern is to release this then having to take it away and have users install a plugin instead.

jjw24 avatar Mar 28 '24 03:03 jjw24

Is this done? I haven't tested it. If it works, let's just include it. In my opinion, this functionality does not need to be separated into a plugin. (most programs that support quicklook do. include fluent search.) Just include it as default code. I don't think it's complicated enough to be a plugin, and it don't requires any configuration. Of course, since we're using all the default features as plugins, it would make sense to go with plugins, but it's not required. We should not delay features that work. Unless raptor makes it a plugin again, or someone else does, it's probably better to just merge this PR. Better to work on separating it into another PR later.

onesounds avatar May 22 '24 19:05 onesounds