mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add check for invalid query shortcuts
This commit is contained in:
parent
d0fc344b54
commit
c4ce8fe580
3 changed files with 13 additions and 2 deletions
|
|
@ -43,12 +43,14 @@ namespace Flow.Launcher
|
|||
App.API.ShowMsgBox(App.API.GetTranslation("emptyShortcut"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if key is modified or adding a new one
|
||||
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
|
||||
{
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("duplicateShortcut"));
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = !update || originalKey != Key || originalValue != Value;
|
||||
Close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,6 +446,7 @@
|
|||
</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>
|
||||
<system:String x:Key="invalidShortcut">Shortcut is invalid</system:String>
|
||||
|
||||
<!-- Common Action -->
|
||||
<system:String x:Key="commonSave">Save</system:String>
|
||||
|
|
|
|||
|
|
@ -107,10 +107,18 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel
|
|||
return;
|
||||
}
|
||||
|
||||
var window = new CustomShortcutSetting(item.Key, item.Value, this);
|
||||
var settingItem = Settings.CustomShortcuts.FirstOrDefault(o =>
|
||||
o.Key == item.Key && o.Value == item.Value);
|
||||
if (settingItem == null)
|
||||
{
|
||||
App.API.ShowMsgBox(App.API.GetTranslation("invalidShortcut"));
|
||||
return;
|
||||
}
|
||||
|
||||
var window = new CustomShortcutSetting(settingItem.Key, settingItem.Value, this);
|
||||
if (window.ShowDialog() is not true) return;
|
||||
|
||||
var index = Settings.CustomShortcuts.IndexOf(item);
|
||||
var index = Settings.CustomShortcuts.IndexOf(settingItem);
|
||||
Settings.CustomShortcuts[index] = new CustomShortcutModel(window.Key, window.Value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue