Skip to content

Commit 4340c08

Browse files
committed
Draft Query Shortcut
1 parent 47c4023 commit 4340c08

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public bool HideNotifyIcon
205205

206206
// This needs to be loaded last by staying at the bottom
207207
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
208+
internal List<ShortCutModel> ShortCuts { get; set; } = new List<ShortCutModel>();
208209
}
209210

210211
public enum LastQueryMode
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Flow.Launcher.Infrastructure.UserSettings
8+
{
9+
public record ShortCutModel(string Key, string Value)
10+
{
11+
}
12+
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,31 @@
873873
SelectedValuePath="LanguageCode" />
874874
</ItemsControl>
875875
</Border>
876+
<Border Style="{DynamicResource SettingGroupBox}">
877+
<StackPanel Margin="10" Orientation="Vertical">
878+
<TextBlock Margin="10" Text="ShortCut" />
879+
<ListView ItemsSource="{Binding ShortCuts}">
880+
<ListView.View>
881+
<GridView>
882+
<GridViewColumn Header="Key">
883+
<GridViewColumn.CellTemplate>
884+
<DataTemplate>
885+
<TextBlock Text="{Binding Key}" />
886+
</DataTemplate>
887+
</GridViewColumn.CellTemplate>
888+
</GridViewColumn>
889+
<GridViewColumn Header="Mapped Value">
890+
<GridViewColumn.CellTemplate>
891+
<DataTemplate>
892+
<TextBlock Text="{Binding Value}" />
893+
</DataTemplate>
894+
</GridViewColumn.CellTemplate>
895+
</GridViewColumn>
896+
</GridView>
897+
</ListView.View>
898+
</ListView>
899+
</StackPanel>
900+
</Border>
876901
</StackPanel>
877902
</ScrollViewer>
878903
</TabItem>

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,16 @@ private async void QueryResults()
529529
return;
530530
}
531531

532+
string query = QueryText;
533+
534+
foreach (var shortcut in _settings.ShortCuts)
535+
{
536+
if (QueryText == shortcut.Key)
537+
{
538+
query = shortcut.Value;
539+
}
540+
}
541+
532542
_updateSource?.Dispose();
533543

534544
var currentUpdateSource = new CancellationTokenSource();
@@ -545,7 +555,7 @@ private async void QueryResults()
545555
if (currentCancellationToken.IsCancellationRequested)
546556
return;
547557

548-
var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins);
558+
var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins);
549559

550560
// handle the exclusiveness of plugin using action keyword
551561
RemoveOldQueryResults(query);

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ public List<string> QuerySearchPrecisionStrings
170170
public List<Language> Languages => _translater.LoadAvailableLanguages();
171171
public IEnumerable<int> MaxResultsRange => Enumerable.Range(2, 16);
172172

173+
public List<ShortCutModel> ShortCuts => Settings.ShortCuts;
174+
173175
public string TestProxy()
174176
{
175177
var proxyServer = Settings.Proxy.Server;

0 commit comments

Comments
 (0)