Skip to content

Commit a7ed678

Browse files
committed
- Remove duplicate method.
1 parent 5aa86f3 commit a7ed678

File tree

3 files changed

+8
-46
lines changed

3 files changed

+8
-46
lines changed

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal static void Initialize(MainViewModel mainVM)
2121
mainViewModel = mainVM;
2222
settings = mainViewModel._settings;
2323

24-
SetHotkey(settings.Hotkey, OnHotkey);
24+
SetHotkey(settings.Hotkey, mainViewModel.OnHotkey);
2525
LoadCustomPluginHotkey();
2626
}
2727

@@ -55,46 +55,6 @@ internal static void RemoveHotkey(string hotkeyStr)
5555
}
5656
}
5757

58-
internal static void OnHotkey(object sender, HotkeyEventArgs e)
59-
{
60-
if (!ShouldIgnoreHotkeys())
61-
{
62-
UpdateLastQUeryMode();
63-
var overlayTask = Task.Delay(50).ContinueWith(_ => {
64-
mainViewModel.ToggleFlowLauncher();
65-
});
66-
e.Handled = true;
67-
}
68-
}
69-
70-
71-
/// <summary>
72-
/// Checks if Flow Launcher should ignore any hotkeys
73-
/// </summary>
74-
private static bool ShouldIgnoreHotkeys()
75-
{
76-
return settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
77-
}
78-
79-
private static void UpdateLastQUeryMode()
80-
{
81-
switch(settings.LastQueryMode)
82-
{
83-
case LastQueryMode.Empty:
84-
mainViewModel.ChangeQueryText(string.Empty);
85-
break;
86-
case LastQueryMode.Preserved:
87-
mainViewModel.LastQuerySelected = true;
88-
break;
89-
case LastQueryMode.Selected:
90-
mainViewModel.LastQuerySelected = false;
91-
break;
92-
default:
93-
throw new ArgumentException($"wrong LastQueryMode: <{settings.LastQueryMode}>");
94-
95-
}
96-
}
97-
9858
internal static void LoadCustomPluginHotkey()
9959
{
10060
if (settings.CustomPluginHotkeys == null)
@@ -110,7 +70,7 @@ internal static void SetCustomQueryHotkey(CustomPluginHotkey hotkey)
11070
{
11171
SetHotkey(hotkey.Hotkey, (s, e) =>
11272
{
113-
if (ShouldIgnoreHotkeys())
73+
if (mainViewModel.ShouldIgnoreHotkeys())
11474
return;
11575

11676
mainViewModel.MainWindowVisibility = Visibility.Visible;

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public partial class SettingWindow
2323
public readonly IPublicAPI API;
2424
private Settings settings;
2525
private SettingWindowViewModel viewModel;
26+
private static MainViewModel mainViewModel;
2627

2728
public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
2829
{
@@ -126,7 +127,7 @@ void OnHotkeyChanged(object sender, EventArgs e)
126127
if (HotkeyControl.CurrentHotkeyAvailable)
127128
{
128129

129-
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, HotKeyMapper.OnHotkey);
130+
HotKeyMapper.SetHotkey(HotkeyControl.CurrentHotkey, mainViewModel.OnHotkey);
130131
HotKeyMapper.RemoveHotkey(settings.Hotkey);
131132
settings.Hotkey = HotkeyControl.CurrentHotkey.ToString();
132133
}

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using System.Threading.Channels;
2222
using ISavable = Flow.Launcher.Plugin.ISavable;
2323
using System.Windows.Threading;
24+
using NHotkey;
25+
2426

2527
namespace Flow.Launcher.ViewModel
2628
{
@@ -368,7 +370,6 @@ private ResultsViewModel SelectedResults
368370
}
369371

370372
public Visibility ProgressBarVisibility { get; set; }
371-
372373
public Visibility MainWindowVisibility { get; set; }
373374

374375
public ICommand EscCommand { get; set; }
@@ -735,7 +736,7 @@ public void Hide()
735736

736737
#endregion
737738

738-
public void OnHotkey()
739+
public void OnHotkey(object sender, HotkeyEventArgs e)
739740
{
740741
if (!ShouldIgnoreHotkeys())
741742
{
@@ -765,7 +766,7 @@ public void OnHotkey()
765766
/// <summary>
766767
/// Checks if Flow Launcher should ignore any hotkeys
767768
/// </summary>
768-
private bool ShouldIgnoreHotkeys()
769+
public bool ShouldIgnoreHotkeys()
769770
{
770771
return _settings.IgnoreHotkeysOnFullscreen && WindowsInteropHelper.IsWindowFullscreen();
771772
}

0 commit comments

Comments
 (0)