1
1
using Flow . Launcher . Core . Resource ;
2
- using Flow . Launcher . ViewModel ;
3
2
using System ;
4
3
using System . Windows ;
5
4
using System . Windows . Input ;
5
+ using Flow . Launcher . SettingPages . ViewModels ;
6
6
7
7
namespace Flow . Launcher
8
8
{
9
9
public partial class CustomShortcutSetting : Window
10
10
{
11
+ private readonly SettingsPaneHotkeyViewModel _hotkeyVm ;
11
12
public string Key { get ; set ; } = String . Empty ;
12
13
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 ;
16
17
17
- public CustomShortcutSetting ( SettingWindowViewModel vm )
18
+ public CustomShortcutSetting ( SettingsPaneHotkeyViewModel vm )
18
19
{
20
+ _hotkeyVm = vm ;
19
21
InitializeComponent ( ) ;
20
22
}
21
23
22
- public CustomShortcutSetting ( string key , string value )
24
+ public CustomShortcutSetting ( string key , string value , SettingsPaneHotkeyViewModel vm )
23
25
{
24
26
Key = key ;
25
27
Value = value ;
26
28
originalKey = key ;
27
29
originalValue = value ;
28
30
update = true ;
31
+ _hotkeyVm = vm ;
29
32
InitializeComponent ( ) ;
30
33
}
31
34
@@ -43,7 +46,7 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
43
46
return ;
44
47
}
45
48
// 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 ) )
47
50
{
48
51
MessageBox . Show ( InternationalizationManager . Instance . GetTranslation ( "duplicateShortcut" ) ) ;
49
52
return ;
0 commit comments