diff --git a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs index 65652878f..0c211eb90 100644 --- a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs +++ b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs @@ -9,10 +9,10 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.DialogJump.Models; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; -using NHotkey; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.UI.Accessibility; +using CommunityToolkit.Mvvm.Input; namespace Flow.Launcher.Infrastructure.DialogJump { @@ -455,7 +455,10 @@ namespace Flow.Launcher.Infrastructure.DialogJump #region Hotkey - public static void OnToggleHotkey(object sender, HotkeyEventArgs args) + private static RelayCommand _dialogJumpCommand; + public static IRelayCommand DialogJumpCommand => _dialogJumpCommand ??= new RelayCommand(OnToggleHotkey); + + private static void OnToggleHotkey() { _ = Task.Run(async () => { diff --git a/Flow.Launcher.Infrastructure/Hotkey/RegisteredHotkeyData.cs b/Flow.Launcher.Infrastructure/Hotkey/RegisteredHotkeyData.cs index a1b577ea7..8459798ba 100644 --- a/Flow.Launcher.Infrastructure/Hotkey/RegisteredHotkeyData.cs +++ b/Flow.Launcher.Infrastructure/Hotkey/RegisteredHotkeyData.cs @@ -285,6 +285,7 @@ public enum RegisteredHotkeyType OpenResultN10, Toggle, + DialogJump, Preview, AutoComplete, diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index e692f5131..08e4194a4 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -9,6 +9,7 @@ using ChefKeys; using CommunityToolkit.Mvvm.DependencyInjection; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core.Plugin; +using Flow.Launcher.Infrastructure.DialogJump; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; @@ -82,6 +83,7 @@ internal static class HotKeyMapper // Flow Launcher global hotkeys new(RegisteredHotkeyType.Toggle, HotkeyType.Global, _settings.Hotkey, "flowlauncherHotkey", _mainViewModel.CheckAndToggleFlowLauncherCommand, null, () => _settings.Hotkey = ""), + new(RegisteredHotkeyType.DialogJump, HotkeyType.Global, _settings.DialogJumpHotkey, "dialogJumpHotkey", DialogJump.DialogJumpCommand, null, () => _settings.DialogJumpHotkey = ""), // Flow Launcher window hotkeys new(RegisteredHotkeyType.Preview, HotkeyType.SearchWindow, _settings.PreviewHotkey, "previewHotkey", _mainViewModel.TogglePreviewCommand, null, () => _settings.PreviewHotkey = ""), @@ -155,6 +157,9 @@ internal static class HotKeyMapper case nameof(_settings.Hotkey): ChangeRegisteredHotkey(RegisteredHotkeyType.Toggle, _settings.Hotkey); break; + case nameof(_settings.DialogJumpHotkey): + ChangeRegisteredHotkey(RegisteredHotkeyType.DialogJump, _settings.DialogJumpHotkey); + break; // Flow Launcher window hotkeys case nameof(_settings.PreviewHotkey): diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index 21444ccee..de3147bf5 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; @@ -156,14 +156,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel { Settings.EnableDialogJump = value; DialogJump.SetupDialogJump(value); - if (Settings.EnableDialogJump) - { - HotKeyMapper.SetHotkey(new(Settings.DialogJumpHotkey), DialogJump.OnToggleHotkey); - } - else - { - HotKeyMapper.RemoveHotkey(Settings.DialogJumpHotkey); - } } } }