From b1ec0bda613224fe8f3587080f04cdc74b211ccc Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 17 Mar 2025 11:01:54 +0800 Subject: [PATCH 1/5] Fix custom query hotkey settings issue --- Flow.Launcher/HotkeyControl.xaml.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs index 273d18e3f5d..8fdaf775a8d 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.xaml.cs @@ -84,7 +84,7 @@ public ICommand? ChangeHotkey nameof(Type), typeof(HotkeyType), typeof(HotkeyControl), - new FrameworkPropertyMetadata(HotkeyType.Hotkey, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged) + new FrameworkPropertyMetadata(HotkeyType.None, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged) ); public HotkeyType Type @@ -95,6 +95,9 @@ public HotkeyType Type public enum HotkeyType { + // Custom hotkeys + None, // Used for getting hotkey from dialog result + // Settings hotkeys Hotkey, PreviewHotkey, OpenContextMenuHotkey, @@ -115,12 +118,16 @@ public enum HotkeyType // and it will not construct settings instances twice private static readonly Settings _settings = Ioc.Default.GetRequiredService(); + private string hotkey = string.Empty; public string Hotkey { get { return Type switch { + // Custom hotkeys + HotkeyType.None => hotkey, + // Settings hotkeys HotkeyType.Hotkey => _settings.Hotkey, HotkeyType.PreviewHotkey => _settings.PreviewHotkey, HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey, @@ -135,13 +142,18 @@ public string Hotkey HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2, HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey, HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2, - _ => string.Empty + _ => throw new System.NotImplementedException("Hotkey type not setted") }; } set { switch (Type) { + // Custom hotkeys + case HotkeyType.None: + hotkey = value; + break; + // Settings hotkeys case HotkeyType.Hotkey: _settings.Hotkey = value; break; @@ -185,7 +197,7 @@ public string Hotkey _settings.SelectNextItemHotkey2 = value; break; default: - return; + throw new System.NotImplementedException("Hotkey type not setted"); } // After setting the hotkey, we need to refresh the interface From 2c5fcf7b9f70e86a4fb253baddd71ddade50b840 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 17 Mar 2025 11:05:47 +0800 Subject: [PATCH 2/5] Add hotkey control type & format xaml --- Flow.Launcher/CustomQueryHotkeySetting.xaml | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml b/Flow.Launcher/CustomQueryHotkeySetting.xaml index ccf4de8706b..3ddd41bd6fd 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml @@ -58,9 +58,9 @@ - + - + @@ -99,11 +99,12 @@ Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" - Margin="10,0,10,0" + Margin="10 0 10 0" HorizontalAlignment="Left" VerticalAlignment="Center" HorizontalContentAlignment="Left" - DefaultHotkey="" /> + DefaultHotkey="" + Type="None" /> @@ -132,21 +133,21 @@ + BorderThickness="0 1 0 0">