Skip to content

Commit d813a47

Browse files
authored
Merge pull request #447 from Flow-Launcher/optionHideDescription
Implement Option to disable program description
2 parents c0afb49 + c97dd36 commit d813a47

File tree

8 files changed

+74
-57
lines changed

8 files changed

+74
-57
lines changed

Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<system:String x:Key="flowlauncher_plugin_program_indexing">Indexing</system:String>
1515
<system:String x:Key="flowlauncher_plugin_program_index_start">Index Start Menu</system:String>
1616
<system:String x:Key="flowlauncher_plugin_program_index_registry">Index Registry</system:String>
17+
<system:String x:Key="flowlauncher_plugin_program_enable_description">Enable Program Description</system:String>
1718
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">Suffixes</system:String>
1819
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">Max Depth</system:String>
1920

Plugins/Flow.Launcher.Plugin.Program/Languages/zh-cn.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<system:String x:Key="flowlauncher_plugin_program_indexing">索引中</system:String>
1515
<system:String x:Key="flowlauncher_plugin_program_index_start">索引开始菜单</system:String>
1616
<system:String x:Key="flowlauncher_plugin_program_index_registry">索引注册表</system:String>
17+
<system:String x:Key="flowlauncher_plugin_program_enable_description">启用程序描述</system:String>
1718
<system:String x:Key="flowlauncher_plugin_program_suffixes_header">后缀</system:String>
1819
<system:String x:Key="flowlauncher_plugin_program_max_depth_header">最大深度</system:String>
1920

Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ private void InitializeAppInfo()
6363
if (hResult == Hresult.Ok)
6464
{
6565
var apps = new List<Application>();
66-
66+
6767
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
68-
foreach(var _app in _apps)
68+
foreach (var _app in _apps)
6969
{
7070
var app = new Application(_app, this);
7171
apps.Add(app);
7272
}
73-
73+
7474
Apps = apps.Where(a => a.AppListEntry != "none").ToArray();
7575
}
7676
else
@@ -275,7 +275,7 @@ public Result Result(string query, IPublicAPI api)
275275
MatchResult matchResult;
276276

