Skip to content

Commit 9d1e305

Browse files
authored
Merge pull request #3354 from Jack251970/fix_custom_hotkey
Fix custom query hotkey settings issue
2 parents eb2a24d + 497ac91 commit 9d1e305

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

Flow.Launcher/CustomQueryHotkeySetting.xaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
</Button>
5959
</Grid>
6060
</StackPanel>
61-
<StackPanel Margin="26,0,26,0">
61+
<StackPanel Margin="26 0 26 0">
6262
<TextBlock
63-
Margin="0,0,0,12"
63+
Margin="0 0 0 12"
6464
FontSize="20"
6565
FontWeight="SemiBold"
6666
Text="{DynamicResource customeQueryHotkeyTitle}"
@@ -72,10 +72,10 @@
7272
TextWrapping="WrapWithOverflow" />
7373
<Image
7474
Width="478"
75-
Margin="0,20,0,0"
75+
Margin="0 20 0 0"
7676
Source="/Images/illustration_01.png" />
7777

78-
<Grid Width="478" Margin="0,20,0,0">
78+
<Grid Width="478" Margin="0 20 0 0">
7979
<Grid.RowDefinitions>
8080
<RowDefinition />
8181
<RowDefinition />
@@ -99,11 +99,12 @@
9999
Grid.Row="0"
100100
Grid.Column="1"
101101
Grid.ColumnSpan="2"
102-
Margin="10,0,10,0"
102+
Margin="10 0 10 0"
103103
HorizontalAlignment="Left"
104104
VerticalAlignment="Center"
105105
HorizontalContentAlignment="Left"
106-
DefaultHotkey="" />
106+
DefaultHotkey=""
107+
Type="CustomQueryHotkey" />
107108
<TextBlock
108109
Grid.Row="1"
109110
Grid.Column="0"
@@ -123,30 +124,30 @@
123124
x:Name="btnTestActionKeyword"
124125
Grid.Row="1"
125126
Grid.Column="2"
126-
Margin="0,0,10,0"
127-
Padding="10,5,10,5"
127+
Margin="0 0 10 0"
128+
Padding="10 5 10 5"
128129
Click="BtnTestActionKeyword_OnClick"
129130
Content="{DynamicResource preview}" />
130131
</Grid>
131132
</StackPanel>
132133
</StackPanel>
133134
<Border
134135
Grid.Row="1"
135-
Margin="0,14,0,0"
136+
Margin="0 14 0 0"
136137
Background="{DynamicResource PopupButtonAreaBGColor}"
137138
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
138-
BorderThickness="0,1,0,0">
139+
BorderThickness="0 1 0 0">
139140
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
140141
<Button
141142
x:Name="btnCancel"
142143
MinWidth="140"
143-
Margin="10,0,5,0"
144+
Margin="10 0 5 0"
144145
Click="BtnCancel_OnClick"
145146
Content="{DynamicResource cancel}" />
146147
<Button
147148
x:Name="btnAdd"
148149
MinWidth="140"
149-
Margin="5,0,10,0"
150+
Margin="5 0 10 0"
150151
Click="btnAdd_OnClick"
151152
Style="{StaticResource AccentButtonStyle}">
152153
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />

Flow.Launcher/HotkeyControl.xaml.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ICommand? ChangeHotkey
8484
nameof(Type),
8585
typeof(HotkeyType),
8686
typeof(HotkeyControl),
87-
new FrameworkPropertyMetadata(HotkeyType.Hotkey, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
87+
new FrameworkPropertyMetadata(HotkeyType.None, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnHotkeyChanged)
8888
);
8989

9090
public HotkeyType Type
@@ -95,6 +95,10 @@ public HotkeyType Type
9595

9696
public enum HotkeyType
9797
{
98+
None,
99+
// Custom query hotkeys
100+
CustomQueryHotkey,
101+
// Settings hotkeys
98102
Hotkey,
99103
PreviewHotkey,
100104
OpenContextMenuHotkey,
@@ -115,12 +119,16 @@ public enum HotkeyType
115119
// and it will not construct settings instances twice
116120
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
117121

122+
private string hotkey = string.Empty;
118123
public string Hotkey
119124
{
120125
get
121126
{
122127
return Type switch
123128
{
129+
// Custom query hotkeys
130+
HotkeyType.CustomQueryHotkey => hotkey,
131+
// Settings hotkeys
124132
HotkeyType.Hotkey => _settings.Hotkey,
125133
HotkeyType.PreviewHotkey => _settings.PreviewHotkey,
126134
HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey,
@@ -135,13 +143,20 @@ public string Hotkey
135143
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
136144
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
137145
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
138-
_ => string.Empty
146+
_ => throw new System.NotImplementedException("Hotkey type not set")
139147
};
140148
}
141149
set
142150
{
143151
switch (Type)
144152
{
153+
// Custom query hotkeys
154+
case HotkeyType.CustomQueryHotkey:
155+
// We just need to store it in a local field
156+
// because we will save to settings in other place
157+
hotkey = value;
158+
break;
159+
// Settings hotkeys
145160
case HotkeyType.Hotkey:
146161
_settings.Hotkey = value;
147162
break;
@@ -185,7 +200,7 @@ public string Hotkey
185200
_settings.SelectNextItemHotkey2 = value;
186201
break;
187202
default:
188-
return;
203+
throw new System.NotImplementedException("Hotkey type not set");
189204
}
190205

191206
// After setting the hotkey, we need to refresh the interface

0 commit comments

Comments
 (0)