mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Allow disabling of default program sources
This commit is contained in:
parent
e82bc859f5
commit
485afcfa6e
4 changed files with 40 additions and 8 deletions
|
|
@ -12,7 +12,11 @@
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</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" 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>
|
<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>
|
</StackPanel>
|
||||||
|
|
@ -28,7 +32,7 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
<GridViewColumn Header="Suffixes" Width="250">
|
<GridViewColumn Header="Suffixes" Width="220">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Suffixes, ConverterParameter=(null), Converter={program:StringEmptyConverter}}"/>
|
<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)
|
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources;
|
programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources;
|
||||||
|
StartMenuEnabled.IsChecked = ProgramStorage.Instance.EnableStartMenuSource;
|
||||||
|
RegistryEnabled.IsChecked = ProgramStorage.Instance.EnableRegistrySource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReIndexing()
|
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 System.Text;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Wox.Infrastructure.Storage;
|
using Wox.Infrastructure.Storage;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Wox.Plugin.Program
|
namespace Wox.Plugin.Program
|
||||||
{
|
{
|
||||||
|
|
@ -17,6 +18,14 @@ namespace Wox.Plugin.Program
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string ProgramSuffixes { get; set; }
|
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
|
protected override string ConfigFolder
|
||||||
{
|
{
|
||||||
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
|
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
|
||||||
|
|
@ -25,6 +34,8 @@ namespace Wox.Plugin.Program
|
||||||
protected override ProgramStorage LoadDefault()
|
protected override ProgramStorage LoadDefault()
|
||||||
{
|
{
|
||||||
ProgramSources = new List<ProgramSource>();
|
ProgramSources = new List<ProgramSource>();
|
||||||
|
EnableStartMenuSource = true;
|
||||||
|
EnableRegistrySource = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ namespace Wox.Plugin.Program
|
||||||
|
|
||||||
public List<Result> Query(Query query)
|
public List<Result> Query(Query query)
|
||||||
{
|
{
|
||||||
|
|
||||||
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
||||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
||||||
returnList.ForEach(ScoreFilter);
|
returnList.ForEach(ScoreFilter);
|
||||||
|
|
@ -97,11 +98,11 @@ namespace Wox.Plugin.Program
|
||||||
if (ProgramStorage.Instance.ProgramSources != null &&
|
if (ProgramStorage.Instance.ProgramSources != null &&
|
||||||
ProgramStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0)
|
ProgramStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0)
|
||||||
{
|
{
|
||||||
programSources.AddRange(ProgramStorage.Instance.ProgramSources.Where(o => o.Enabled));
|
programSources.AddRange(ProgramStorage.Instance.ProgramSources);
|
||||||
}
|
}
|
||||||
|
|
||||||
sources.Clear();
|
sources.Clear();
|
||||||
programSources.ForEach(source =>
|
foreach(var source in programSources.Where(o => o.Enabled))
|
||||||
{
|
{
|
||||||
Type sourceClass;
|
Type sourceClass;
|
||||||
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
|
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
|
||||||
|
|
@ -114,7 +115,7 @@ namespace Wox.Plugin.Program
|
||||||
sources.Add(programSource);
|
sources.Add(programSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
var tempPrograms = new List<Program>();
|
var tempPrograms = new List<Program>();
|
||||||
foreach (var source in sources)
|
foreach (var source in sources)
|
||||||
|
|
@ -145,19 +146,19 @@ namespace Wox.Plugin.Program
|
||||||
list.Add(new ProgramSource()
|
list.Add(new ProgramSource()
|
||||||
{
|
{
|
||||||
BonusPoints = 0,
|
BonusPoints = 0,
|
||||||
Enabled = true,
|
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||||
Type = "CommonStartMenuProgramSource"
|
Type = "CommonStartMenuProgramSource"
|
||||||
});
|
});
|
||||||
list.Add(new ProgramSource()
|
list.Add(new ProgramSource()
|
||||||
{
|
{
|
||||||
BonusPoints = 0,
|
BonusPoints = 0,
|
||||||
Enabled = true,
|
Enabled = ProgramStorage.Instance.EnableStartMenuSource,
|
||||||
Type = "UserStartMenuProgramSource"
|
Type = "UserStartMenuProgramSource"
|
||||||
});
|
});
|
||||||
list.Add(new ProgramSource()
|
list.Add(new ProgramSource()
|
||||||
{
|
{
|
||||||
BonusPoints = -10,
|
BonusPoints = -10,
|
||||||
Enabled = true,
|
Enabled = ProgramStorage.Instance.EnableRegistrySource,
|
||||||
Type = "AppPathsProgramSource"
|
Type = "AppPathsProgramSource"
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue