Skip to content

Commit 0d355bd

Browse files
committed
Draft Query Shortcut
1 parent 16e032e commit 0d355bd

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
@@ -875,6 +875,31 @@
875875
SelectedValuePath="LanguageCode" />
876876
</ItemsControl>
877877
</Border>
878+
<Border Style="{DynamicResource SettingGroupBox}">
879+
<StackPanel Margin="10" Orientation="Vertical">
880+
<TextBlock Margin="10" Text="ShortCut" />
881+
<ListView ItemsSource="{Binding ShortCuts}">
882+
<ListView.View>
883+
<GridView>
884+
<GridViewColumn Header="Key">
885+
<GridViewColumn.CellTemplate>
886+
<DataTemplate>
887+
<TextBlock Text="{Binding Key}" />
888+
</DataTemplate>
889+
</GridViewColumn.CellTemplate>
890+
</GridViewColumn>
891+
<GridViewColumn Header="Mapped Value">
892+
<GridViewColumn.CellTemplate>
893+
<DataTemplate>
894+
<TextBlock Text="{Binding Value}" />
895+
</DataTemplate>
896+
</GridViewColumn.CellTemplate>
897+
</GridViewColumn>
898+
</GridView>
899+
</ListView.View>
900+
</ListView>
901+
</StackPanel>
902+
</Border>
878903
</StackPanel>
879904
</ScrollViewer>
880905
</TabItem>

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,16 @@ private async void QueryResults()
553553
return;
554554
}
555555

556+
string query = QueryText;
557+
558+
foreach (var shortcut in _settings.ShortCuts)
559+
{
560+
if (QueryText == shortcut.Key)
561+
{
562+
query = shortcut.Value;
563+
}
564+
}
565+
556566
_updateSource?.Dispose();
557567

558568
var currentUpdateSource = new CancellationTokenSource();
@@ -569,7 +579,7 @@ private async void QueryResults()
569579
if (currentCancellationToken.IsCancellationRequested)
570580
return;
571581

572-
var query = QueryBuilder.Build(QueryText.Trim(), PluginManager.NonGlobalPlugins);
582+
var query = QueryBuilder.Build(query.Trim(), PluginManager.NonGlobalPlugins);
573583

574584
// handle the exclusiveness of plugin using action keyword
575585
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)