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
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
71376b8
Add FilePath property for PreviewInfo
VictoriousRaptor Apr 21, 2023
96f5231
Add FilePath for Explorer results preview
VictoriousRaptor Apr 21, 2023
0c4f50a
Default values for preview info
VictoriousRaptor Apr 21, 2023
1cedb6e
Add file path in preview
VictoriousRaptor Apr 21, 2023
f460913
Move QuickLook support to QuickLookHelper
VictoriousRaptor Apr 22, 2023
0b6f737
Add open/close QuickLook function
VictoriousRaptor Apr 22, 2023
ab20dcc
Reorganize preview code
VictoriousRaptor Apr 22, 2023
98991fe
Implement open QuickLook feature
VictoriousRaptor Apr 22, 2023
99b5197
Fix case when switching file
VictoriousRaptor Apr 22, 2023
1e1f29b
Add UI to toggle QuickLook usage
VictoriousRaptor Apr 22, 2023
afa8a34
Tweak Win32 preview path
VictoriousRaptor Apr 22, 2023
a1600fa
Implement preview switching logic
VictoriousRaptor Apr 22, 2023
cf10a4a
Rename method for clarity
VictoriousRaptor Apr 22, 2023
10d1410
Reduce unnecessary image load
VictoriousRaptor Apr 22, 2023
ba8bb3a
Fix switching preview logic
VictoriousRaptor Apr 22, 2023
098e90b
Hide external preview when hiding flow
VictoriousRaptor Apr 22, 2023
26ff98e
comment
VictoriousRaptor Apr 22, 2023
9061da9
Formatting
VictoriousRaptor Apr 23, 2023
441d4cb
Configure await for QuickLook calls
VictoriousRaptor Apr 23, 2023
45a42a5
Log exception when QL timeout
VictoriousRaptor Apr 23, 2023
cda587f
Show toast when QL unavailable
VictoriousRaptor Apr 23, 2023
2ed33a2
Refactor QuickLook toggle and update logic
VictoriousRaptor May 13, 2023
64afeed
Rename variable
VictoriousRaptor May 13, 2023
d266e9e
Simplify QuickLook logic
VictoriousRaptor May 20, 2023
ff7457d
Keep FL open when focus lost if QL open
VictoriousRaptor May 20, 2023
cb33756
Remove QL support for programs
VictoriousRaptor May 20, 2023
abfbef4
update
VictoriousRaptor May 20, 2023
c705b01
Change glyph
VictoriousRaptor May 22, 2023
7033bce
Add minimum gap time between fail toasts
VictoriousRaptor May 22, 2023
2bb398d
Add sendFailToast arg
VictoriousRaptor Jul 11, 2023
1eae693
Merge branch 'dev' into quicklook
VictoriousRaptor Jul 11, 2023
e248fcb
Fix build error introduced in 1eae69304f3f961b70fe224a58d870d85bcb08ad
VictoriousRaptor Jul 11, 2023
8da88bd
Hide fail toast for closing
VictoriousRaptor Aug 5, 2023
c36cea7
Merge branch 'dev' into quicklook
VictoriousRaptor Aug 27, 2023
29c1503
Merge branch 'dev' into quicklook
VictoriousRaptor Oct 15, 2023
666211d
add plugin support for external preview
jjw24 May 28, 2024
8da1313
update external preview methods to use the external preview interface
jjw24 May 28, 2024
587536f
updated PreviewVisible logic to base on ResultAreaColumn size
jjw24 May 28, 2024
53e4bbb
updated internal and external preview's show and hide logic
jjw24 May 28, 2024
b345944
Merge branch 'external_preview_plugin_support' into quicklook
jjw24 May 28, 2024
70e530b
add QuickLook plugin for testing
jjw24 May 29, 2024
493a30e
remove QuickLook related code from flow
jjw24 May 29, 2024
f902eae
Merge remote-tracking branch 'origin/dev' into quicklook
jjw24 May 29, 2024
9e39e48
minor clean up and update
jjw24 May 30, 2024
f4f519b
minor clean up
jjw24 May 31, 2024
5ec474c
Merge branch 'dev' into quicklook
VictoriousRaptor Jun 1, 2024
2e47da4
allow internal preview when external not available
jjw24 Jun 6, 2024
e6f0f28
Don't show external preview when always preview enabled
VictoriousRaptor Jun 9, 2024
4dbecb1
allow preview plugin to override the AlwaysPreview setting
jjw24 Jun 12, 2024
03686dd
Merge remote-tracking branch 'origin/dev' into quicklook
jjw24 Jun 12, 2024
0c0806e
Merge branch 'dev' into quicklook
jjw24 Jun 15, 2024
25963ea
Merge branch 'dev' into quicklook
jjw24 Jun 16, 2024
7f31fef
remove QuickLook plugin test project
jjw24 Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Português
Português (Brasil)
Italiano
Slovenský
quicklook
Tiếng Việt
Droplex
Preinstalled
Expand Down
44 changes: 43 additions & 1 deletion Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.ExternalPlugins;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -90,6 +90,48 @@ public static async Task ReloadDataAsync()
}).ToArray());
}

