From 642ea4a290e09417fa1ad791e6c31abcd20517dd Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sun, 23 Oct 2022 22:09:22 +0800 Subject: [PATCH] bugfix --- .../Languages/en.xaml | 14 +++++----- .../ProgramSuffixes.xaml | 4 +-- .../ProgramSuffixes.xaml.cs | 28 +++++++++++++------ .../Flow.Launcher.Plugin.Program/Settings.cs | 10 +++---- .../SuffixesConverter.cs | 2 +- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index c7acb3184..2ccff4dd7 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -36,20 +36,20 @@ Are you sure you want to delete the selected program sources? OK - Program Plugin will only index files that end with the following file types. + Program Plugin will only index files with following suffixes. Successfully updated file suffixes File suffixes can't be empty Protocols can't be empty - Excutable Types - URL Types - Custom URL Types - Custom File Types + File Suffixes + URL Protocols + Custom URL Protocols + Custom File Suffixes - Insert file types what you want, Each file type should split by ';'. (ex>bat; py;) + Insert file suffixes you want to index. File types should be separated by ';'. (ex>bat;py) - Insert protocol types what you want, Each protocol type should split by ';'. (ex>steam; epic;) + Insert protocols in .url files you want to index. Protocols should be separated by ';'. (ex>ftp;netflix) Run As Different User diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml index b0b110207..9eabc6d0e 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml @@ -173,7 +173,7 @@ SuffixesStatus => _settings.BuiltinSuffixesStatus; - public Dictionary ProtocolsStatus => _settings.BuiltinProtocolsStatus; + private Settings _settings; + public Dictionary SuffixesStatus { get; set; } + public Dictionary ProtocolsStatus { get; set; } + public bool UseCustomSuffixes { get; set; } + public bool UseCustomProtocols { get; set; } public ProgramSuffixes(PluginInitContext context, Settings settings) { this.context = context; _settings = settings; + SuffixesStatus = new Dictionary(_settings.BuiltinSuffixesStatus); + ProtocolsStatus = new Dictionary(_settings.BuiltinProtocolsStatus); + UseCustomSuffixes = _settings.UseCustomSuffixes; + UseCustomProtocols = _settings.UseCustomProtocols; InitializeComponent(); - tbSuffixes.Text = string.Join(Settings.SuffixSeperator, _settings.CustomSuffixes); - tbProtocols.Text = string.Join(Settings.SuffixSeperator, _settings.CustomProtocols); + tbSuffixes.Text = string.Join(Settings.SuffixSeparator, _settings.CustomSuffixes); + tbProtocols.Text = string.Join(Settings.SuffixSeparator, _settings.CustomProtocols); } private void BtnCancel_OnClick(object sender, RoutedEventArgs e) @@ -27,17 +33,17 @@ namespace Flow.Launcher.Plugin.Program private void BtnAdd_OnClick(object sender, RoutedEventArgs e) { - var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); - var protocols = tbProtocols.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); + var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeparator, StringSplitOptions.RemoveEmptyEntries); + var protocols = tbProtocols.Text.Split(Settings.SuffixSeparator, StringSplitOptions.RemoveEmptyEntries); - if (suffixes.Length == 0 && _settings.UseCustomSuffixes) + if (suffixes.Length == 0 && UseCustomSuffixes) { string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); MessageBox.Show(warning); return; } - if (protocols.Length == 0 && _settings.UseCustomProtocols) + if (protocols.Length == 0 && UseCustomProtocols) { string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty"); MessageBox.Show(warning); @@ -46,6 +52,10 @@ namespace Flow.Launcher.Plugin.Program _settings.CustomSuffixes = suffixes; _settings.CustomProtocols = protocols; + _settings.BuiltinSuffixesStatus = new Dictionary(SuffixesStatus); + _settings.BuiltinProtocolsStatus = new Dictionary(ProtocolsStatus); + _settings.UseCustomSuffixes = UseCustomSuffixes; + _settings.UseCustomProtocols = UseCustomProtocols; DialogResult = true; } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs index 407cee969..f2f8afe46 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Settings.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Settings.cs @@ -21,11 +21,11 @@ namespace Flow.Launcher.Plugin.Program [JsonIgnore] public Dictionary BuiltinProtocolsStatus { get; set; } = new Dictionary{ - { $"steam://run/{SuffixSeperator}steam://rungameid/", true }, { "com.epicgames.launcher://apps/", true }, { $"http://{SuffixSeperator}https://", false} + { $"steam://run/{SuffixSeparator}steam://rungameid/", true }, { "com.epicgames.launcher://apps/", true }, { $"http://{SuffixSeparator}https://", false} }; - public bool UseCustomSuffixes = false; - public bool UseCustomProtocols = false; + public bool UseCustomSuffixes { get; set; } = false; + public bool UseCustomProtocols { get; set; } = false; public string[] GetSuffixes() { @@ -60,7 +60,7 @@ namespace Flow.Launcher.Plugin.Program { if (item.Value) { - var tmp = item.Key.Split(SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); + var tmp = item.Key.Split(SuffixSeparator, StringSplitOptions.RemoveEmptyEntries); foreach(var p in tmp) { protocols.Add(p); @@ -85,7 +85,7 @@ namespace Flow.Launcher.Plugin.Program public string CustomizedExplorer { get; set; } = Explorer; public string CustomizedArgs { get; set; } = ExplorerArgs; - internal const char SuffixSeperator = ';'; + internal const char SuffixSeparator = ';'; internal const string Explorer = "explorer"; diff --git a/Plugins/Flow.Launcher.Plugin.Program/SuffixesConverter.cs b/Plugins/Flow.Launcher.Plugin.Program/SuffixesConverter.cs index 28f0b1c25..ef93913a5 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/SuffixesConverter.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/SuffixesConverter.cs @@ -12,7 +12,7 @@ namespace Flow.Launcher.Plugin.Program var text = value as string[]; if (text != null) { - return string.Join(Settings.SuffixSeperator, text); + return string.Join(Settings.SuffixSeparator, text); } else {