Draft Query Shortcut

This commit is contained in:
Hongtao Zhang 2021-12-23 16:13:49 -06:00
parent 16e032ea55
commit 0d355bdef8
5 changed files with 51 additions and 1 deletions

View file

@ -205,6 +205,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
// This needs to be loaded last by staying at the bottom
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
internal List<ShortCutModel> ShortCuts { get; set; } = new List<ShortCutModel>();
}
public enum LastQueryMode

View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Flow.Launcher.Infrastructure.UserSettings
{
public record ShortCutModel(string Key, string Value)
{
}
}

View file

@ -875,6 +875,31 @@
SelectedValuePath="LanguageCode" />
</ItemsControl>
</Border>
<Border Style="{DynamicResource SettingGroupBox}">
<StackPanel Margin="10" Orientation="Vertical">
<TextBlock Margin="10" Text="ShortCut" />
<ListView ItemsSource="{Binding ShortCuts}">
<ListView.View>
<GridView>
<GridViewColumn Header="Key">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Mapped Value">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
</TabItem>

View file

@ -553,6 +553,16 @@ namespace Flow.Launcher.ViewModel
return;
}
string query = QueryText;
foreach (var shortcut in _settings.ShortCuts)
{
if (QueryText == shortcut.Key)
{
query = shortcut.Value;
}
}
_updateSource?.Dispose();
var currentUpdateSource = new CancellationTokenSource();
@ -569,7 +579,7 @@ namespace Flow.Launcher.ViewModel
if (currentCancellationToken.IsCancellationRequested)
return;
var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins);
var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins);
// handle the exclusiveness of plugin using action keyword
RemoveOldQueryResults(query);

View file

@ -170,6 +170,8 @@ namespace Flow.Launcher.ViewModel
public List<Language> Languages => _translater.LoadAvailableLanguages();
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
public List<ShortCutModel> ShortCuts => Settings.ShortCuts;
public string TestProxy()
{
var proxyServer = Settings.Proxy.Server;