diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index 1072c2e02..d36a49538 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -81,8 +81,6 @@ Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese. Always Preview Always open preview panel when Flow activates. Press {0} to toggle preview. - Use QuickLook - Use QuickLook to preview file results. Shadow effect is not allowed while current theme has blur effect enabled @@ -318,8 +316,6 @@ Please wait... - Failed to launch QuickLook - Please check if QuickLook is running. Checking for new update diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index e98a6cfc8..1e886c022 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -859,24 +859,6 @@ - - - - - - - - -  - - - - diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs deleted file mode 100644 index f3f25122f..000000000 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Helper/QuickLookHelper.cs +++ /dev/null @@ -1,153 +0,0 @@ -// 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 2ed32a13b..e4056131d 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, IAsyncExternalPreview + public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n { internal static PluginInitContext Context { get; set; } @@ -87,27 +87,6 @@ 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/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml index 283e1d5ec..d6a760f27 100644 --- a/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.QuickLook/Languages/en.xaml @@ -4,8 +4,8 @@ xmlns:system="clr-namespace:System;assembly=mscorlib"> - Explorer - Find and manage files and folders via Windows Search or Everything + QuickLook + Use QuickLook to preview files Failed to launch QuickLook