mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 19:26:39 +02:00
added the abitliy to opt out of pinyin in control panel and in program plug in - this give a major perf boost (and I'm guessing it is not relevant for most users)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">Indexierungsspeicher</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">Endungen</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">Maximale Tiefe</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">Verzeichnis:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">Durchsuchen</system:String>
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">Index Registry</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">Suffixes</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">Max Depth</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin</system:String>
|
||||
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">Directory:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">Browse</system:String>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">Indeksuj rejestr</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">Rozszerzenia</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">Maksymalna głębokość</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">Katalog:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">Przeglądaj</system:String>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">Registry'i İndeksle</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">Uzantılar</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">Derinlik</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">Dizin:</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">Gözat</system:String>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">索引注册表</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">后缀</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">目录</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">浏览</system:String>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<system:String x:Key="wox_plugin_program_index_registry">替登錄檔建立索引</system:String>
|
||||
<system:String x:Key="wox_plugin_program_suffixes_header">副檔名</system:String>
|
||||
<system:String x:Key="wox_plugin_program_max_depth_header">最大深度</system:String>
|
||||
<system:String x:Key="wox_plugin_program_use_pinyin">Should Use Pinyin (waiting for translation)</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_directory">目錄</system:String>
|
||||
<system:String x:Key="wox_plugin_program_browse">瀏覽</system:String>
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
private static BinaryStorage<Win32[]> _win32Storage;
|
||||
|
||||
private static Settings _settings;
|
||||
private readonly Settings _settings;
|
||||
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
||||
|
||||
public Main()
|
||||
@@ -66,9 +66,9 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
lock (IndexLock)
|
||||
{
|
||||
var results1 = _win32s.AsParallel().Select(p => p.Result(query.Search, _context.API));
|
||||
var results1 = _win32s.AsParallel().Select(p => p.Result(query.Search, _context.API, _settings));
|
||||
#if !IGNORE_UWP
|
||||
var results2 = _uwps.AsParallel().Select(p => p.Result(query.Search, _context.API));
|
||||
var results2 = _uwps.AsParallel().Select(p => p.Result(query.Search, _context.API, _settings));
|
||||
#endif
|
||||
var result = results1
|
||||
#if !IGNORE_UWP
|
||||
@@ -84,7 +84,7 @@ namespace Wox.Plugin.Program
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public static void IndexPrograms()
|
||||
public void IndexPrograms()
|
||||
{
|
||||
Win32[] w = { };
|
||||
#if !IGNORE_UWP
|
||||
@@ -121,7 +121,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return new ProgramSetting(_context, _settings);
|
||||
return new ProgramSetting(_context, _settings, this);
|
||||
}
|
||||
|
||||
public string GetTranslatedPluginTitle()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
d:DesignHeight="300" d:DesignWidth="600">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
@@ -16,6 +16,7 @@
|
||||
<StackPanel Orientation="Vertical" Width="310">
|
||||
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}" />
|
||||
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}" />
|
||||
<CheckBox Name="ShouldUsePinYin" Click="ShouldUsePinYin_Click" Margin="5" Content="{DynamicResource wox_plugin_program_use_pinyin}"/>
|
||||
</StackPanel>
|
||||
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}" />
|
||||
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}" />
|
||||
|
||||
@@ -11,15 +11,17 @@ namespace Wox.Plugin.Program
|
||||
/// </summary>
|
||||
public partial class ProgramSetting : UserControl
|
||||
{
|
||||
private PluginInitContext context;
|
||||
private Settings _settings;
|
||||
private readonly PluginInitContext context;
|
||||
private readonly Settings _settings;
|
||||
private readonly Main _main;
|
||||
|
||||
public ProgramSetting(PluginInitContext context, Settings settings)
|
||||
public ProgramSetting(PluginInitContext context, Settings settings, Main main)
|
||||
{
|
||||
this.context = context;
|
||||
InitializeComponent();
|
||||
Loaded += Setting_Loaded;
|
||||
_settings = settings;
|
||||
_main = main;
|
||||
}
|
||||
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -27,6 +29,7 @@ namespace Wox.Plugin.Program
|
||||
programSourceView.ItemsSource = _settings.ProgramSources;
|
||||
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
|
||||
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
|
||||
ShouldUsePinYin.IsChecked = _settings.ShouldUsePinYin;
|
||||
}
|
||||
|
||||
private void ReIndexing()
|
||||
@@ -35,7 +38,7 @@ namespace Wox.Plugin.Program
|
||||
Task.Run(() =>
|
||||
{
|
||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Visible; });
|
||||
Main.IndexPrograms();
|
||||
_main.IndexPrograms();
|
||||
Dispatcher.Invoke(() => { indexingPanel.Visibility = Visibility.Hidden; });
|
||||
});
|
||||
}
|
||||
@@ -145,5 +148,10 @@ namespace Wox.Plugin.Program
|
||||
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
||||
ReIndexing();
|
||||
}
|
||||
|
||||
private void ShouldUsePinYin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_settings.ShouldUsePinYin = ShouldUsePinYin.IsChecked ?? false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ namespace Wox.Plugin.Program.Programs
|
||||
public interface IProgram
|
||||
{
|
||||
List<Result> ContextMenus(IPublicAPI api);
|
||||
Result Result(string query, IPublicAPI api);
|
||||
Result Result(string query, IPublicAPI api, Settings settings);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,23 +239,23 @@ namespace Wox.Plugin.Program.Programs
|
||||
public string LogoPath { get; set; }
|
||||
public UWP Package { get; set; }
|
||||
|
||||
private int Score(string query)
|
||||
private int Score(string query, bool shouldUsePinYin)
|
||||
{
|
||||
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(DisplayName, query) : 0;
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = Package.Location,
|
||||
Icon = Logo,
|
||||
Score = Score(query),
|
||||
Score = Score(query, settings.ShouldUsePinYin),
|
||||
ContextData = this,
|
||||
Action = e =>
|
||||
{
|
||||
|
||||
@@ -29,25 +29,25 @@ namespace Wox.Plugin.Program.Programs
|
||||
private const string ApplicationReferenceExtension = "appref-ms";
|
||||
private const string ExeExtension = "exe";
|
||||
|
||||
private int Score(string query)
|
||||
private int Score(string query, bool shouldUsePinYin)
|
||||
{
|
||||
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(Name, query);
|
||||
var score2 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Name, query) : 0;
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score4 = shouldUsePinYin ? StringMatcher.ScoreForPinyin(Description, query) : 0;
|
||||
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
||||
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
||||
|
||||
public Result Result(string query, IPublicAPI api)
|
||||
public Result Result(string query, IPublicAPI api, Settings settings)
|
||||
{
|
||||
var result = new Result
|
||||
{
|
||||
SubTitle = FullPath,
|
||||
IcoPath = IcoPath,
|
||||
Score = Score(query),
|
||||
Score = Score(query, settings.ShouldUsePinYin),
|
||||
ContextData = this,
|
||||
Action = e =>
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public bool EnableRegistrySource { get; set; } = true;
|
||||
|
||||
public bool ShouldUsePinYin { get; set; } = true;
|
||||
|
||||
internal const char SuffixSeperator = ';';
|
||||
|
||||
public class ProgramSource
|
||||
|
||||
Reference in New Issue
Block a user