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 @@ -30,7 +30,7 @@
{
Title = "Google Scholar",
ActionKeyword = "sc",
Icon = "google.png",

Check warning on line 33 in Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`google` is not a recognized word. (unrecognized-spelling)
Url = "https://scholar.google.com/scholar?q={q}",
Enabled = true
},
Expand Down Expand Up @@ -70,7 +70,7 @@
{
Title = "Google Maps",
ActionKeyword = "maps",
Icon = "google_maps.png",

Check warning on line 73 in Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`google` is not a recognized word. (unrecognized-spelling)
Url = "https://maps.google.com/maps?q={q}",
Enabled = true
},
Expand All @@ -78,7 +78,7 @@
{
Title = "Google Translate",
ActionKeyword = "translate",
Icon = "google_translate.png",

Check warning on line 81 in Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`google` is not a recognized word. (unrecognized-spelling)
Url = "https://translate.google.com/#auto|en|{q}",
Enabled = true
},
Expand Down Expand Up @@ -118,7 +118,7 @@
{
Title = "Google Drive",
ActionKeyword = "drive",
Icon = "google_drive.png",

Check warning on line 121 in Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`google` is not a recognized word. (unrecognized-spelling)
Url = "https://drive.google.com/?hl=en&tab=bo#search/{q}",
Enabled = true
},
Expand Down Expand Up @@ -205,6 +205,23 @@
}
}

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 All @@ -72,7 +74,7 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>

<!-- Margin="0 6" is a workaround to set this TextBlock to vertially center -->

Check warning on line 77 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`vertially` is not a recognized word. (unrecognized-spelling)
<GridViewColumn Width="135" Header="{DynamicResource flowlauncher_plugin_websearch_action_keyword}">
<GridViewColumn.CellTemplate>
<DataTemplate>
Expand Down Expand Up @@ -106,7 +108,7 @@
</GridViewColumn.CellTemplate>
</GridViewColumn>

<!-- CheckBox is vertially center by default -->

Check warning on line 111 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

View workflow job for this annotation

GitHub Actions / Check Spelling

`vertially` is not a recognized word. (unrecognized-spelling)
<GridViewColumn Width="123" Header="{DynamicResource flowlauncher_plugin_websearch_private_mode_label}">
<GridViewColumn.CellTemplate>
<DataTemplate>
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 @@ -212,12 +212,12 @@

var items = _settings.SearchSources;
int removedIdx = items.IndexOf(droppedData);
int targetIdx = items.IndexOf(targetData);

Check warning on line 215 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Idx` is not a recognized word. (unrecognized-spelling)

if (removedIdx == targetIdx)

Check warning on line 217 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Idx` is not a recognized word. (unrecognized-spelling)

Check warning on line 217 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Idx` is not a recognized word. (unrecognized-spelling)
return;

items.Move(removedIdx, targetIdx);

Check warning on line 220 in Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs

View workflow job for this annotation

GitHub Actions / Check Spelling

`Idx` is not a recognized word. (unrecognized-spelling)
}
}

Expand All @@ -240,5 +240,15 @@
}
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