public static async Task OpenExternalPreviewAsync(string path, bool sendFailToast = true)
{
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
{
IAsyncExternalPreview p => p.OpenPreviewAsync(path, sendFailToast),
_ => Task.CompletedTask,
}).ToArray());
}

jjw24 marked this conversation as resolved.
Show resolved Hide resolved
public static async Task CloseExternalPreviewAsync()
{
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
{
IAsyncExternalPreview p => p.ClosePreviewAsync(),
_ => Task.CompletedTask,
}).ToArray());
}

jjw24 marked this conversation as resolved.
Show resolved Hide resolved
public static async Task SwitchExternalPreviewAsync(string path, bool sendFailToast = true)
{
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
{
IAsyncExternalPreview p => p.SwitchPreviewAsync(path, sendFailToast),
_ => Task.CompletedTask,
}).ToArray());
}

jjw24 marked this conversation as resolved.
Show resolved Hide resolved
public static bool UseExternalPreview()
{
return GetPluginsForInterface<IAsyncExternalPreview>().Any(x => !x.Metadata.Disabled);
}

public static bool AllowAlwaysPreview()
{
var plugin = GetPluginsForInterface<IAsyncExternalPreview>().FirstOrDefault(x => !x.Metadata.Disabled);

if (plugin is null)
return false;

return ((IAsyncExternalPreview)plugin.Plugin).AllowAlwaysPreview();
}

