Skip to content

Commit 2176553

Browse files
committed
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.
1 parent 83883c4 commit 2176553

8 files changed

Lines changed: 36 additions & 2 deletions

File tree

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/de.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
2020
<system:String x:Key="flowlauncher_plugin_websearch_search">Suche</system:String>
2121
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Autovervollständigung von Suchanfragen verwenden</system:String>
22+
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Max. Vorschläge:</system:String>
2223
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Autovervollständigung der Daten aus:</system:String>
2324
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Bitte wählen Sie eine Websuche aus</system:String>
2425
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">Sind Sie sicher, dass Sie {0} löschen wollen?</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
2222
<system:String x:Key="flowlauncher_plugin_websearch_search">Search</system:String>
2323
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Use Search Query Autocomplete</system:String>
24+
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Max Suggestions:</system:String>
2425
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Autocomplete Data from:</system:String>
2526
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Please select a web search</system:String>
2627
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">Are you sure you want to delete {0}?</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/es.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
2020
<system:String x:Key="flowlauncher_plugin_websearch_search">Busca en</system:String>
2121
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Usar autocompletado en consultas de búsqueda</system:String>
22+
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Max sugerencias:</system:String>
2223
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Autocompletar datos desde:</system:String>
2324
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Por favor, seleccione una búsqueda web</system:String>
2425
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">¿Está seguro de que desea eliminar {0}?</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/fr.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
2020
<system:String x:Key="flowlauncher_plugin_websearch_search">Rechercher sur</system:String>
2121
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Utiliser la fonction d'auto-complétion des requêtes de recherche</system:String>
22+
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Max suggestions :</system:String>
2223
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Saisir automatiquement les données à partir de :</system:String>
2324
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Veuillez sélectionner une recherche web</system:String>
2425
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">Êtes-vous sûr de vouloir supprimer {0} ?</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Languages/pt-br.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<system:String x:Key="flowlauncher_plugin_websearch_url">URL</system:String>
2020
<system:String x:Key="flowlauncher_plugin_websearch_search">Search</system:String>
2121
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion">Use Search Query Autocomplete</system:String>
22+
<system:String x:Key="flowlauncher_plugin_websearch_max_suggestions">Qtd Sugestões:</system:String>
2223
<system:String x:Key="flowlauncher_plugin_websearch_enable_suggestion_provider">Autocomplete Data from:</system:String>
2324
<system:String x:Key="flowlauncher_plugin_websearch_pls_select_web_search">Please select a web search</system:String>
2425
<system:String x:Key="flowlauncher_plugin_websearch_delete_warning">Are you sure you want to delete {0}?</system:String>

Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -91,6 +91,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
9191

9292
if (token.IsCancellationRequested)
9393
return null;
94+
9495
}
9596

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

127128
token.ThrowIfCancellationRequested();
128129

129-
var resultsFromSuggestion = suggestions?.Select(o => new Result
130+
var resultsFromSuggestion = suggestions?.Take(_settings.MaxSuggestions).Select(o => new Result
130131
{
131132
Title = o,
132133
SubTitle = subtitle,

Plugins/Flow.Launcher.Plugin.WebSearch/Settings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ public bool EnableSuggestion
205205
}
206206
}
207207

208+
private int maxSuggestions = 1;
209+
public int MaxSuggestions
210+
{
211+
get => maxSuggestions;
212+
set
213+
{
214+
if (maxSuggestions != value)
215+
{
216+
maxSuggestions = Math.Max(1, Math.Min(value, 10));
217+
OnPropertyChanged(nameof(MaxSuggestions));
218+
}
219+
}
220+
}
221+
208222
[JsonIgnore]
209223
public SuggestionSource[] Suggestions { get; set; } = {
210224
new Google(),

Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@
154154
<Label
155155
HorizontalAlignment="Right"
156156
VerticalAlignment="Center"
157+
Content="{DynamicResource flowlauncher_plugin_websearch_max_suggestions}" />
158+
<TextBox
159+
Width="40"
160+
Height="30"
161+
Margin="{StaticResource SettingPanelItemLeftMargin}"
162+
VerticalAlignment="Center"
163+
HorizontalAlignment="Center"
164+
TextAlignment="Center"
165+
FontSize="11"
166+
Text="{Binding Settings.MaxSuggestions, UpdateSourceTrigger=PropertyChanged}" />
167+
<Label
168+
HorizontalAlignment="Right"
169+
VerticalAlignment="Center"
170+
Margin="{StaticResource SettingPanelItemLeftMargin}"
157171
Content="{DynamicResource flowlauncher_plugin_websearch_enable_suggestion_provider}" />
158172
<ComboBox
159173
Height="30"

0 commit comments

Comments
 (0)