Skip to content

Commit

Permalink
Set default searcher in General settings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJoeFin committed Dec 20, 2024
1 parent 8d8672e commit f36b08d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Text-Grab/Controls/BottomBarSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
Margin="0,0,8,0"
d:Symbol="Diamond24"
FontSize="24"
Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
Symbol="{Binding Path=SymbolIcon,
Mode=TwoWay}" />
</Viewbox>
</DataTemplate>
</GridViewColumn.CellTemplate>
Expand Down Expand Up @@ -173,7 +174,8 @@
Margin="0,0,8,0"
d:Symbol="Diamond24"
FontSize="24"
Symbol="{Binding Path=SymbolIcon, Mode=TwoWay}" />
Symbol="{Binding Path=SymbolIcon,
Mode=TwoWay}" />
</Viewbox>
</DataTemplate>
</GridViewColumn.CellTemplate>
Expand Down
1 change: 1 addition & 0 deletions Text-Grab/Models/WebSearchUrlModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public WebSearchUrlModel DefaultSearcher
}
}

public override string ToString() => Name;

private List<WebSearchUrlModel> webSearchers = [];

Expand Down
19 changes: 19 additions & 0 deletions Text-Grab/Pages/GeneralSettings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Text_Grab.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:Text_Grab.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
Title="GeneralSettings"
d:DesignHeight="1450"
Expand Down Expand Up @@ -212,6 +213,24 @@
Disabling may speed up results
</TextBlock>

<TextBlock
Margin="0,16,0,4"
FontSize="16"
Style="{StaticResource TextHeader}"
Text="Web Search Options" />
<ComboBox
x:Name="WebSearchersComboBox"
Width="300"
HorizontalAlignment="Left"
IsTextSearchCaseSensitive="False"
SelectionChanged="WebSearchersComboBox_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>

<TextBlock
Margin="0,16,0,4"
FontSize="16"
Expand Down
20 changes: 20 additions & 0 deletions Text-Grab/Pages/GeneralSettings.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Text_Grab.Models;
using Text_Grab.Properties;
using Text_Grab.Utilities;
using Windows.ApplicationModel;
Expand Down Expand Up @@ -116,6 +119,13 @@ private async void Page_Loaded(object sender, RoutedEventArgs e)
StartupOnLoginCheckBox.IsChecked = DefaultSettings.StartupOnLogin;
}

List<WebSearchUrlModel> searcherSettings = Singleton<WebSearchUrlModel>.Instance.WebSearchers;

foreach (WebSearchUrlModel searcher in searcherSettings)
WebSearchersComboBox.Items.Add(searcher);

WebSearchersComboBox.SelectedItem = Singleton<WebSearchUrlModel>.Instance.DefaultSearcher;

ShowToastCheckBox.IsChecked = DefaultSettings.ShowToast;

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

DefaultSettings.ShowToast = false;
}

private void WebSearchersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (!settingsSet
|| sender is not ComboBox comboBox
|| comboBox.SelectedItem is not WebSearchUrlModel newDefault)
return;

Singleton<WebSearchUrlModel>.Instance.DefaultSearcher = newDefault;
}
}

0 comments on commit f36b08d

Please sign in to comment.