diff --git a/Flow.Launcher.Plugin/Result.cs b/Flow.Launcher.Plugin/Result.cs
index 4a5eb39afc0..521351c72bf 100644
--- a/Flow.Launcher.Plugin/Result.cs
+++ b/Flow.Launcher.Plugin/Result.cs
@@ -13,6 +13,8 @@ public class Result
private string _icoPath;
+ private string _QuickLookPath;
+
///
/// The title of the result. This is always required.
///
@@ -64,6 +66,38 @@ public string IcoPath
}
}
+ public string QuickLookPath
+ {
+ get
+ {
+ if (!string.IsNullOrEmpty(_QuickLookPath))
+ {
+ return _QuickLookPath;
+ }
+ else if (File.Exists(Title) || Directory.Exists(Title))
+ {
+ return Title;
+ }
+ else if (File.Exists(SubTitle) || Directory.Exists(SubTitle))
+ {
+ return SubTitle;
+ }
+ else if (!string.IsNullOrEmpty(IcoPath))
+ {
+ return IcoPath;
+ }
+ else
+ {
+ return _QuickLookPath;
+ }
+
+ }
+ set
+ {
+ _QuickLookPath = value;
+ }
+ }
+
public delegate ImageSource IconDelegate();
///
diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml
index 714fcc53fa1..fab7add0292 100644
--- a/Flow.Launcher/MainWindow.xaml
+++ b/Flow.Launcher/MainWindow.xaml
@@ -39,7 +39,7 @@
-
+
{ SelectedResults.SelectNextResult(); });
+ SelectNextItemCommand = new RelayCommand(_ => {
+ SelectedResults.SelectNextResult();
+ OpenQuickLook.Execute("Switch");
+ });
- SelectPrevItemCommand = new RelayCommand(_ => { SelectedResults.SelectPrevResult(); });
+ SelectPrevItemCommand = new RelayCommand(_ => {
+ SelectedResults.SelectPrevResult();
+ OpenQuickLook.Execute("Switch");
+ });
SelectNextPageCommand = new RelayCommand(_ => { SelectedResults.SelectNextPage(); });
SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); });
+
+
+#pragma warning disable VSTHRD101 // Avoid unsupported async delegates
+ OpenQuickLook = new RelayCommand(async command =>
+ {
+ var results = SelectedResults;
+ var result = results.SelectedItem?.Result;
+
+ if (result is null)
+ return;
+ if (command is null)
+ {
+ command = "Toggle";
+ }
+ string pipeName = "QuickLook.App.Pipe." + WindowsIdentity.GetCurrent().User?.Value;
+
+ await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out);
+ try
+ {
+ await client.ConnectAsync(100).ConfigureAwait(false);
+ var message = $"QuickLook.App.PipeMessages.{command}|{result.QuickLookPath}\n";
+ using var buffer = MemoryPool.Shared.Rent(Encoding.UTF8.GetMaxByteCount(message.Length));
+ var count = Encoding.UTF8.GetBytes(message, buffer.Memory.Span);
+ await client.WriteAsync(buffer.Memory[..count]);
+ }
+ catch (System.TimeoutException)
+ {
+ if ((string)command == "Toggle")
+ {
+ Log.Warn("MainViewModel", "Unable to activate quicklook");
+ }
+
+ }
+
+ });
+#pragma warning restore VSTHRD101 // Avoid unsupported async delegates
+
SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());
StartHelpCommand = new RelayCommand(_ =>
@@ -425,9 +472,8 @@ private ResultsViewModel SelectedResults
public ICommand OpenSettingCommand { get; set; }
public ICommand ReloadPluginDataCommand { get; set; }
public ICommand ClearQueryCommand { get; private set; }
-
+ public ICommand OpenQuickLook { get; set; }
public ICommand CopyToClipboard { get; set; }
-
public ICommand AutocompleteQueryCommand { get; set; }
public string OpenResultCommandModifiers { get; private set; }