mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix duplicates when editing
This commit is contained in:
parent
fc7ed31004
commit
473626f16e
2 changed files with 23 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using Flow.Launcher.Core.Resource;
|
||||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ namespace Flow.Launcher
|
|||
private bool update = false;
|
||||
public string Key { get; set; }
|
||||
public string Value { get; set; }
|
||||
public CustomShortcutModel ShortCut => (Key, Value);
|
||||
public CustomShortcutModel ShortCut;
|
||||
|
||||
public CustomShortcutSetting(Settings settings)
|
||||
{
|
||||
|
|
@ -24,6 +25,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
Key = shortcut.Key;
|
||||
Value = shortcut.Value;
|
||||
ShortCut = shortcut;
|
||||
_settings = settings;
|
||||
update = true;
|
||||
InitializeComponent();
|
||||
|
|
@ -37,17 +39,32 @@ namespace Flow.Launcher
|
|||
|
||||
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool modified = false;
|
||||
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
|
||||
return;
|
||||
}
|
||||
if (!update && (_settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)) || _settings.BuiltinShortcuts.Contains(new BuiltinShortcutModel(Key, Value, null))))
|
||||
if (!update)
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
|
||||
return;
|
||||
ShortCut = new CustomShortcutModel(Key, Value);
|
||||
if (_settings.CustomShortcuts.Any(x => x.Key == Key) || _settings.BuiltinShortcuts.Any(x => x.Key == Key))
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
|
||||
return;
|
||||
}
|
||||
modified = true;
|
||||
}
|
||||
DialogResult = true;
|
||||
else
|
||||
{
|
||||
if (ShortCut.Key != Key && _settings.CustomShortcuts.Any(x => x.Key == Key) || _settings.BuiltinShortcuts.Any(x => x.Key == Key))
|
||||
{
|
||||
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
|
||||
return;
|
||||
}
|
||||
modified = ShortCut.Key != Key || ShortCut.Value != Value;
|
||||
}
|
||||
DialogResult = modified;
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@
|
|||
<!-- Custom Query Shortcut Dialog -->
|
||||
<system:String x:Key="customeQueryShortcutTitle">Custom Query Shortcut</system:String>
|
||||
<system:String x:Key="customeQueryShortcutTips">Enter a shortcut that automatically expands to the specified query.</system:String>
|
||||
<system:String x:Key="dulplicateShortcut">Shortcut is dulplicate, please enter a new Shortcut or edit the existing one.</system:String>
|
||||
<system:String x:Key="duplicateShortcut">Shortcut already exists, please enter a new Shortcut or edit the existing one.</system:String>
|
||||
<system:String x:Key="emptyShortcut">Shortcut and/or its expansion is empty.</system:String>
|
||||
|
||||
<!-- Hotkey Control -->
|
||||
|
|
|
|||
Loading…
Reference in a new issue