diff --git a/Flow.Launcher/HotkeyControlDialog.xaml b/Flow.Launcher/HotkeyControlDialog.xaml index 322f82366..1eed711f3 100644 --- a/Flow.Launcher/HotkeyControlDialog.xaml +++ b/Flow.Launcher/HotkeyControlDialog.xaml @@ -82,7 +82,8 @@ - - - - + + + + + + diff --git a/Flow.Launcher/HotkeyControlDialog.xaml.cs b/Flow.Launcher/HotkeyControlDialog.xaml.cs index afb7d4229..f4e04e38b 100644 --- a/Flow.Launcher/HotkeyControlDialog.xaml.cs +++ b/Flow.Launcher/HotkeyControlDialog.xaml.cs @@ -1,4 +1,5 @@ -using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Windows; using System.Windows.Input; using Flow.Launcher.Core.Resource; @@ -16,6 +17,28 @@ public partial class HotkeyControlDialog : ContentDialog public HotkeyModel CurrentHotkey { get; private set; } public ObservableCollection KeysToDisplay { get; } = new(); + private readonly Dictionary StaticHotkeys = new() + { + [new HotkeyModel("Escape")] = "", // TODO + [new HotkeyModel("F5")] = "ReloadPluginHotkey", + [new HotkeyModel("Alt+Home")] = "Select first result", // TODO + [new HotkeyModel("Alt+End")] = "Select last result", // TODO + [new HotkeyModel("Ctrl+R")] = "Requery", // TODO + [new HotkeyModel("Ctrl+H")] = "ToggleHistoryHotkey", + [new HotkeyModel("Ctrl+OemCloseBrackets")] = "QuickWidthHotkey", + [new HotkeyModel("Ctrl+OemOpenBrackets")] = "QuickWidthHotkey", + [new HotkeyModel("Ctrl+OemPlus")] = "QuickHeightHotkey", + [new HotkeyModel("Ctrl+OemMinus")] = "QuickHeightHotkey", + [new HotkeyModel("Ctrl+Shift+Enter")] = "HotkeyCtrlShiftEnterDesc", + [new HotkeyModel("Shift+Enter")] = "OpenContextMenuHotkey", + [new HotkeyModel("Enter")] = "HotkeyRunDesc", + [new HotkeyModel("Ctrl+Enter")] = "Open result", // TODO + [new HotkeyModel("Alt+Enter")] = "Open result", // TODO + // TODO D0-D9 But not here since they're not completely static, they can be Ctrl+D0-D9, Alt+D0-D9, or Ctrl+Alt+D0-D9 + [new HotkeyModel("Ctrl+F12")] = "ToggleGameModeHotkey", + [new HotkeyModel("Ctrl+Shift+C")] = "Copy alternative", // TODO + }; + public enum EResultType { Cancel, @@ -109,11 +132,20 @@ public partial class HotkeyControlDialog : ContentDialog if (tbMsg == null) return; + + if (StaticHotkeys.TryGetValue((HotkeyModel)hotkey, out var staticHotkey)) + { + ShowWarningAndDisableSaveButton( + string.Format( + InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableInUseStatic"), + InternationalizationManager.Instance.GetTranslation(staticHotkey) + ) + ); + return; + } if (!CheckHotkeyAvailability(hotkey.Value, true)) { - tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable"); - Alert.Visibility = Visibility.Visible; - SaveBtn.IsEnabled = false; + ShowWarningAndDisableSaveButton(InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable")); } else { @@ -122,6 +154,13 @@ public partial class HotkeyControlDialog : ContentDialog } } + private void ShowWarningAndDisableSaveButton(string message) + { + tbMsg.Text = message; + Alert.Visibility = Visibility.Visible; + SaveBtn.IsEnabled = false; + } + private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) => hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey); } diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml index b71e25e8f..25d618726 100644 --- a/Flow.Launcher/Languages/en.xaml +++ b/Flow.Launcher/Languages/en.xaml @@ -311,6 +311,8 @@ Update Binding Hotkey Current hotkey is unavailable. + This hotkey is unavailable because it is reserved for Flow Launcher's functionality: {0}. + This hotkey is unavailable because it is already used for {0}. Press the keys you want to use for this function.