mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Implement Option to disable program description
This commit is contained in:
parent
be8bb8bcd1
commit
4a02cff498
7 changed files with 73 additions and 56 deletions
|
|
@ -14,6 +14,7 @@
|
||||||
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_index_start">Index Start Menu</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_index_start">Index Start Menu</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
|
||||||
|
<system:String x:Key="flowlauncher_plugin_program_enable_description">Enable Program Description</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max Depth</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max Depth</system:String>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
<system:String x:Key="flowlauncher_plugin_program_indexing">索引中</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_indexing">索引中</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_index_start">索引开始菜单</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_index_start">索引开始菜单</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_index_registry">索引注册表</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_index_registry">索引注册表</system:String>
|
||||||
|
<system:String x:Key="flowlauncher_plugin_program_enable_description">启用程序描述</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">后缀</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">后缀</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">最大深度</system:String>
|
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">最大深度</system:String>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
var apps = new List<Application>();
|
var apps = new List<Application>();
|
||||||
|
|
||||||
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
|
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
|
||||||
foreach(var _app in _apps)
|
foreach (var _app in _apps)
|
||||||
{
|
{
|
||||||
var app = new Application(_app, this);
|
var app = new Application(_app, this);
|
||||||
apps.Add(app);
|
apps.Add(app);
|
||||||
|
|
@ -275,7 +275,7 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
MatchResult matchResult;
|
MatchResult matchResult;
|
||||||
|
|
||||||
// We suppose Name won't be null
|
// We suppose Name won't be null
|
||||||
if (Description == null || Name.StartsWith(Description))
|
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
|
||||||
{
|
{
|
||||||
title = Name;
|
title = Name;
|
||||||
matchResult = StringMatcher.FuzzySearch(query, title);
|
matchResult = StringMatcher.FuzzySearch(query, title);
|
||||||
|
|
|
||||||
|
|
@ -54,51 +54,43 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
||||||
public Result Result(string query, IPublicAPI api)
|
public Result Result(string query, IPublicAPI api)
|
||||||
{
|
{
|
||||||
string title;
|
string title;
|
||||||
|
MatchResult matchResult;
|
||||||
var nameMatchResult = StringMatcher.FuzzySearch(query, Name);
|
|
||||||
var descriptionMatchResult = StringMatcher.FuzzySearch(query, Description);
|
|
||||||
|
|
||||||
var pathMatchResult = new MatchResult(false, 0, new List<int>(), 0);
|
|
||||||
if (ExecutableName != null) // only lnk program will need this one
|
|
||||||
pathMatchResult = StringMatcher.FuzzySearch(query, ExecutableName);
|
|
||||||
|
|
||||||
MatchResult matchResult = nameMatchResult;
|
|
||||||
|
|
||||||
if (nameMatchResult.Score < descriptionMatchResult.Score)
|
|
||||||
matchResult = descriptionMatchResult;
|
|
||||||
|
|
||||||
if (!matchResult.IsSearchPrecisionScoreMet())
|
|
||||||
{
|
|
||||||
if (pathMatchResult.IsSearchPrecisionScoreMet())
|
|
||||||
matchResult = pathMatchResult;
|
|
||||||
else return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We suppose Name won't be null
|
// We suppose Name won't be null
|
||||||
if (Description == null || Name.StartsWith(Description))
|
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
|
||||||
{
|
{
|
||||||
title = Name;
|
title = Name;
|
||||||
|
matchResult = StringMatcher.FuzzySearch(query, title);
|
||||||
}
|
}
|
||||||
else if (Description.StartsWith(Name))
|
else if (Description.StartsWith(Name))
|
||||||
{
|
{
|
||||||
title = Description;
|
title = Description;
|
||||||
|
matchResult = StringMatcher.FuzzySearch(query, Description);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
title = $"{Name}: {Description}";
|
title = $"{Name}: {Description}";
|
||||||
|
var nameMatch = StringMatcher.FuzzySearch(query, Name);
|
||||||
if (matchResult == descriptionMatchResult)
|
var desciptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||||
|
if (desciptionMatch.Score > nameMatch.Score)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < descriptionMatchResult.MatchData.Count; i++)
|
for (int i = 0; i < desciptionMatch.MatchData.Count; i++)
|
||||||
{
|
{
|
||||||
matchResult.MatchData[i] += Name.Length + 2; // 2 is ": "
|
desciptionMatch.MatchData[i] += Name.Length + 2; // 2 is ": "
|
||||||
}
|
}
|
||||||
|
matchResult = desciptionMatch;
|
||||||
}
|
}
|
||||||
|
else matchResult = nameMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchResult == pathMatchResult)
|
if (!matchResult.IsSearchPrecisionScoreMet())
|
||||||
{
|
{
|
||||||
// path Match won't have valid highlight data
|
if (ExecutableName != null) // only lnk program will need this one
|
||||||
|
matchResult = StringMatcher.FuzzySearch(query, ExecutableName);
|
||||||
|
|
||||||
|
if (!matchResult.IsSearchPrecisionScoreMet())
|
||||||
|
return null;
|
||||||
|
|
||||||
matchResult.MatchData = new List<int>();
|
matchResult.MatchData = new List<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ namespace Flow.Launcher.Plugin.Program
|
||||||
|
|
||||||
public bool EnableStartMenuSource { get; set; } = true;
|
public bool EnableStartMenuSource { get; set; } = true;
|
||||||
|
|
||||||
|
public bool EnableDescription { get; set; } = true;
|
||||||
public bool EnableRegistrySource { get; set; } = true;
|
public bool EnableRegistrySource { get; set; } = true;
|
||||||
public string CustomizedExplorer { get; set; } = Explorer;
|
public string CustomizedExplorer { get; set; } = Explorer;
|
||||||
public string CustomizedArgs { get; set; } = ExplorerArgs;
|
public string CustomizedArgs { get; set; } = ExplorerArgs;
|
||||||
|
|
|
||||||
|
|
@ -4,19 +4,21 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
|
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
|
||||||
|
DataContext="{Binding RelativeSource={RelativeSource Self}}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="404.508" d:DesignWidth="600">
|
d:DesignHeight="404.508" d:DesignWidth="600">
|
||||||
<Grid Margin="10">
|
<Grid Margin="10">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="75"/>
|
<RowDefinition Height="120"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
<RowDefinition Height="50"/>
|
<RowDefinition Height="50"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||||
<StackPanel Orientation="Vertical" Width="205">
|
<StackPanel Orientation="Vertical" Width="250">
|
||||||
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" />
|
<CheckBox Name="StartMenuEnabled" IsChecked="{Binding EnableStartMenuSource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" />
|
||||||
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" />
|
<CheckBox Name="RegistryEnabled" IsChecked="{Binding EnableRegistrySource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" />
|
||||||
|
<CheckBox Name="DescriptionEnabled" IsChecked="{Binding EnableDescription}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_enable_description}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnLoadAllProgramSource" Click="btnLoadAllProgramSource_OnClick" Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />
|
<Button Height="31" HorizontalAlignment="Right" Margin="10" Width="100" x:Name="btnLoadAllProgramSource" Click="btnLoadAllProgramSource_OnClick" Content="{DynamicResource flowlauncher_plugin_program_all_programs}" />
|
||||||
|
|
@ -79,10 +81,10 @@
|
||||||
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_customizedexplorer}" VerticalAlignment="Center" FontSize="15"
|
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_customizedexplorer}" VerticalAlignment="Center" FontSize="15"
|
||||||
ToolTip= "{DynamicResource flowlauncher_plugin_program_tooltip_customizedexplorer}"/>
|
ToolTip= "{DynamicResource flowlauncher_plugin_program_tooltip_customizedexplorer}"/>
|
||||||
<TextBox Margin="10,0,10,0" TextWrapping="NoWrap" VerticalAlignment="Center" Width="200" Height="30" FontSize="15"
|
<TextBox Margin="10,0,10,0" TextWrapping="NoWrap" VerticalAlignment="Center" Width="200" Height="30" FontSize="15"
|
||||||
TextChanged="CustomizeExplorer" x:Name="CustomizeExplorerBox"/>
|
Text="{Binding CustomizedExplorerPath}" x:Name="CustomizeExplorerBox"/>
|
||||||
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_args}" VerticalAlignment="Center" FontSize="15"
|
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_args}" VerticalAlignment="Center" FontSize="15"
|
||||||
ToolTip="{DynamicResource flowlauncher_plugin_program_tooltip_args}" />
|
ToolTip="{DynamicResource flowlauncher_plugin_program_tooltip_args}" />
|
||||||
<TextBox Margin="10,0,0,0" Width="135" Height="30" FontSize="15" x:Name="CustomizeArgsBox" TextChanged="CustomizeExplorerArgs"></TextBox>
|
<TextBox Margin="10,0,0,0" Width="135" Height="30" FontSize="15" x:Name="CustomizeArgsBox" Text="{Binding CustomizedExplorerArg}"></TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,50 @@ namespace Flow.Launcher.Plugin.Program.Views
|
||||||
// this as temporary holder for displaying all loaded programs sources.
|
// this as temporary holder for displaying all loaded programs sources.
|
||||||
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
|
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
|
||||||
|
|
||||||
|
public bool EnableDescription
|
||||||
|
{
|
||||||
|
get => _settings.EnableDescription;
|
||||||
|
set => _settings.EnableDescription = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnableRegistrySource
|
||||||
|
{
|
||||||
|
get => _settings.EnableRegistrySource;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_settings.EnableRegistrySource = value;
|
||||||
|
ReIndexing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EnableStartMenuSource
|
||||||
|
{
|
||||||
|
get => _settings.EnableStartMenuSource;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_settings.EnableStartMenuSource = value;
|
||||||
|
ReIndexing();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CustomizedExplorerPath
|
||||||
|
{
|
||||||
|
get => _settings.CustomizedExplorer;
|
||||||
|
set => _settings.CustomizedExplorer = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string CustomizedExplorerArg
|
||||||
|
{
|
||||||
|
get => _settings.CustomizedArgs;
|
||||||
|
set => _settings.CustomizedArgs = value;
|
||||||
|
}
|
||||||
|
|
||||||
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
|
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
InitializeComponent();
|
|
||||||
Loaded += Setting_Loaded;
|
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
Loaded += Setting_Loaded;
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
@ -40,12 +78,6 @@ namespace Flow.Launcher.Plugin.Program.Views
|
||||||
ProgramSettingDisplayList = _settings.ProgramSources.LoadProgramSources();
|
ProgramSettingDisplayList = _settings.ProgramSources.LoadProgramSources();
|
||||||
programSourceView.ItemsSource = ProgramSettingDisplayList;
|
programSourceView.ItemsSource = ProgramSettingDisplayList;
|
||||||
|
|
||||||
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
|
|
||||||
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
|
|
||||||
|
|
||||||
CustomizeExplorerBox.Text = _settings.CustomizedExplorer;
|
|
||||||
CustomizeArgsBox.Text = _settings.CustomizedArgs;
|
|
||||||
|
|
||||||
ViewRefresh();
|
ViewRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -178,18 +210,6 @@ namespace Flow.Launcher.Plugin.Program.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartMenuEnabled_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
_settings.EnableStartMenuSource = StartMenuEnabled.IsChecked ?? false;
|
|
||||||
ReIndexing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RegistryEnabled_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
|
||||||
ReIndexing();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void btnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ProgramSettingDisplayList.LoadAllApplications();
|
ProgramSettingDisplayList.LoadAllApplications();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue