From 1c8a8d0fc695888cff135937ded97e7c78b293cc Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 2 Jul 2025 14:04:02 +0800 Subject: [PATCH] Code quality --- Flow.Launcher/Helper/HotKeyMapper.cs | 58 +++++++++++++++------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 816ad23eb..bebfa16d5 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -217,33 +217,6 @@ internal static class HotKeyMapper } } - private static void ChangeRegisteredHotkey(RegisteredHotkeyType registeredType, string newHotkeyStr) - { - var newHotkey = new HotkeyModel(newHotkeyStr); - ChangeRegisteredHotkey(registeredType, newHotkey); - } - - private static void ChangeRegisteredHotkey(RegisteredHotkeyType registeredType, HotkeyModel newHotkey) - { - // Find the old registered hotkey data item - var registeredHotkeyData = _settings.RegisteredHotkeys.FirstOrDefault(h => h.RegisteredType == registeredType); - - // If it is not found, return - if (registeredHotkeyData == null) - { - return; - } - - // Remove the old hotkey - RemoveHotkey(registeredHotkeyData); - - // Update the hotkey string - registeredHotkeyData.Hotkey = newHotkey; - - // Set the new hotkey - SetHotkey(registeredHotkeyData); - } - #endregion // TODO: Deprecated @@ -509,6 +482,37 @@ internal static class HotKeyMapper #endregion + #region Hotkey Changing + + private static void ChangeRegisteredHotkey(RegisteredHotkeyType registeredType, string newHotkeyStr) + { + var newHotkey = new HotkeyModel(newHotkeyStr); + ChangeRegisteredHotkey(registeredType, newHotkey); + } + + private static void ChangeRegisteredHotkey(RegisteredHotkeyType registeredType, HotkeyModel newHotkey) + { + // Find the old registered hotkey data item + var registeredHotkeyData = _settings.RegisteredHotkeys.FirstOrDefault(h => h.RegisteredType == registeredType); + + // If it is not found, return + if (registeredHotkeyData == null) + { + return; + } + + // Remove the old hotkey + RemoveHotkey(registeredHotkeyData); + + // Update the hotkey string + registeredHotkeyData.Hotkey = newHotkey; + + // Set the new hotkey + SetHotkey(registeredHotkeyData); + } + + #endregion + #region Commands private static RelayCommand _customQueryHotkeyCommand;