11using Flow . Launcher . Core . Resource ;
2- using Flow . Launcher . ViewModel ;
32using System ;
43using System . Windows ;
54using System . Windows . Input ;
5+ using Flow . Launcher . SettingPages . ViewModels ;
66
77namespace Flow . Launcher
88{
99 public partial class CustomShortcutSetting : Window
1010 {
11+ private readonly SettingsPaneHotkeyViewModel _hotkeyVm ;
1112 public string Key { get ; set ; } = String . Empty ;
1213 public string Value { get ; set ; } = String . Empty ;
13- private string originalKey { get ; init ; } = null ;
14- private string originalValue { get ; init ; } = null ;
15- private bool update { get ; init ; } = false ;
14+ private string originalKey { get ; } = null ;
15+ private string originalValue { get ; } = null ;
16+ private bool update { get ; } = false ;
1617
17- public CustomShortcutSetting ( SettingWindowViewModel vm )
18+ public CustomShortcutSetting ( SettingsPaneHotkeyViewModel vm )
1819 {
20+ _hotkeyVm = vm ;
1921 InitializeComponent ( ) ;
2022 }
2123
22- public CustomShortcutSetting ( string key , string value )
24+ public CustomShortcutSetting ( string key , string value , SettingsPaneHotkeyViewModel vm )
2325 {
2426 Key = key ;
2527 Value = value ;
2628 originalKey = key ;
2729 originalValue = value ;
2830 update = true ;
31+ _hotkeyVm = vm ;
2932 InitializeComponent ( ) ;
3033 }
3134
@@ -43,7 +46,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
4346 return ;
4447 }
4548 // Check if key is modified or adding a new one
46- if ( ( update && originalKey != Key ) || ! update )
49+ if ( ( ( update && originalKey != Key ) || ! update ) && _hotkeyVm . DoesShortcutExist ( Key ) )
4750 {
4851 MessageBox . Show ( InternationalizationManager . Instance . GetTranslation ( "duplicateShortcut" ) ) ;
4952 return ;
0 commit comments