277277
// We suppose Name won't be null
278-
if (Description == null || Name.StartsWith(Description))
278+
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
279279
{
280280
title = Name;
281281
matchResult = StringMatcher.FuzzySearch(query, title);

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,51 +54,43 @@ public class Win32 : IProgram, IEquatable<Win32>
5454
public Result Result(string query, IPublicAPI api)
5555
{
5656
string title;
57-
58-
var nameMatchResult = StringMatcher.FuzzySearch(query, Name);
59-
var descriptionMatchResult = StringMatcher.FuzzySearch(query, Description);
60-
61-
var pathMatchResult = new MatchResult(false, 0, new List<int>(), 0);
62-
if (ExecutableName != null) // only lnk program will need this one
63-
pathMatchResult = StringMatcher.FuzzySearch(query, ExecutableName);
64-
65-
MatchResult matchResult = nameMatchResult;
66-
67-
if (nameMatchResult.Score < descriptionMatchResult.Score)
68-
matchResult = descriptionMatchResult;
69-
70-
if (!matchResult.IsSearchPrecisionScoreMet())
71-
{
72-
if (pathMatchResult.IsSearchPrecisionScoreMet())
73-
matchResult = pathMatchResult;
74-
else return null;
75-
}
57+
MatchResult matchResult;
7658

7759
// We suppose Name won't be null
78-
if (Description == null || Name.StartsWith(Description))
60+
if (!Main._settings.EnableDescription || Description == null || Name.StartsWith(Description))
7961
{
8062
title = Name;
63+
matchResult = StringMatcher.FuzzySearch(query, title);
8164
}
8265
else if (Description.StartsWith(Name))
8366
{
8467
title = Description;
68+
matchResult = StringMatcher.FuzzySearch(query, Description);
8569
}
8670
else
8771
{
8872
title = $"{Name}: {Description}";
89-
90-
if (matchResult == descriptionMatchResult)
73+
var nameMatch = StringMatcher.FuzzySearch(query, Name);
74+
var desciptionMatch = StringMatcher.FuzzySearch(query, Description);
75+
if (desciptionMatch.Score > nameMatch.Score)
9176
{
92-
for (int i = 0; i < descriptionMatchResult.MatchData.Count; i++)
77+
for (int i = 0; i < desciptionMatch.MatchData.Count; i++)
9378
{
94-
matchResult.MatchData[i] += Name.Length + 2; // 2 is ": "
79+
desciptionMatch.MatchData[i] += Name.Length + 2; // 2 is ": "
9580
}
81+
matchResult = desciptionMatch;
9682
}
83+
else matchResult = nameMatch;
9784
}
9885

99-
if (matchResult == pathMatchResult)
86+
if (!matchResult.IsSearchPrecisionScoreMet())
10087
{
101-
// path Match won't have valid highlight data
88+
if (ExecutableName != null) // only lnk program will need this one
89+
matchResult = StringMatcher.FuzzySearch(query, ExecutableName);
90+
91+
if (!matchResult.IsSearchPrecisionScoreMet())
92+
return null;
93+
10294
matchResult.MatchData = new List<int>();
10395
}
10496

Plugins/Flow.Launcher.Plugin.Program/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class Settings
1313

1414
public bool EnableStartMenuSource { get; set; } = true;
1515

16+
public bool EnableDescription { get; set; } = true;
1617
public bool EnableRegistrySource { get; set; } = true;
1718
public string CustomizedExplorer { get; set; } = Explorer;
1819
public string CustomizedArgs { get; set; } = ExplorerArgs;

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:program="clr-namespace:Flow.Launcher.Plugin.Program"
7+
DataContext="{Binding RelativeSource={RelativeSource Self}}"
78
mc:Ignorable="d"
89
d:DesignHeight="404.508" d:DesignWidth="600">
910
<Grid Margin="10">
1011
<Grid.RowDefinitions>
11-
<RowDefinition Height="75"/>
12+
<RowDefinition Height="120"/>
1213
<RowDefinition Height="*"/>
1314
<RowDefinition Height="50"/>
1415
<RowDefinition Height="50"/>
1516
</Grid.RowDefinitions>
1617
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
17-
<StackPanel Orientation="Vertical" Width="205">
18-
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" />
19-
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" />
18+
<StackPanel Orientation="Vertical" Width="250">
19+
<CheckBox Name="StartMenuEnabled" IsChecked="{Binding EnableStartMenuSource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_start}" />
20+
<CheckBox Name="RegistryEnabled" IsChecked="{Binding EnableRegistrySource}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_index_registry}" />
21+
<CheckBox Name="DescriptionEnabled" IsChecked="{Binding EnableDescription}" Margin="5" Content="{DynamicResource flowlauncher_plugin_program_enable_description}" />
2022
</StackPanel>
2123
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
2224
<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 @@
7981
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_customizedexplorer}" VerticalAlignment="Center" FontSize="15"
8082
ToolTip= "{DynamicResource flowlauncher_plugin_program_tooltip_customizedexplorer}"/>
8183
<TextBox Margin="10,0,10,0" TextWrapping="NoWrap" VerticalAlignment="Center" Width="200" Height="30" FontSize="15"
82-
TextChanged="CustomizeExplorer" x:Name="CustomizeExplorerBox"/>
84+
Text="{Binding CustomizedExplorerPath}" x:Name="CustomizeExplorerBox"/>
8385
<TextBlock Text="{DynamicResource flowlauncher_plugin_program_args}" VerticalAlignment="Center" FontSize="15"
8486
ToolTip="{DynamicResource flowlauncher_plugin_program_tooltip_args}" />
85-
<TextBox Margin="10,0,0,0" Width="135" Height="30" FontSize="15" x:Name="CustomizeArgsBox" TextChanged="CustomizeExplorerArgs"></TextBox>
87+
<TextBox Margin="10,0,0,0" Width="135" Height="30" FontSize="15" x:Name="CustomizeArgsBox" Text="{Binding CustomizedExplorerArg}"></TextBox>
8688
</StackPanel>
8789
</Grid>
8890
</UserControl>

Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,57 @@ public partial class ProgramSetting : UserControl
2727
// this as temporary holder for displaying all loaded programs sources.
2828
internal static List<ProgramSource> ProgramSettingDisplayList { get; set; }
2929

30+
public bool EnableDescription
31+
{
32+
get => _settings.EnableDescription;
33+
set => _settings.EnableDescription = value;
34+
}
35+
36+
public bool EnableRegistrySource
37+
{
38+
get => _settings.EnableRegistrySource;
39+
set
40+
{
41+
_settings.EnableRegistrySource = value;
42+
ReIndexing();
43+
}
44+
}
45+
46+
public bool EnableStartMenuSource
47+
{
48+
get => _settings.EnableStartMenuSource;
49+
set
50+
{
51+
_settings.EnableStartMenuSource = value;
52+
ReIndexing();
53+
}
54+
}
55+
56+
public string CustomizedExplorerPath
57+
{
58+
get => _settings.CustomizedExplorer;
59+
set => _settings.CustomizedExplorer = value;
60+
}
61+
62+
public string CustomizedExplorerArg
63+
{
64+
get => _settings.CustomizedArgs;
65+
set => _settings.CustomizedArgs = value;
66+
}
67+
3068
public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
3169
{
3270
this.context = context;
33-
InitializeComponent();
34-
Loaded += Setting_Loaded;
3571
_settings = settings;
72+
Loaded += Setting_Loaded;
73+
InitializeComponent();
3674
}
3775

3876
private void Setting_Loaded(object sender, RoutedEventArgs e)
3977
{
4078
ProgramSettingDisplayList = _settings.ProgramSources.LoadProgramSources();
4179
programSourceView.ItemsSource = ProgramSettingDisplayList;
4280

43-
StartMenuEnabled.IsChecked = _settings.EnableStartMenuSource;
44-
RegistryEnabled.IsChecked = _settings.EnableRegistrySource;
45-
46-
CustomizeExplorerBox.Text = _settings.CustomizedExplorer;
47-
CustomizeArgsBox.Text = _settings.CustomizedArgs;
48-
4981
ViewRefresh();
5082
}
5183

@@ -178,18 +210,6 @@ private void programSourceView_Drop(object sender, DragEventArgs e)
178210
}
179211
}
180212

181-
private void StartMenuEnabled_Click(object sender, RoutedEventArgs e)
182-
{
183-
_settings.EnableStartMenuSource = StartMenuEnabled.IsChecked ?? false;
184-
ReIndexing();
185-
}
186-
187-
private void RegistryEnabled_Click(object sender, RoutedEventArgs e)
188-
{
189-
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
190-
ReIndexing();
191-
}
192-
193213
private void btnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
194214
{
195215
ProgramSettingDisplayList.LoadAllApplications();

Plugins/Flow.Launcher.Plugin.Program/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Name": "Program",
55
"Description": "Search programs in Flow.Launcher",
66
"Author": "qianlifeng",
7-
"Version": "1.4.6",
7+
"Version": "1.5.0",
88
"Language": "csharp",
99
"Website": "https://github.com/Flow-Launcher/Flow.Launcher",
1010
"ExecuteFileName": "Flow.Launcher.Plugin.Program.dll",

0 commit comments

Comments
 (0)