mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
#129 Make web search suggestion optional and add baidu suggeestion source.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Wox.Infrastructure.Storage.UserSettings;
|
||||
|
||||
@@ -19,6 +21,24 @@ namespace Wox.Plugin.SystemPlugins
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
webSearchView.ItemsSource = UserSettingStorage.Instance.WebSearches;
|
||||
cbEnableWebSearchSuggestion.IsChecked = UserSettingStorage.Instance.EnableWebSearchSuggestion;
|
||||
comboBoxSuggestionSource.Visibility = UserSettingStorage.Instance.EnableWebSearchSuggestion
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
|
||||
List<ComboBoxItem> items = new List<ComboBoxItem>()
|
||||
{
|
||||
new ComboBoxItem() {Content = "Google"},
|
||||
new ComboBoxItem() {Content = "Bing" },
|
||||
new ComboBoxItem() {Content = "Baidu"},
|
||||
};
|
||||
ComboBoxItem selected = items.FirstOrDefault(o => o.Content.ToString() == UserSettingStorage.Instance.WebSearchSuggestionSource);
|
||||
if (selected == null)
|
||||
{
|
||||
selected = items[0];
|
||||
}
|
||||
comboBoxSuggestionSource.ItemsSource = items;
|
||||
comboBoxSuggestionSource.SelectedItem = selected;
|
||||
}
|
||||
|
||||
public void ReloadWebSearchView()
|
||||
@@ -66,5 +86,24 @@ namespace Wox.Plugin.SystemPlugins
|
||||
}
|
||||
}
|
||||
|
||||
private void CbEnableWebSearchSuggestion_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
comboBoxSuggestionSource.Visibility = Visibility.Visible;
|
||||
UserSettingStorage.Instance.EnableWebSearchSuggestion = true;
|
||||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
|
||||
private void CbEnableWebSearchSuggestion_OnUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
comboBoxSuggestionSource.Visibility = Visibility.Collapsed;
|
||||
UserSettingStorage.Instance.EnableWebSearchSuggestion = false;
|
||||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
|
||||
private void ComboBoxSuggestionSource_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
UserSettingStorage.Instance.WebSearchSuggestionSource = ((ComboBoxItem)e.AddedItems[0]).Content.ToString();
|
||||
UserSettingStorage.Instance.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user