diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs index 469068b7a..fddb69f2a 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs @@ -27,9 +27,10 @@ namespace Flow.Launcher.Plugin.Program btnAdd.Content = _context.API.GetTranslation("flowlauncher_plugin_program_add"); } - public AddProgramSource(ProgramSource source, Settings settings) + public AddProgramSource(PluginInitContext context, ProgramSource source, Settings settings) { InitializeComponent(); + _context = context; _editing = source; _settings = settings; update = true; @@ -70,11 +71,24 @@ namespace Flow.Launcher.Plugin.Program _settings.ProgramSources.Insert(0, source); ProgramSetting.ProgramSettingDisplayList.Add(source); } + else + { + System.Windows.MessageBox.Show(_context.API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source")); + return; + } } else { if (!_editing.Location.Equals(path, System.StringComparison.OrdinalIgnoreCase)) { + if (ProgramSetting.ProgramSettingDisplayList + .Any(x => x.UniqueIdentifier.Equals(path, System.StringComparison.OrdinalIgnoreCase))) + { + // Check if the new location is used + // No need to check win32 or uwp, just override them + System.Windows.MessageBox.Show(_context.API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source")); + return; + } modified = true; _editing.Location = path; // Changes UniqueIdentifier internally } diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml index 2a166cc95..eacda542b 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml @@ -35,6 +35,7 @@ Please select a program source Are you sure you want to delete the selected program sources? + Another program source with the same location alreaday exists. Program Source Edit directory and status of this program source. diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 1ee18ae37..3daf1939f 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -160,7 +160,7 @@ namespace Flow.Launcher.Plugin.Program.Views } else { - var add = new AddProgramSource(selectedProgramSource, _settings); + var add = new AddProgramSource(context, selectedProgramSource, _settings); if (add.ShowDialog() ?? false) { if (selectedProgramSource.Enabled)