jjw24 marked this conversation as resolved.
Show resolved Hide resolved
static PluginManager()
{
// validate user directory
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ public CustomBrowserViewModel CustomBrowser
/// when false Alphabet static service will always return empty results
/// </summary>
public bool ShouldUsePinyin { get; set; } = false;

public bool AlwaysPreview { get; set; } = false;

public bool AlwaysStartEn { get; set; } = false;

private SearchPrecisionScore _querySearchPrecision = SearchPrecisionScore.Regular;
Expand Down
40 changes: 40 additions & 0 deletions Flow.Launcher.Plugin/Interfaces/IAsyncExternalPreview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Threading.Tasks;

namespace Flow.Launcher.Plugin
{
/// <summary>
/// This interface is for plugins that wish to provide file preview (external preview)
/// via a third party app instead of the default preview.
/// </summary>
public interface IAsyncExternalPreview : IFeatures
{
/// <summary>
/// Method for opening/showing the preview.
/// </summary>
/// <param name="path">The file path to open the preview for</param>
/// <param name="sendFailToast">Whether to send a toast message notification on failure for the user</param>
public Task OpenPreviewAsync(string path, bool sendFailToast = true);

/// <summary>
/// Method for closing/hiding the preview.
/// </summary>
public Task ClosePreviewAsync();

/// <summary>
/// Method for switching the preview to the next file result.
/// This requires the external preview be already open/showing
/// </summary>
/// <param name="path">The file path to switch the preview for</param>
/// <param name="sendFailToast">Whether to send a toast message notification on failure for the user</param>
public Task SwitchPreviewAsync(string path, bool sendFailToast = true);

/// <summary>
/// Allows the preview plugin to override the AlwaysPreview setting. Typically useful if plugin's preview does not
/// fully work well with being shown together when the query window appears with results.
/// When AlwaysPreview setting is on and this is set to false, the preview will not be shown when query
/// window appears with results, instead the internal preview will be shown.
/// </summary>
/// <returns></returns>
public bool AllowAlwaysPreview();
}
}
14 changes: 10 additions & 4 deletions Flow.Launcher.Plugin/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,30 @@ public record PreviewInfo
/// <summary>
/// Full image used for preview panel
/// </summary>
public string PreviewImagePath { get; set; }
public string PreviewImagePath { get; set; } = null;

/// <summary>
/// Determines if the preview image should occupy the full width of the preview panel.
/// </summary>
public bool IsMedia { get; set; }
public bool IsMedia { get; set; } = false;

/// <summary>
/// Result description text that is shown at the bottom of the preview panel.
/// </summary>
/// <remarks>
/// When a value is not set, the <see cref="SubTitle"/> will be used.
/// </remarks>
public string Description { get; set; }
public string Description { get; set; } = null;

/// <summary>
/// Delegate to get the preview panel's image
/// </summary>
public IconDelegate PreviewDelegate { get; set; }
public IconDelegate PreviewDelegate { get; set; } = null;

/// <summary>
/// File path of the result. For third-party programs providing external preview.
/// </summary>
public string FilePath { get; set; } = null;

/// <summary>
/// Default instance of <see cref="PreviewInfo"/>
Expand All @@ -299,6 +304,7 @@ public record PreviewInfo
Description = null,
IsMedia = false,
PreviewDelegate = null,
FilePath = null,
};
}
}
Expand Down
55 changes: 35 additions & 20 deletions Flow.Launcher.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher", "Flow.Launcher\Flow.Launcher.csproj", "{DB90F671-D861-46BB-93A3-F1304F5BA1C5}"
ProjectSection(ProjectDependencies) = postProject
{0B9DE348-9361-4940-ADB6-F5953BFFCCEC} = {0B9DE348-9361-4940-ADB6-F5953BFFCCEC}
{403B57F2-1856-4FC7-8A24-36AB346B763E} = {403B57F2-1856-4FC7-8A24-36AB346B763E}
{4792A74A-0CEA-4173-A8B2-30E6764C6217} = {4792A74A-0CEA-4173-A8B2-30E6764C6217}
{FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {F9C4C081-4CC3-4146-95F1-E102B4E10A5F}
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {5043CECE-E6A7-4867-9CBE-02D27D83747A}
{588088F4-3262-4F9F-9663-A05DE12534C3} = {588088F4-3262-4F9F-9663-A05DE12534C3}
{59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E}
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
{758F3331-8D38-49F9-913C-60A18A8AEF3B} = {758F3331-8D38-49F9-913C-60A18A8AEF3B}
{9B130CC5-14FB-41FF-B310-0A95B6894C37} = {9B130CC5-14FB-41FF-B310-0A95B6894C37}
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
{A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26}
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {5043CECE-E6A7-4867-9CBE-02D27D83747A}
{403B57F2-1856-4FC7-8A24-36AB346B763E} = {403B57F2-1856-4FC7-8A24-36AB346B763E}
{588088F4-3262-4F9F-9663-A05DE12534C3} = {588088F4-3262-4F9F-9663-A05DE12534C3}
{C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0}
{F9C4C081-4CC3-4146-95F1-E102B4E10A5F} = {F9C4C081-4CC3-4146-95F1-E102B4E10A5F}
{FDB3555B-58EF-4AE6-B5F1-904719637AB4} = {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
{FDED22C8-B637-42E8-824A-63B5B6E05A3A} = {FDED22C8-B637-42E8-824A-63B5B6E05A3A}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Test", "Flow.Launcher.Test\Flow.Launcher.Test.csproj", "{FF742965-9A80-41A5-B042-D6C7D3A21708}"
Expand Down Expand Up @@ -71,6 +72,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.Plugin
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Flow.Launcher.Plugin.WindowsSettings", "Plugins\Flow.Launcher.Plugin.WindowsSettings\Flow.Launcher.Plugin.WindowsSettings.csproj", "{5043CECE-E6A7-4867-9CBE-02D27D83747A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flow.Launcher.Plugin.QuickLook", "plugins\Flow.Launcher.Plugin.QuickLook\Flow.Launcher.Plugin.QuickLook.csproj", "{758F3331-8D38-49F9-913C-60A18A8AEF3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -81,8 +84,19 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.Build.0 = Release|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.ActiveCfg = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x64.Build.0 = Debug|Any CPU
{FF742965-9A80-41A5-B042-D6C7D3A21708}.Debug|x86.ActiveCfg = Debug|Any CPU
Expand All @@ -105,18 +119,6 @@ Global
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x64.Build.0 = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.ActiveCfg = Release|Any CPU
{8451ECDD-2EA4-4966-BB0A-7BBC40138E80}.Release|x86.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x64.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.ActiveCfg = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Debug|x86.Build.0 = Debug|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|Any CPU.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x64.Build.0 = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.ActiveCfg = Release|Any CPU
{DB90F671-D861-46BB-93A3-F1304F5BA1C5}.Release|x86.Build.0 = Release|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FD29318-A8AB-4D8F-AA47-60BC241B8DA3}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -286,6 +288,18 @@ Global
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x64.Build.0 = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.ActiveCfg = Release|Any CPU
{5043CECE-E6A7-4867-9CBE-02D27D83747A}.Release|x86.Build.0 = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|x64.ActiveCfg = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|x64.Build.0 = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|x86.ActiveCfg = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Debug|x86.Build.0 = Debug|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|Any CPU.Build.0 = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|x64.ActiveCfg = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|x64.Build.0 = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|x86.ActiveCfg = Release|Any CPU
{758F3331-8D38-49F9-913C-60A18A8AEF3B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -303,6 +317,7 @@ Global
{588088F4-3262-4F9F-9663-A05DE12534C3} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{4792A74A-0CEA-4173-A8B2-30E6764C6217} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{5043CECE-E6A7-4867-9CBE-02D27D83747A} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
{758F3331-8D38-49F9-913C-60A18A8AEF3B} = {3A73F5A7-0335-40D8-BF7C-F20BE5D0BA87}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F26ACB50-3F6C-4907-B0C9-1ADACC1D0DED}
Expand Down
Loading
Loading