mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Implement the search functionality in PluginStore Page
This commit is contained in:
parent
65fcbbcd66
commit
a8bcda2cd3
2 changed files with 42 additions and 10 deletions
|
|
@ -878,8 +878,7 @@
|
|||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem
|
||||
KeyDown="OnPluginSettingKeydown">
|
||||
<TabItem KeyDown="OnPluginSettingKeydown">
|
||||
<TabItem.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
|
|
@ -925,10 +924,10 @@
|
|||
HorizontalAlignment="Right"
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="14"
|
||||
Text=""
|
||||
TextAlignment="Left"
|
||||
KeyDown="PluginFilterTxb_OnKeyDown"
|
||||
LostFocus="RefreshPluginListEventHandler"
|
||||
KeyDown="PluginFilterTxb_OnKeyDown">
|
||||
Text=""
|
||||
TextAlignment="Left">
|
||||
<TextBox.Style>
|
||||
<Style BasedOn="{StaticResource DefaultTextBoxStyle}" TargetType="TextBox">
|
||||
<Style.Resources>
|
||||
|
|
@ -1344,6 +1343,9 @@
|
|||
HorizontalAlignment="Right"
|
||||
DockPanel.Dock="Right"
|
||||
FontSize="14"
|
||||
Name="pluginStoreFilterTxb"
|
||||
KeyDown="PluginFilterTxb_OnKeyDown"
|
||||
LostFocus="RefreshPluginStoreEventHandler"
|
||||
Text=""
|
||||
TextAlignment="Left">
|
||||
<TextBox.Style>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,10 @@ namespace Flow.Launcher
|
|||
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
|
||||
|
||||
pluginListView = (CollectionView)CollectionViewSource.GetDefaultView(pluginList.ItemsSource);
|
||||
pluginListView.Filter = PluginFilter;
|
||||
pluginListView.Filter = PluginListFilter;
|
||||
|
||||
pluginStoreView = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource);
|
||||
pluginStoreView.Filter = PluginStoreFilter;
|
||||
}
|
||||
|
||||
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
|
||||
|
|
@ -381,8 +384,9 @@ namespace Flow.Launcher
|
|||
}
|
||||
|
||||
private CollectionView pluginListView;
|
||||
private CollectionView pluginStoreView;
|
||||
|
||||
private bool PluginFilter(object item)
|
||||
private bool PluginListFilter(object item)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pluginFilterTxb.Text))
|
||||
return true;
|
||||
|
|
@ -392,22 +396,48 @@ namespace Flow.Launcher
|
|||
}
|
||||
return false;
|
||||
}
|
||||
private bool PluginStoreFilter(object item)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pluginStoreFilterTxb.Text))
|
||||
return true;
|
||||
if (item is UserPlugin model)
|
||||
{
|
||||
return StringMatcher.FuzzySearch(pluginStoreFilterTxb.Text, model.Name).IsSearchPrecisionScoreMet();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private string lastSearch = "";
|
||||
private string lastPluginListSearch = "";
|
||||
private string lastPluginStoreSearch = "";
|
||||
|
||||
private void RefreshPluginListEventHandler(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (pluginFilterTxb.Text != lastSearch)
|
||||
if (pluginFilterTxb.Text != lastPluginListSearch)
|
||||
{
|
||||
lastSearch = pluginFilterTxb.Text;
|
||||
lastPluginListSearch = pluginFilterTxb.Text;
|
||||
pluginListView.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshPluginStoreEventHandler(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (pluginStoreFilterTxb.Text != lastPluginStoreSearch)
|
||||
{
|
||||
lastPluginStoreSearch = pluginStoreFilterTxb.Text;
|
||||
pluginStoreView.Refresh();
|
||||
}
|
||||
}
|
||||
private void PluginFilterTxb_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
RefreshPluginListEventHandler(sender, e);
|
||||
}
|
||||
|
||||
private void PluginStoreFilterTxb_OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter)
|
||||
RefreshPluginListEventHandler(sender, e);
|
||||
}
|
||||
private void OnPluginSettingKeydown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.F)
|
||||
|
|
|
|||
Loading…
Reference in a new issue