diff --git a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs index 65652878f..ef9e9cf1d 100644 --- a/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs +++ b/Flow.Launcher.Infrastructure/DialogJump/DialogJump.cs @@ -455,7 +455,7 @@ namespace Flow.Launcher.Infrastructure.DialogJump #region Hotkey - public static void OnToggleHotkey(object sender, HotkeyEventArgs args) + public static void ToggleHotkey() { _ = Task.Run(async () => { diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 9d2e9ed9c..52d1ca9aa 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -23,13 +23,11 @@ internal static class HotKeyMapper _settings = Ioc.Default.GetService(); ChefKeysManager.RegisterHotkey(_settings.Hotkey, ToggleHotkey); - ChefKeysManager.Start(); - - // TODO: Resolve this if (_settings.EnableDialogJump) { - SetHotkey(_settings.DialogJumpHotkey, DialogJump.OnToggleHotkey); + ChefKeysManager.RegisterHotkey(_settings.DialogJumpHotkey, DialogJump.ToggleHotkey); } + ChefKeysManager.Start(); LoadCustomPluginHotkey(); } @@ -52,8 +50,8 @@ internal static class HotKeyMapper string.Format("|HotkeyMapper.SetHotkey|Error registering hotkey {2}: {0} \nStackTrace:{1}", e.Message, e.StackTrace, - hotkeyStr)); - string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr); + hotkey)); + string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkey); string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); App.API.ShowMsgBox(errorMsg, errorMsgTitle); } @@ -69,21 +67,16 @@ internal static class HotKeyMapper catch (Exception e) { App.API.LogError(ClassName, - string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey: {0} \nStackTrace:{1}", + string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey {2}: {0} \nStackTrace:{1}", e.Message, - e.StackTrace)); - string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkeyStr); + e.StackTrace, + hotkey)); + string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkey); string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); App.API.ShowMsgBox(errorMsg, errorMsgTitle); } } - private static void RemoveWithChefKeys(string hotkeyStr) - { - ChefKeysManager.UnregisterHotkey(hotkeyStr); - ChefKeysManager.Stop(); - } - internal static void LoadCustomPluginHotkey() { foreach (CustomPluginHotkey hotkey in _settings.CustomPluginHotkeys) diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs index eba782661..a36db0d03 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.xaml.cs @@ -1,4 +1,4 @@ -using System.Collections.ObjectModel; +using System.Collections.ObjectModel; using System.Globalization; using System.Threading.Tasks; using System.Windows; @@ -273,7 +273,7 @@ namespace Flow.Launcher private async Task OpenHotkeyDialogAsync() { - hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, HotkeySettings, IsWPFHotkeyControl, WindowTitle); + hotkeyControlDialog = new HotkeyControlDialog(Hotkey, DefaultHotkey, IsWPFHotkeyControl, WindowTitle); await hotkeyControlDialog.ShowAsync(); switch (hotkeyControlDialog.ResultType) { diff --git a/Flow.Launcher/HotkeyControlDialog.xaml.cs b/Flow.Launcher/HotkeyControlDialog.xaml.cs index dd7b15847..77ed9558f 100644 --- a/Flow.Launcher/HotkeyControlDialog.xaml.cs +++ b/Flow.Launcher/HotkeyControlDialog.xaml.cs @@ -64,8 +64,6 @@ public partial class HotkeyControlDialog : ContentDialog // This is a requirement to be set with current hotkey for the WPF hotkey control when saving without any new changes HotkeyToUpdate = new HotkeyModel(hotkey); - _hotkeySettings = hotkeySettings; - SetKeysToDisplay(CurrentHotkey); clearKeysOnFirstType = true; diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index b47b53654..fe51c232d 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -158,11 +158,12 @@ public partial class SettingsPaneGeneralViewModel : BaseModel DialogJump.SetupDialogJump(value); if (Settings.EnableDialogJump) { - HotKeyMapper.SetHotkey(new(Settings.DialogJumpHotkey), DialogJump.OnToggleHotkey); + // TODO: How can we parse the previousHotkey parameter here? + HotKeyMapper.RegisterHotkey(Settings.DialogJumpHotkey, string.Empty, DialogJump.ToggleHotkey); } else { - HotKeyMapper.RemoveHotkey(Settings.DialogJumpHotkey); + HotKeyMapper.UnregisterHotkey(Settings.DialogJumpHotkey); } } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs index db8e1e51d..d8c176375 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs @@ -40,7 +40,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel { if (Settings.EnableDialogJump) { - HotKeyMapper.SetHotkey(hotkey, DialogJump.OnToggleHotkey); + HotKeyMapper.RegisterHotkey(hotkey.HotkeyRaw, hotkey.PreviousHotkey, DialogJump.ToggleHotkey); } } @@ -92,7 +92,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var index = Settings.CustomPluginHotkeys.IndexOf(settingItem); Settings.CustomPluginHotkeys[index] = new CustomPluginHotkey(window.Hotkey, window.ActionKeyword); - HotKeyMapper.RemoveHotkey(settingItem.Hotkey); // remove origin hotkey + HotKeyMapper.UnregisterHotkey(settingItem.Hotkey); // remove origin hotkey HotKeyMapper.SetCustomQueryHotkey(Settings.CustomPluginHotkeys[index]); // set new hotkey } diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml index 1379f2372..efff4f87e 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneHotkey.xaml @@ -34,10 +34,10 @@ + WindowTitle="{DynamicResource flowlauncherHotkey}" />