Skip to content

Commit f36b08d

Browse files
committed
Set default searcher in General settings
1 parent 8d8672e commit f36b08d

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

Text-Grab/Controls/BottomBarSettings.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
Margin="0,0,8,0"
7575
d:Symbol="Diamond24"
7676
FontSize="24"
77-
Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
77+
Symbol="{Binding Path=SymbolIcon,
78+
Mode=TwoWay}" />
7879
</Viewbox>
7980
</DataTemplate>
8081
</GridViewColumn.CellTemplate>
@@ -173,7 +174,8 @@
173174
Margin="0,0,8,0"
174175
d:Symbol="Diamond24"
175176
FontSize="24"
176-
Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
177+
Symbol="{Binding Path=SymbolIcon,
178+
Mode=TwoWay}" />
177179
</Viewbox>
178180
</DataTemplate>
179181
</GridViewColumn.CellTemplate>

Text-Grab/Models/WebSearchUrlModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public WebSearchUrlModel DefaultSearcher
2626
}
2727
}
2828

29+
public override string ToString() => Name;
2930

3031
private List<WebSearchUrlModel> webSearchers = [];
3132

Text-Grab/Pages/GeneralSettings.xaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:local="clr-namespace:Text_Grab.Pages"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:models="clr-namespace:Text_Grab.Models"
910
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
1011
Title="GeneralSettings"
1112
d:DesignHeight="1450"
@@ -212,6 +213,24 @@
212213
Disabling may speed up results
213214
</TextBlock>
214215

216+
<TextBlock
217+
Margin="0,16,0,4"
218+
FontSize="16"
219+
Style="{StaticResource TextHeader}"
220+
Text="Web Search Options" />
221+
<ComboBox
222+
x:Name="WebSearchersComboBox"
223+
Width="300"
224+
HorizontalAlignment="Left"
225+
IsTextSearchCaseSensitive="False"
226+
SelectionChanged="WebSearchersComboBox_SelectionChanged">
227+
<ComboBox.ItemTemplate>
228+
<DataTemplate>
229+
<TextBlock Text="{Binding}" />
230+
</DataTemplate>
231+
</ComboBox.ItemTemplate>
232+
</ComboBox>
233+
215234
<TextBlock
216235
Margin="0,16,0,4"
217236
FontSize="16"

Text-Grab/Pages/GeneralSettings.xaml.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
24
using System.Diagnostics;
35
using System.IO;
46
using System.Windows;
57
using System.Windows.Controls;
68
using System.Windows.Media;
9+
using Text_Grab.Models;
710
using Text_Grab.Properties;
811
using Text_Grab.Utilities;
912
using Windows.ApplicationModel;
@@ -116,6 +119,13 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
116119
StartupOnLoginCheckBox.IsChecked = DefaultSettings.StartupOnLogin;
117120
}
118121

122+
List<WebSearchUrlModel> searcherSettings = Singleton<WebSearchUrlModel>.Instance.WebSearchers;
123+
124+
foreach (WebSearchUrlModel searcher in searcherSettings)
125+
WebSearchersComboBox.Items.Add(searcher);
126+
127+
WebSearchersComboBox.SelectedItem = Singleton<WebSearchUrlModel>.Instance.DefaultSearcher;
128+
119129
ShowToastCheckBox.IsChecked = DefaultSettings.ShowToast;
120130

121131
RunInBackgroundChkBx.IsChecked = DefaultSettings.RunInTheBackground;
@@ -356,4 +366,14 @@ private void ShowToastCheckBox_Unchecked(object sender, RoutedEventArgs e)
356366

357367
DefaultSettings.ShowToast = false;
358368
}
369+
370+
private void WebSearchersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
371+
{
372+
if (!settingsSet
373+
|| sender is not ComboBox comboBox
374+
|| comboBox.SelectedItem is not WebSearchUrlModel newDefault)
375+
return;
376+
377+
Singleton<WebSearchUrlModel>.Instance.DefaultSearcher = newDefault;
378+
}
359379
}

0 commit comments

Comments
 (0)