Skip to content

Commit b77a8f7

Browse files
Fix suffixes
1 parent d13c381 commit b77a8f7

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@
167167
FontSize="16"
168168
FontWeight="SemiBold"
169169
Text="{DynamicResource flowlauncher_plugin_program_suffixes_excutable_types}" />
170-
<CheckBox Name="apprefMS" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[appref-ms]}">appref-ms</CheckBox>
171-
<CheckBox Name="exe" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[exe]}">exe</CheckBox>
172-
<CheckBox Name="lnk" Margin="10,0,0,0" IsChecked="{Binding _settings.BuiltinSuffixesStatus[lnk]}">lnk</CheckBox>
170+
<CheckBox Name="apprefMS" Margin="10,0,0,0" IsChecked="{Binding SuffixesStaus[appref-ms]}">appref-ms</CheckBox>
171+
<CheckBox Name="exe" Margin="10,0,0,0" IsChecked="{Binding SuffixesStaus[exe]}">exe</CheckBox>
172+
<CheckBox Name="lnk" Margin="10,0,0,0" IsChecked="{Binding SuffixesStaus[lnk]}">lnk</CheckBox>
173173
<CheckBox
174174
Name="CustomFiles"
175175
Margin="10,0,0,0"

Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Windows;
34

45
namespace Flow.Launcher.Plugin.Program
@@ -7,13 +8,14 @@ public partial class ProgramSuffixes
78
{
89
private PluginInitContext context;
910
private Settings _settings;
11+
public Dictionary<string, bool> SuffixesStaus => _settings.BuiltinSuffixesStatus;
1012

1113
public ProgramSuffixes(PluginInitContext context, Settings settings)
1214
{
1315
this.context = context;
14-
InitializeComponent();
1516
_settings = settings;
16-
tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.CustomSuffixes);
17+
InitializeComponent();
18+
tbSuffixes.Text = string.Join(Settings.SuffixSeperator, _settings.CustomSuffixes);
1719
}
1820

1921
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
@@ -25,7 +27,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
2527
{
2628
var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries);
2729

28-
if (suffixes.Length == 0)
30+
if (suffixes.Length == 0 && _settings.UseCustomSuffixes)
2931
{
3032
string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty");
3133
MessageBox.Show(warning);
@@ -34,14 +36,18 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
3436

3537
_settings.CustomSuffixes = suffixes;
3638

37-
string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes");
38-
MessageBox.Show(msg);
39+
//string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes");
40+
//MessageBox.Show(msg);
3941

4042
DialogResult = true;
4143
}
4244

4345
private void BtnReset_OnClick(object sender, RoutedEventArgs e)
4446
{
47+
apprefMS.IsChecked = true;
48+
exe.IsChecked = true;
49+
lnk.IsChecked = true;
50+
CustomFiles.IsChecked = false;
4551

4652
}
4753
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,21 +537,21 @@ public static Win32[] All(Settings settings)
537537
{
538538
var programs = Enumerable.Empty<Win32>();
539539

540-
var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.CustomSuffixes);
540+
var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.GetProgramExtensions());
541541

542542
programs = programs.Concat(unregistered);
543543

544544
var autoIndexPrograms = Enumerable.Empty<Win32>();
545545

546546
if (settings.EnableRegistrySource)
547547
{
548-
var appPaths = AppPathsPrograms(settings.CustomSuffixes);
548+
var appPaths = AppPathsPrograms(settings.GetProgramExtensions());
549549
autoIndexPrograms = autoIndexPrograms.Concat(appPaths);
550550
}
551551

552552
if (settings.EnableStartMenuSource)
553553
{
554-
var startMenu = StartMenuPrograms(settings.CustomSuffixes);
554+
var startMenu = StartMenuPrograms(settings.GetProgramExtensions());
555555
autoIndexPrograms = autoIndexPrograms.Concat(startMenu);
556556
}
557557

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Text.Json.Serialization;
56

67
namespace Flow.Launcher.Plugin.Program
78
{
@@ -10,8 +11,9 @@ public class Settings
1011
public DateTime LastIndexTime { get; set; }
1112
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
1213
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
13-
public string[] CustomSuffixes { get; set; } = { "appref-ms", "exe", "lnk" };
14+
public string[] CustomSuffixes { get; set; } = { };
1415

16+
[JsonIgnore]
1517
public Dictionary<string, bool> BuiltinSuffixesStatus { get; set; } = new Dictionary<string, bool>{
1618
{ "exe", true }, { "appref-ms", true }, { "lnk", true }
1719
};
@@ -30,7 +32,16 @@ public string[] GetProgramExtensions()
3032
}
3133
}
3234

33-
return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray();
35+
// todo: url
36+
37+
if (UseCustomSuffixes)
38+
{
39+
return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray();
40+
}
41+
else
42+
{
43+
return extensions.ToArray();
44+
}
3445
}
3546

3647
public bool EnableStartMenuSource { get; set; } = true;

0 commit comments

Comments
 (0)