Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.10.2.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_search">Search</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Use Search Query Autocomplete</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Max Suggestions</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Autocomplete Data from:</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Please select a web search</system:String>
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">Are you sure you want to delete {0}?</system:String>
Expand Down
5 changes: 3 additions & 2 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -91,6 +91,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)

if (token.IsCancellationRequested)
return null;

}

return results;
Expand Down Expand Up @@ -126,7 +127,7 @@ private async Task<IEnumerable<Result>> SuggestionsAsync(string keyword, string

token.ThrowIfCancellationRequested();

var resultsFromSuggestion = suggestions?.Select(o => new Result
var resultsFromSuggestion = suggestions?.Take(_settings.MaxSuggestions).Select(o => new Result
{
Title = o,
SubTitle = subtitle,
Expand Down
17 changes: 17 additions & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ public bool EnableSuggestion
}
}

private int maxSuggestions = 1;
public int MaxSuggestions
{
get => maxSuggestions;
set
{
if (value > 0 && value <= 1000)
{
if (maxSuggestions != value)
{
maxSuggestions = value;
OnPropertyChanged();
}
}
}
}

[JsonIgnore]
public SuggestionSource[] Suggestions { get; set; } = {
new Google(),
Expand Down
58 changes: 36 additions & 22 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
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:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:vm="clr-namespace:Flow.Launcher.Plugin.WebSearch"
d:DataContext="{d:DesignInstance vm:SettingsViewModel}"
d:DesignHeight="300"
Expand Down Expand Up @@ -45,17 +47,17 @@
x:Name="SearchSourcesListView"
Grid.Row="0"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
AllowDrop="True"
BorderBrush="DarkGray"
BorderThickness="1"
Drop="ListView_Drop"
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"
SelectedItem="{Binding Settings.SelectedSearchSource}"
SizeChanged="ListView_SizeChanged"
Style="{StaticResource {x:Static GridView.GridViewStyleKey}}">
<ListView.View>
<GridView>
Expand Down Expand Up @@ -146,31 +148,43 @@

<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"
<WrapPanel Grid.Row="3" HorizontalAlignment="Stretch">
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion_provider}" />
Text="{DynamicResource flowlauncher_plugin_websearch_max_suggestions}" />
<ui:NumberBox
Width="120"
MinWidth="120"
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}"
Maximum="1000"
Minimum="1"
SmallChange="10"
SpinButtonPlacementMode="Compact"
ValidationMode="InvalidInputOverwritten"
ValueChanged="NumberBox_ValueChanged"
Value="{Binding Settings.MaxSuggestions, Mode=OneWay}" />
</StackPanel>
<CheckBox
Name="EnableSuggestion"
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}"
VerticalAlignment="Center"
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion}"
IsChecked="{Binding Settings.EnableSuggestion}" />
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="{StaticResource SettingPanelItemRightTopBottomMargin}"
VerticalAlignment="Center"
Text="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion_provider}" />
<ComboBox
Height="30"
Margin="{StaticResource SettingPanelItemLeftMargin}"
Margin="{StaticResource SettingPanelItemTopBottomMargin}"
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>
</WrapPanel>
</Grid>
</UserControl>
10 changes: 10 additions & 0 deletions Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,15 @@ private static T FindAncestor<T>(DependencyObject current) where T : DependencyO
}
return null;
}

// This is used for NumberBox to force its value to be 1 when the user clears the value
private void NumberBox_ValueChanged(iNKORE.UI.WPF.Modern.Controls.NumberBox sender, iNKORE.UI.WPF.Modern.Controls.NumberBoxValueChangedEventArgs args)
{
if (double.IsNaN(args.NewValue))
{
sender.Value = 1;
_settings.MaxSuggestions = (int)sender.Value;
}
}
}
}
Loading