From b77a8f755a1e763094e5d8e9de6a6d787d7df42a Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 23 Oct 2022 18:50:38 +0800 Subject: [PATCH] Fix suffixes --- .../ProgramSuffixes.xaml | 6 +++--- .../ProgramSuffixes.xaml.cs | 16 +++++++++++----- .../Programs/Win32.cs | 6 +++--- Plugins/Flow.Launcher.Plugin.Program/Settings.cs | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml index ef1ba3fcc..5a0f0eb1b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml @@ -167,9 +167,9 @@ FontSize="16" FontWeight="SemiBold" Text="{DynamicResource flowlauncher_plugin_program_suffixes_excutable_types}" /> - appref-ms - exe - lnk + appref-ms + exe + lnk SuffixesStaus => _settings.BuiltinSuffixesStatus; public ProgramSuffixes(PluginInitContext context, Settings settings) { this.context = context; - InitializeComponent(); _settings = settings; - tbSuffixes.Text = string.Join(Settings.SuffixSeperator.ToString(), _settings.CustomSuffixes); + InitializeComponent(); + tbSuffixes.Text = string.Join(Settings.SuffixSeperator, _settings.CustomSuffixes); } private void BtnCancel_OnClick(object sender, RoutedEventArgs e) @@ -25,7 +27,7 @@ namespace Flow.Launcher.Plugin.Program { var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); - if (suffixes.Length == 0) + if (suffixes.Length == 0 && _settings.UseCustomSuffixes) { string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); MessageBox.Show(warning); @@ -34,14 +36,18 @@ namespace Flow.Launcher.Plugin.Program _settings.CustomSuffixes = suffixes; - string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes"); - MessageBox.Show(msg); + //string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes"); + //MessageBox.Show(msg); DialogResult = true; } private void BtnReset_OnClick(object sender, RoutedEventArgs e) { + apprefMS.IsChecked = true; + exe.IsChecked = true; + lnk.IsChecked = true; + CustomFiles.IsChecked = false; } } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 79723e3b0..469a7133a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -537,7 +537,7 @@ namespace Flow.Launcher.Plugin.Program.Programs { var programs = Enumerable.Empty(); - var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.CustomSuffixes); + var unregistered = UnregisteredPrograms(settings.ProgramSources, settings.GetProgramExtensions()); programs = programs.Concat(unregistered); @@ -545,13 +545,13 @@ namespace Flow.Launcher.Plugin.Program.Programs if (settings.EnableRegistrySource) { - var appPaths = AppPathsPrograms(settings.CustomSuffixes); + var appPaths = AppPathsPrograms(settings.GetProgramExtensions()); autoIndexPrograms = autoIndexPrograms.Concat(appPaths); } if (settings.EnableStartMenuSource) { - var startMenu = StartMenuPrograms(settings.CustomSuffixes); + var startMenu = StartMenuPrograms(settings.GetProgramExtensions()); autoIndexPrograms = autoIndexPrograms.Concat(startMenu); } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 244c3818f..92335e38b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.Json.Serialization; namespace Flow.Launcher.Plugin.Program { @@ -10,8 +11,9 @@ namespace Flow.Launcher.Plugin.Program public DateTime LastIndexTime { get; set; } public List ProgramSources { get; set; } = new List(); public List DisabledProgramSources { get; set; } = new List(); - public string[] CustomSuffixes { get; set; } = { "appref-ms", "exe", "lnk" }; + public string[] CustomSuffixes { get; set; } = { }; + [JsonIgnore] public Dictionary BuiltinSuffixesStatus { get; set; } = new Dictionary{ { "exe", true }, { "appref-ms", true }, { "lnk", true } }; @@ -30,7 +32,16 @@ namespace Flow.Launcher.Plugin.Program } } - return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray(); + // todo: url + + if (UseCustomSuffixes) + { + return extensions.Concat(CustomSuffixes).DistinctBy(x => x.ToLower()).ToArray(); + } + else + { + return extensions.ToArray(); + } } public bool EnableStartMenuSource { get; set; } = true;