Skip to content
34 changes: 34 additions & 0 deletions Flow.Launcher.Plugin/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class Result

private string _icoPath;

private string _QuickLookPath;

/// <summary>
/// The title of the result. This is always required.
/// </summary>
Expand Down Expand Up @@ -57,6 +59,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 null;
}

}
set
{
_QuickLookPath = value;
}
}

public delegate ImageSource IconDelegate();

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ private void OnKeyDown(object sender, KeyEventArgs e)
e.Handled = true;
}
break;
case Key.F1:
_viewModel.OpenQuickLook.Execute(null);
e.Handled = true;
break;
case Key.Back:
var specialKeyState = GlobalHotkey.CheckModifiers();
if (specialKeyState.CtrlPressed)
Expand Down
44 changes: 42 additions & 2 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
using Microsoft.VisualStudio.Threading;
using System.Threading.Channels;
using ISavable = Flow.Launcher.Plugin.ISavable;
using System.IO;
using System.Security.Principal;
using System.IO.Pipes;

namespace Flow.Launcher.ViewModel
{
Expand Down Expand Up @@ -177,14 +180,50 @@ private void InitializeKeyCommands()
}
});

SelectNextItemCommand = new RelayCommand(_ => { 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(); });



OpenQuickLook = new RelayCommand(command =>
{
var results = SelectedResults;
var result = results.SelectedItem?.Result;
string PipeName = "QuickLook.App.Pipe." + WindowsIdentity.GetCurrent().User?.Value;
if (command == null)
{
command = "Toggle";
}
try
{
using (var client = new NamedPipeClientStream(".", PipeName, PipeDirection.Out))
{
client.Connect();

using (var writer = new StreamWriter(client))
{
writer.WriteLine($"QuickLook.App.PipeMessages.{command}|{result.QuickLookPath}");
writer.Flush();
}
}
}
catch (Exception ex)
{
Log.Exception("Test", "fail to convert text for suggestion box", ex);
}
});

SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());

StartHelpCommand = new RelayCommand(_ =>
Expand Down Expand Up @@ -423,6 +462,7 @@ 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 AutocompleteQueryCommand { get; set; }

public string OpenResultCommandModifiers { get; private set; }
Expand Down