mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
Allow disabling of default program sources
This commit is contained in:
@@ -12,7 +12,11 @@
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||
<StackPanel Orientation="Vertical" Width="310">
|
||||
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5">Index Start Menu</CheckBox>
|
||||
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5">Index Registry</CheckBox>
|
||||
</StackPanel>
|
||||
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}"></Button>
|
||||
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}"></Button>
|
||||
</StackPanel>
|
||||
@@ -28,7 +32,7 @@
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="Suffixes" Width="250">
|
||||
<GridViewColumn Header="Suffixes" Width="220">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Suffixes, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Wox.Plugin.Program
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources;
|
||||
StartMenuEnabled.IsChecked = ProgramStorage.Instance.EnableStartMenuSource;
|
||||
RegistryEnabled.IsChecked = ProgramStorage.Instance.EnableRegistrySource;
|
||||
}
|
||||
|
||||
private void ReIndexing()
|
||||
@@ -130,5 +132,19 @@ namespace Wox.Plugin.Program
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StartMenuEnabled_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramStorage.Instance.EnableStartMenuSource = StartMenuEnabled.IsChecked ?? false;
|
||||
ProgramStorage.Instance.Save();
|
||||
ReIndexing();
|
||||
}
|
||||
|
||||
private void RegistryEnabled_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ProgramStorage.Instance.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
||||
ProgramStorage.Instance.Save();
|
||||
ReIndexing();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
{
|
||||
@@ -17,6 +18,14 @@ namespace Wox.Plugin.Program
|
||||
[JsonProperty]
|
||||
public string ProgramSuffixes { get; set; }
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableStartMenuSource { get; set; }
|
||||
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
[DefaultValue(true)]
|
||||
public bool EnableRegistrySource { get; set; }
|
||||
|
||||
protected override string ConfigFolder
|
||||
{
|
||||
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
|
||||
@@ -25,6 +34,8 @@ namespace Wox.Plugin.Program
|
||||
protected override ProgramStorage LoadDefault()
|
||||
{
|
||||
ProgramSources = new List<ProgramSource>();
|
||||
EnableStartMenuSource = true;
|
||||
EnableRegistrySource = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
|
||||
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||
returnList.ForEach(ScoreFilter);
|
||||
@@ -97,11 +98,11 @@ namespace Wox.Plugin.Program
|
||||
if (ProgramStorage.Instance.ProgramSources != null &&
|
||||
ProgramStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0)
|
||||
{
|
||||
programSources.AddRange(ProgramStorage.Instance.ProgramSources.Where(o => o.Enabled));
|
||||
programSources.AddRange(ProgramStorage.Instance.ProgramSources);
|
||||
}
|
||||
|
||||
sources.Clear();
|
||||
programSources.ForEach(source =>
|
||||
foreach(var source in programSources.Where(o => o.Enabled))
|
||||
{
|
||||
Type sourceClass;
|
||||
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
|
||||
@@ -114,7 +115,7 @@ namespace Wox.Plugin.Program
|
||||
sources.Add(programSource);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tempPrograms = new List<Program>();
|
||||
foreach (var source in sources)
|
||||
@@ -145,19 +146,19 @@ namespace Wox.Plugin.Program
|
||||
list.Add(new ProgramSource()
|
||||
{
|
||||
BonusPoints = 0,
|
||||
Enabled = true,
|
||||
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||
Type = "CommonStartMenuProgramSource"
|
||||
});
|
||||
list.Add(new ProgramSource()
|
||||
{
|
||||
BonusPoints = 0,
|
||||
Enabled = true,
|
||||
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||
Type = "UserStartMenuProgramSource"
|
||||
});
|
||||
list.Add(new ProgramSource()
|
||||
{
|
||||
BonusPoints = -10,
|
||||
Enabled = true,
|
||||
Enabled = ProgramStorage.Instance.EnableRegistrySource,
|
||||
Type = "AppPathsProgramSource"
|
||||
});
|
||||
return list;
|
||||
|
||||
Reference in New Issue
Block a user