Flow.Launcher/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml
Nilvan Lopes 2176553b26 Add max suggestions setting for web search plugins
Introduced a MaxSuggestions property (min 1, max 10) to control the number of autocomplete suggestions shown in web search plugins. Updated the UI to allow user configuration and added localized labels for the new setting in all supported languages. Suggestions in results are now limited according to this setting.
2026-01-02 14:32:44 -03:00

190 lines
No EOL
9.1 KiB
XML

<UserControl
x:Class="Flow.Launcher.Plugin.WebSearch.SettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Flow.Launcher.Plugin.WebSearch"
d:DataContext="{d:DesignInstance vm:SettingsViewModel}"
d:DesignHeight="300"
d:DesignWidth="500"
mc:Ignorable="d">
<UserControl.Resources>
<DataTemplate x:Key="HeaderTemplateArrowUp">
<DockPanel>
<TextBlock HorizontalAlignment="Center" Text="{Binding}" />
<Path
x:Name="arrow"
Data="M 5,10 L 15,10 L 10,5 L 5,10"
Fill="gray"
StrokeThickness="1" />
</DockPanel>
</DataTemplate>
<DataTemplate x:Key="HeaderTemplateArrowDown">
<DockPanel>
<TextBlock HorizontalAlignment="Center" Text="{Binding}" />
<Path
x:Name="arrow"
Data="M 5,5 L 10,10 L 15,5 L 5,5"
Fill="gray"
StrokeThickness="1" />
</DockPanel>
</DataTemplate>
</UserControl.Resources>
<Grid Margin="{StaticResource SettingPanelMargin}">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView
x:Name="SearchSourcesListView"
Grid.Row="0"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
BorderBrush="DarkGray"
BorderThickness="1"
GridViewColumnHeader.Click="SortByColumn"
ItemsSource="{Binding Settings.SearchSources}"
MouseDoubleClick="MouseDoubleClickItem"
SelectedItem="{Binding Settings.SelectedSearchSource}"
SizeChanged="ListView_SizeChanged"
PreviewMouseLeftButtonDown="ListView_PreviewMouseLeftButtonDown"
PreviewMouseMove="ListView_PreviewMouseMove"
AllowDrop="True"
Drop="ListView_Drop"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.View>
<GridView>
<!-- Margin="0 4" is a workaround to set this TextBlock to vertially center -->
<GridViewColumn Width="45">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Image
Width="20"
Height="20"
Margin="6 4 0 4"
Source="{Binding Path=IconPath}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- Margin="0 6" is a workaround to set this TextBlock to vertially center -->
<GridViewColumn Width="135" Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="0 6" Text="{Binding ActionKeyword}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="145" Header="{DynamicResource flowlauncher_plugin_websearch_title}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="0 6" Text="{Binding Title}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="112" Header="{DynamicResource flowlauncher_plugin_websearch_enable}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="0 6">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{DynamicResource flowlauncher_plugin_websearch_false}" />
<Style.Triggers>
<DataTrigger Binding="{Binding Status, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Text" Value="{DynamicResource flowlauncher_plugin_websearch_true}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!-- CheckBox is vertially center by default -->
<GridViewColumn Width="123" Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsPrivateMode}"
IsEnabled="False" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<StackPanel
Grid.Row="1"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button
Width="100"
Margin="{StaticResource SettingPanelItemLeftMargin}"
Click="OnDeleteSearchSearchClick"
Content="{DynamicResource flowlauncher_plugin_websearch_delete}" />
<Button
Width="100"
Margin="{StaticResource SettingPanelItemLeftMargin}"
Click="OnEditSearchSourceClick"
Content="{DynamicResource flowlauncher_plugin_websearch_edit}" />
<Button
Width="100"
Margin="{StaticResource SettingPanelItemLeftMargin}"
Click="OnAddSearchSearchClick"
Content="{DynamicResource flowlauncher_plugin_websearch_add}" />
</StackPanel>
<Separator Grid.Row="2" Style="{StaticResource SettingPanelSeparatorStyle}" />
<DockPanel
Grid.Row="3"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
HorizontalAlignment="Right">
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
<Label
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_websearch_max_suggestions}" />
<TextBox
Width="40"
Height="30"
Margin="{StaticResource SettingPanelItemLeftMargin}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextAlignment="Center"
FontSize="11"
Text="{Binding Settings.MaxSuggestions, UpdateSourceTrigger=PropertyChanged}" />
<Label
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="{StaticResource SettingPanelItemLeftMargin}"
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion_provider}" />
<ComboBox
Height="30"
Margin="{StaticResource SettingPanelItemLeftMargin}"
VerticalAlignment="Center"
FontSize="11"
IsEnabled="{Binding Settings.EnableSuggestion}"
ItemsSource="{Binding Settings.Suggestions}"
SelectedItem="{Binding Settings.SelectedSuggestion}" />
<CheckBox
Name="EnableSuggestion"
Margin="{StaticResource SettingPanelItemLeftMargin}"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion}"
IsChecked="{Binding Settings.EnableSuggestion}" />
</StackPanel>
</DockPanel>
</Grid>
</UserControl>