diff --git a/Flow.Launcher.sln b/Flow.Launcher.sln index 13e98833a..9b376ca14 100644 --- a/Flow.Launcher.sln +++ b/Flow.Launcher.sln @@ -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} - {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} - {59BD9891-3837-438A-958D-ADC7F91F6F7E} = {59BD9891-3837-438A-958D-ADC7F91F6F7E} - {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} = {C21BFF9C-2C99-4B5F-B7C9-A5E6DDDB37B0} - {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} + {4792A74A-0CEA-4173-A8B2-30E6764C6217} = {4792A74A-0CEA-4173-A8B2-30E6764C6217} + {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} + {758F3331-8D38-49F9-913C-60A18A8AEF3B} = {758F3331-8D38-49F9-913C-60A18A8AEF3B} + {9B130CC5-14FB-41FF-B310-0A95B6894C37} = {9B130CC5-14FB-41FF-B310-0A95B6894C37} + {A3DCCBCA-ACC1-421D-B16E-210896234C26} = {A3DCCBCA-ACC1-421D-B16E-210896234C26} + {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}" @@ -70,6 +71,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 @@ -80,8 +83,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 @@ -104,18 +118,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 @@ -285,6 +287,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 @@ -302,6 +316,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} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs new file mode 100644 index 000000000..f3f25122f --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs @@ -0,0 +1,153 @@ +// Adapted from Files +// https://github.com/files-community/Files/blob/ad33c75c53382fcb9b16fa9cd66ae5399f3dff0b/src/Files.App/Helpers/QuickLookHelpers.cs +using System; +using System.IO.Pipes; +using System.IO; +using System.Security.Principal; +using System.Threading.Tasks; +using Flow.Launcher.Infrastructure.Logger; +using Flow.Launcher.Core.Resource; + +namespace Flow.Launcher.Plugin.Explorer.Helper +{ + internal static class QuickLookHelper + { + private const int TIMEOUT = 500; + private static DateTime lastNotificationTime = DateTime.MinValue; + + private static readonly string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}"; + private static readonly string pipeMessageSwitch = "QuickLook.App.PipeMessages.Switch"; + private static readonly string pipeMessageToggle = "QuickLook.App.PipeMessages.Toggle"; + private static readonly string pipeMessageClose = "QuickLook.App.PipeMessages.Close"; + private static readonly string pipeMessageInvoke = "QuickLook.App.PipeMessages.Invoke"; + + + /// + /// Toggle QuickLook + /// + /// File path to preview + /// Send toast when fails. + /// + public static async Task ToggleQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageToggle, path); + if (sendFailToast && !success) + { + //ShowQuickLookUnavailableToast(); + } + return success; + } + + public static async Task CloseQuickLookAsync() + { + bool success = await SendQuickLookPipeMsgAsync(pipeMessageClose); + return success; + } + + public static async Task OpenQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageInvoke, path); + if (sendFailToast && !success) + { + //ShowQuickLookUnavailableToast(); + } + return success; + } + + /// + /// Switch QuickLook to preview another file if it's on + /// + /// File path to preview + /// Send notification if fail + /// + public static async Task SwitchQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageSwitch, path); + if (sendFailToast && !success) + { + //ShowQuickLookUnavailableToast(); + } + return success; + } + + private static async Task SendQuickLookPipeMsgAsync(string message, string arg = "") + { + await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out); + try + { + await client.ConnectAsync(TIMEOUT); + + await using var writer = new StreamWriter(client); + await writer.WriteLineAsync($"{message}|{arg}"); + await writer.FlushAsync(); + } + catch (TimeoutException) + { + client.Close(); + Log.Error($"{nameof(QuickLookHelper)}", "QuickLook timeout"); + return false; + } + catch (Exception e) + { + Log.Exception($"{nameof(QuickLookHelper)}", "QuickLook error", e); + return false; + } + return true; + } + + public static async Task DetectQuickLookAvailabilityAsync() + { + static async Task QuickLookServerAvailable() + { + await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out); + try + { + await client.ConnectAsync(TIMEOUT); + var serverInstances = client.NumberOfServerInstances; + + await using var writer = new StreamWriter(client); + await writer.WriteLineAsync($"{pipeMessageSwitch}|"); + await writer.FlushAsync(); + + return serverInstances; + } + catch (TimeoutException e) + { + client.Close(); + Log.Exception($"{nameof(QuickLookHelper)}", "QuickLook connection timeout", e); + return 0; + } + } + + try + { + var result = await QuickLookServerAvailable(); + return result != 0; + } + catch (Exception e) + { + Log.Exception($"{nameof(QuickLookHelper)}", "QuickLook unavailable", e); + return false; + } + } + + private static void ShowQuickLookUnavailableToast() + { + if (lastNotificationTime.AddSeconds(10) < DateTime.Now) + { + //Notification.Show(InternationalizationManager.Instance.GetTranslation("QuickLookFail"), + // InternationalizationManager.Instance.GetTranslation("QuickLookFailTips")); + lastNotificationTime = DateTime.Now; + } + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs index e4056131d..2ed32a13b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs @@ -14,7 +14,7 @@ using Flow.Launcher.Plugin.Explorer.Exceptions; namespace Flow.Launcher.Plugin.Explorer { - public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n + public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n, IAsyncExternalPreview { internal static PluginInitContext Context { get; set; } @@ -87,6 +87,27 @@ namespace Flow.Launcher.Plugin.Explorer } } + public async Task TogglePreviewAsync(string path) + { + bool success = await QuickLookHelper.ToggleQuickLookAsync(path).ConfigureAwait(false); + } + public async Task ClosePreviewAsync() + { + bool success = await QuickLookHelper.CloseQuickLookAsync().ConfigureAwait(false); + } + + public async Task SwitchPreviewAsync(string path, bool sendFailToast = true) + { + // Switches preview content + // When external is off, do nothing + _ = QuickLookHelper.SwitchQuickLookAsync(path, sendFailToast).ConfigureAwait(false); + } + + public async Task OpenPreviewAsync(string path, bool sendFailToast = true) + { + bool success = await QuickLookHelper.OpenQuickLookAsync(path, sendFailToast).ConfigureAwait(false); + } + public string GetTranslatedPluginTitle() { return Context.API.GetTranslation("plugin_explorer_plugin_name"); diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/Flow.Launcher.Plugin.QuickLook.csproj b/Plugins/Flow.Launcher.Plugin.QuickLook/Flow.Launcher.Plugin.QuickLook.csproj new file mode 100644 index 000000000..b7e79f0a3 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/Flow.Launcher.Plugin.QuickLook.csproj @@ -0,0 +1,51 @@ + + + + Library + net7.0-windows + true + false + warnings + + + + + ..\..\Output\Debug\Plugins\Flow.Launcher.Plugin.QuickLook + + + + + ..\..\Output\Release\Plugins\Flow.Launcher.Plugin.QuickLook + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + PreserveNewest + Designer + MSBuild:Compile + + + + + + + + diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/Helpers/QuickLookHelper.cs b/Plugins/Flow.Launcher.Plugin.QuickLook/Helpers/QuickLookHelper.cs new file mode 100644 index 000000000..dfdf04871 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/Helpers/QuickLookHelper.cs @@ -0,0 +1,154 @@ +using System; +using System.IO.Pipes; +using System.IO; +using System.Security.Principal; +using System.Threading.Tasks; + +namespace Flow.Launcher.Plugin.QuickLook.Helpers +{ + /// + /// Adapted from Files + /// https://github.com/files-community/Files/blob/ad33c75c53382fcb9b16fa9cd66ae5399f3dff0b/src/Files.App/Helpers/QuickLookHelpers.cs + /// + internal static class QuickLookHelper + { + private static readonly IPublicAPI api = Main.Context.API; + + private const int TIMEOUT = 500; + private static DateTime lastNotificationTime = DateTime.MinValue; + + private static readonly string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}"; + private static readonly string pipeMessageSwitch = "QuickLook.App.PipeMessages.Switch"; + private static readonly string pipeMessageToggle = "QuickLook.App.PipeMessages.Toggle"; + private static readonly string pipeMessageClose = "QuickLook.App.PipeMessages.Close"; + private static readonly string pipeMessageInvoke = "QuickLook.App.PipeMessages.Invoke"; + + + /// + /// Toggle QuickLook + /// + /// File path to preview + /// Send toast when fails. + /// + public static async Task ToggleQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageToggle, path); + if (sendFailToast && !success) + { + ShowQuickLookUnavailableToast(); + } + return success; + } + + public static async Task CloseQuickLookAsync() + { + bool success = await SendQuickLookPipeMsgAsync(pipeMessageClose); + return success; + } + + public static async Task OpenQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageInvoke, path); + if (sendFailToast && !success) + { + ShowQuickLookUnavailableToast(); + } + return success; + } + + /// + /// Switch QuickLook to preview another file if it's on + /// + /// File path to preview + /// Send notification if fail + /// + public static async Task SwitchQuickLookAsync(string path, bool sendFailToast = true) + { + if (string.IsNullOrEmpty(path)) + return false; + + bool success = await SendQuickLookPipeMsgAsync(pipeMessageSwitch, path); + if (sendFailToast && !success) + { + ShowQuickLookUnavailableToast(); + } + return success; + } + + private static async Task SendQuickLookPipeMsgAsync(string message, string arg = "") + { + await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out); + try + { + await client.ConnectAsync(TIMEOUT); + + await using var writer = new StreamWriter(client); + await writer.WriteLineAsync($"{message}|{arg}"); + await writer.FlushAsync(); + } + catch (TimeoutException e) + { + client.Close(); + api.LogException($"{nameof(QuickLookHelper)}", "QuickLook timeout", e); + return false; + } + catch (Exception e) + { + api.LogException($"{nameof(QuickLookHelper)}", "QuickLook error", e); + return false; + } + return true; + } + + public static async Task DetectQuickLookAvailabilityAsync() + { + static async Task QuickLookServerAvailable() + { + await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out); + try + { + await client.ConnectAsync(TIMEOUT); + var serverInstances = client.NumberOfServerInstances; + + await using var writer = new StreamWriter(client); + await writer.WriteLineAsync($"{pipeMessageSwitch}|"); + await writer.FlushAsync(); + + return serverInstances; + } + catch (TimeoutException e) + { + client.Close(); + api.LogException($"{nameof(QuickLookHelper)}", "QuickLook connection timeout", e); + return 0; + } + } + + try + { + var result = await QuickLookServerAvailable(); + return result != 0; + } + catch (Exception e) + { + api.LogException($"{nameof(QuickLookHelper)}", "QuickLook unavailable", e); + return false; + } + } + + private static void ShowQuickLookUnavailableToast() + { + if (lastNotificationTime.AddSeconds(10) < DateTime.Now) + { + api.ShowMsgError(api.GetTranslation("quicklook_failed_to_launch"), api.GetTranslation("quicklook_fail_tips")); + lastNotificationTime = DateTime.Now; + } + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/Images/app.png b/Plugins/Flow.Launcher.Plugin.QuickLook/Images/app.png new file mode 100644 index 000000000..5a8238c03 Binary files /dev/null and b/Plugins/Flow.Launcher.Plugin.QuickLook/Images/app.png differ diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml new file mode 100644 index 000000000..283e1d5ec --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml @@ -0,0 +1,14 @@ + + + + Explorer + Find and manage files and folders via Windows Search or Everything + + + Failed to launch QuickLook + Please check if QuickLook is running. + + diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/Main.cs b/Plugins/Flow.Launcher.Plugin.QuickLook/Main.cs new file mode 100644 index 000000000..3696ca434 --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/Main.cs @@ -0,0 +1,52 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Flow.Launcher.Plugin.QuickLook.Helpers; + +namespace Flow.Launcher.Plugin.QuickLook +{ + public class Main : IAsyncPlugin, IAsyncExternalPreview, IPluginI18n + { + internal static PluginInitContext Context { get; set; } + + public Task InitAsync(PluginInitContext context) + { + Context = context; + + // prompt quicklook install if not found? + + return Task.CompletedTask; + } + + public async Task TogglePreviewAsync(string path) + { + await QuickLookHelper.ToggleQuickLookAsync(path).ConfigureAwait(false); + } + public async Task ClosePreviewAsync() + { + await QuickLookHelper.CloseQuickLookAsync().ConfigureAwait(false); + } + + public async Task SwitchPreviewAsync(string path, bool sendFailToast = true) + { + await QuickLookHelper.SwitchQuickLookAsync(path, sendFailToast).ConfigureAwait(false); + } + + public async Task OpenPreviewAsync(string path, bool sendFailToast = true) + { + await QuickLookHelper.OpenQuickLookAsync(path, sendFailToast).ConfigureAwait(false); + } + + public async Task> QueryAsync(Query query, CancellationToken token) => new List(); + + public string GetTranslatedPluginTitle() + { + return Context.API.GetTranslation("plugin_name"); + } + + public string GetTranslatedPluginDescription() + { + return Context.API.GetTranslation("plugin_description"); + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.QuickLook/plugin.json b/Plugins/Flow.Launcher.Plugin.QuickLook/plugin.json new file mode 100644 index 000000000..0a078e8be --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/plugin.json @@ -0,0 +1,12 @@ +{ + "ID": "e6a13bf1-5op9-2b96-a7fd-130b7vdt3d14", + "ActionKeywords": [ "*" ], + "Name": "QuickLook", + "Description": "Use QuickLook to preview files", + "Author": "Flow Launcher", + "Version": "1.0.0", + "Language": "csharp", + "Website": "https://github.com/Flow-Launcher/Flow.Launcher.Plugin.QuickLook", + "ExecuteFileName": "Flow.Launcher.Plugin.QuickLook.dll", + "IcoPath": "Images\\app.png" +}