mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
add IPathSelected interface for query window hotkey path capture
This commit is contained in:
parent
11f1f402b2
commit
7faa4bb0f4
5 changed files with 61 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
@ -179,6 +179,15 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task PublishPathSelectedFromResult(string selectedPath, string hotkey)
|
||||||
|
{
|
||||||
|
await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch
|
||||||
|
{
|
||||||
|
IPathSelected p => p.PathSelected(selectedPath, hotkey),
|
||||||
|
_ => Task.CompletedTask,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<List<Result>> QueryForPluginAsync(PluginPair pair, Query query, CancellationToken token)
|
public static async Task<List<Result>> QueryForPluginAsync(PluginPair pair, Query query, CancellationToken token)
|
||||||
{
|
{
|
||||||
var results = new List<Result>();
|
var results = new List<Result>();
|
||||||
|
|
|
||||||
13
Flow.Launcher.Plugin/Interfaces/IPathSelected.cs
Normal file
13
Flow.Launcher.Plugin/Interfaces/IPathSelected.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Flow.Launcher.Plugin
|
||||||
|
{
|
||||||
|
public interface IPathSelected : IFeatures
|
||||||
|
{
|
||||||
|
Task PathSelected(string path, string hotkey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Window.InputBindings>
|
<Window.InputBindings>
|
||||||
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
|
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
|
||||||
<KeyBinding Key="F1" Command="{Binding StartHelpCommand}" />
|
<KeyBinding Key="F1" Command="{Binding F1SelectedCommand}" />
|
||||||
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
|
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
|
||||||
<KeyBinding Key="Tab" Command="{Binding AutocompleteQueryCommand}" />
|
<KeyBinding Key="Tab" Command="{Binding AutocompleteQueryCommand}" />
|
||||||
<KeyBinding
|
<KeyBinding
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,33 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); });
|
SelectPrevPageCommand = new RelayCommand(_ => { SelectedResults.SelectPrevPage(); });
|
||||||
|
|
||||||
|
F1SelectedCommand = new RelayCommand(_ =>
|
||||||
|
{
|
||||||
|
var results = SelectedResults;
|
||||||
|
var result = results.SelectedItem?.Result;
|
||||||
|
|
||||||
|
if (result is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var selectedPath = string.Empty;
|
||||||
|
|
||||||
|
if (File.Exists(result.Title) || Directory.Exists(result.Title))
|
||||||
|
{
|
||||||
|
selectedPath = result.Title;
|
||||||
|
}
|
||||||
|
else if (File.Exists(result.SubTitle) || Directory.Exists(result.SubTitle))
|
||||||
|
{
|
||||||
|
selectedPath = result.SubTitle;
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(result.IcoPath))
|
||||||
|
{
|
||||||
|
selectedPath = result.IcoPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManager.PublishPathSelectedFromResult(selectedPath, "f1");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());
|
SelectFirstResultCommand = new RelayCommand(_ => SelectedResults.SelectFirstResult());
|
||||||
|
|
||||||
StartHelpCommand = new RelayCommand(_ =>
|
StartHelpCommand = new RelayCommand(_ =>
|
||||||
|
|
@ -430,6 +457,8 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
public ICommand AutocompleteQueryCommand { get; set; }
|
public ICommand AutocompleteQueryCommand { get; set; }
|
||||||
|
|
||||||
|
public ICommand F1SelectedCommand { get; set; }
|
||||||
|
|
||||||
public string OpenResultCommandModifiers { get; private set; }
|
public string OpenResultCommandModifiers { get; private set; }
|
||||||
|
|
||||||
public string Image => Constant.QueryTextBoxIconImagePath;
|
public string Image => Constant.QueryTextBoxIconImagePath;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using System.Windows.Controls;
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer
|
namespace Flow.Launcher.Plugin.Explorer
|
||||||
{
|
{
|
||||||
public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n
|
public class Main : ISettingProvider, IAsyncPlugin, IContextMenu, IPluginI18n, IPathSelected
|
||||||
{
|
{
|
||||||
internal PluginInitContext Context { get; set; }
|
internal PluginInitContext Context { get; set; }
|
||||||
|
|
||||||
|
|
@ -28,6 +28,13 @@ namespace Flow.Launcher.Plugin.Explorer
|
||||||
return new ExplorerSettings(viewModel);
|
return new ExplorerSettings(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task PathSelected(string filePath, string hotkey)
|
||||||
|
{
|
||||||
|
//checked the hotkey if is ctrl+c, then
|
||||||
|
//copy file to clipboard.
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
public Task InitAsync(PluginInitContext context)
|
public Task InitAsync(PluginInitContext context)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue