Skip to content

Commit 4232ef7

Browse files
Merge pull request #1508 from VictoriousRaptor/Fix-1476
Fix #1476
2 parents e17ec6a + 171ac07 commit 4232ef7

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343

4444
<system:String x:Key="flowlauncher_plugin_program_suffixes_excutable_types">File Suffixes</system:String>
4545
<system:String x:Key="flowlauncher_plugin_program_suffixes_URL_types">URL Protocols</system:String>
46+
<system:String x:Key="flowlauncher_plugin_program_suffixes_URL_steam">Steam Games</system:String>
47+
<system:String x:Key="flowlauncher_plugin_program_suffixes_URL_epic">Epic Games</system:String>
48+
<system:String x:Key="flowlauncher_plugin_program_suffixes_URL_http">Http/Https</system:String>
4649
<system:String x:Key="flowlauncher_plugin_program_suffixes_custom_urls">Custom URL Protocols</system:String>
4750
<system:String x:Key="flowlauncher_plugin_program_suffixes_custom_file_types">Custom File Suffixes</system:String>
4851
<system:String x:Key="flowlauncher_plugin_program_suffixes_tooltip">

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@
189189
FontSize="16"
190190
FontWeight="SemiBold"
191191
Text="{DynamicResource flowlauncher_plugin_program_suffixes_URL_types}" />
192-
<CheckBox Name="steam" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[steam]}">Steam Games</CheckBox>
193-
<CheckBox Name="epic" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[epic]}">Epic Games</CheckBox>
194-
<CheckBox Name="http" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[http]}">Http/Https</CheckBox>
192+
<CheckBox Name="steam" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[steam]}" Content="{DynamicResource flowlauncher_plugin_program_suffixes_URL_steam}"></CheckBox>
193+
<CheckBox Name="epic" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[epic]}" Content="{DynamicResource flowlauncher_plugin_program_suffixes_URL_epic}"></CheckBox>
194+
<CheckBox Name="http" Margin="10,0,0,0" IsChecked="{Binding ProtocolsStatus[http]}" Content="{DynamicResource flowlauncher_plugin_program_suffixes_URL_http}"></CheckBox>
195195
<CheckBox
196196
Name="CustomProtocol"
197197
Margin="10,0,0,0"

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Text.Json.Serialization;
6+
using Windows.Foundation.Metadata;
67

78
namespace Flow.Launcher.Plugin.Program
89
{
@@ -11,7 +12,10 @@ public class Settings
1112
public DateTime LastIndexTime { get; set; }
1213
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
1314
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
14-
public string[] CustomSuffixes { get; set; } = Array.Empty<string>();
15+
16+
[Obsolete, JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
17+
public string[] ProgramSuffixes { get; set; } = null;
18+
public string[] CustomSuffixes { get; set; } = Array.Empty<string>(); // Custom suffixes only
1519
public string[] CustomProtocols { get; set; } = Array.Empty<string>();
1620

1721
public Dictionary<string, bool> BuiltinSuffixesStatus { get; set; } = new Dictionary<string, bool>{
@@ -32,6 +36,7 @@ public class Settings
3236

3337
public string[] GetSuffixes()
3438
{
39+
RemoveRedundantSuffixes();
3540
List<string> extensions = new List<string>();
3641
foreach (var item in BuiltinSuffixesStatus)
3742
{
@@ -84,6 +89,24 @@ public string[] GetProtocols()
8489
}
8590
}
8691

92+
private void RemoveRedundantSuffixes()
93+
{
94+
// Migrate to new settings
95+
// CustomSuffixes no longer contains custom suffixes
96+
// users has tweaked the settings
97+
// or this function has been executed once
98+
if (UseCustomSuffixes == true || ProgramSuffixes == null)
99+
return;
100+
var suffixes = ProgramSuffixes.ToList();
101+
foreach(var item in BuiltinSuffixesStatus)
102+
{
103+
suffixes.Remove(item.Key);
104+
}
105+
CustomSuffixes = suffixes.ToArray(); // Custom suffixes
106+
UseCustomSuffixes = CustomSuffixes.Length != 0; // Search custom suffixes or not
107+
ProgramSuffixes = null;
108+
}
109+
87110
public bool EnableStartMenuSource { get; set; } = true;
88111
public bool EnableDescription { get; set; } = false;
89112
public bool HideAppsPath { get; set; } = true;

0 commit comments

Comments
 (0)