Skip to content

Commit 20f849d

Browse files
committed
move CheckHotkeyAvailability to HotkeyMapper
1 parent 86804bc commit 20f849d

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Flow.Launcher.Helper;
33
using Flow.Launcher.Infrastructure.Hotkey;
44
using Flow.Launcher.Infrastructure.UserSettings;
5-
using NHotkey;
6-
using NHotkey.Wpf;
75
using System;
86
using System.Collections.ObjectModel;
97
using System.Linq;

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,24 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
113113
mainViewModel.ChangeQueryText(hotkey.ActionKeyword);
114114
});
115115
}
116+
117+
internal static bool CheckAvailability(HotkeyModel currentHotkey)
118+
{
119+
try
120+
{
121+
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", currentHotkey.CharKey, currentHotkey.ModifierKeys, (sender, e) => { });
122+
123+
return true;
124+
}
125+
catch
126+
{
127+
}
128+
finally
129+
{
130+
HotkeyManager.Current.Remove("HotkeyAvailabilityTest");
131+
}
132+
133+
return false;
134+
}
116135
}
117136
}

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using System.Windows.Controls;
55
using System.Windows.Input;
66
using System.Windows.Media;
7-
using NHotkey.Wpf;
87
using Flow.Launcher.Core.Resource;
8+
using Flow.Launcher.Helper;
99
using Flow.Launcher.Infrastructure.Hotkey;
1010
using Flow.Launcher.Plugin;
1111

@@ -92,24 +92,7 @@ public void SetHotkey(string keyStr, bool triggerValidate = true)
9292
SetHotkey(new HotkeyModel(keyStr), triggerValidate);
9393
}
9494

95-
private bool CheckHotkeyAvailability()
96-
{
97-
try
98-
{
99-
HotkeyManager.Current.AddOrReplace("HotkeyAvailabilityTest", CurrentHotkey.CharKey, CurrentHotkey.ModifierKeys, (sender, e) => { });
100-
101-
return true;
102-
}
103-
catch
104-
{
105-
}
106-
finally
107-
{
108-
HotkeyManager.Current.Remove("HotkeyAvailabilityTest");
109-
}
110-
111-
return false;
112-
}
95+
private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey);
11396

11497
public new bool IsFocused
11598
{

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
using System.Threading.Tasks.Dataflow;
77
using System.Windows;
88
using System.Windows.Input;
9-
using NHotkey;
10-
using NHotkey.Wpf;
119
using Flow.Launcher.Core.Plugin;
1210
using Flow.Launcher.Core.Resource;
1311
using Flow.Launcher.Helper;

0 commit comments

Comments
 (0)