mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3354 from Jack251970/fix_custom_hotkey
Fix custom query hotkey settings issue
This commit is contained in:
commit
9d1e305ed8
2 changed files with 31 additions and 15 deletions
|
|
@ -58,9 +58,9 @@
|
|||
</Button>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="26,0,26,0">
|
||||
<StackPanel Margin="26 0 26 0">
|
||||
<TextBlock
|
||||
Margin="0,0,0,12"
|
||||
Margin="0 0 0 12"
|
||||
FontSize="20"
|
||||
FontWeight="SemiBold"
|
||||
Text="{DynamicResource customeQueryHotkeyTitle}"
|
||||
|
|
@ -72,10 +72,10 @@
|
|||
TextWrapping="WrapWithOverflow" />
|
||||
<Image
|
||||
Width="478"
|
||||
Margin="0,20,0,0"
|
||||
Margin="0 20 0 0"
|
||||
Source="/Images/illustration_01.png" />
|
||||
|
||||
<Grid Width="478" Margin="0,20,0,0">
|
||||
<Grid Width="478" Margin="0 20 0 0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
|
|
@ -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="CustomQueryHotkey" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
|
|
@ -123,8 +124,8 @@
|
|||
x:Name="btnTestActionKeyword"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,10,0"
|
||||
Padding="10,5,10,5"
|
||||
Margin="0 0 10 0"
|
||||
Padding="10 5 10 5"
|
||||
Click="BtnTestActionKeyword_OnClick"
|
||||
Content="{DynamicResource preview}" />
|
||||
</Grid>
|
||||
|
|
@ -132,21 +133,21 @@
|
|||
</StackPanel>
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Margin="0,14,0,0"
|
||||
Margin="0 14 0 0"
|
||||
Background="{DynamicResource PopupButtonAreaBGColor}"
|
||||
BorderBrush="{DynamicResource PopupButtonAreaBorderColor}"
|
||||
BorderThickness="0,1,0,0">
|
||||
BorderThickness="0 1 0 0">
|
||||
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
|
||||
<Button
|
||||
x:Name="btnCancel"
|
||||
MinWidth="140"
|
||||
Margin="10,0,5,0"
|
||||
Margin="10 0 5 0"
|
||||
Click="BtnCancel_OnClick"
|
||||
Content="{DynamicResource cancel}" />
|
||||
<Button
|
||||
x:Name="btnAdd"
|
||||
MinWidth="140"
|
||||
Margin="5,0,10,0"
|
||||
Margin="5 0 10 0"
|
||||
Click="btnAdd_OnClick"
|
||||
Style="{StaticResource AccentButtonStyle}">
|
||||
<TextBlock x:Name="lblAdd" Text="{DynamicResource done}" />
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ namespace Flow.Launcher
|
|||
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,10 @@ namespace Flow.Launcher
|
|||
|
||||
public enum HotkeyType
|
||||
{
|
||||
None,
|
||||
// Custom query hotkeys
|
||||
CustomQueryHotkey,
|
||||
// Settings hotkeys
|
||||
Hotkey,
|
||||
PreviewHotkey,
|
||||
OpenContextMenuHotkey,
|
||||
|
|
@ -115,12 +119,16 @@ namespace Flow.Launcher
|
|||
// and it will not construct settings instances twice
|
||||
private static readonly Settings _settings = Ioc.Default.GetRequiredService<Settings>();
|
||||
|
||||
private string hotkey = string.Empty;
|
||||
public string Hotkey
|
||||
{
|
||||
get
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
// Custom query hotkeys
|
||||
HotkeyType.CustomQueryHotkey => hotkey,
|
||||
// Settings hotkeys
|
||||
HotkeyType.Hotkey => _settings.Hotkey,
|
||||
HotkeyType.PreviewHotkey => _settings.PreviewHotkey,
|
||||
HotkeyType.OpenContextMenuHotkey => _settings.OpenContextMenuHotkey,
|
||||
|
|
@ -135,13 +143,20 @@ namespace Flow.Launcher
|
|||
HotkeyType.SelectPrevItemHotkey2 => _settings.SelectPrevItemHotkey2,
|
||||
HotkeyType.SelectNextItemHotkey => _settings.SelectNextItemHotkey,
|
||||
HotkeyType.SelectNextItemHotkey2 => _settings.SelectNextItemHotkey2,
|
||||
_ => string.Empty
|
||||
_ => throw new System.NotImplementedException("Hotkey type not set")
|
||||
};
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
// Custom query hotkeys
|
||||
case HotkeyType.CustomQueryHotkey:
|
||||
// We just need to store it in a local field
|
||||
// because we will save to settings in other place
|
||||
hotkey = value;
|
||||
break;
|
||||
// Settings hotkeys
|
||||
case HotkeyType.Hotkey:
|
||||
_settings.Hotkey = value;
|
||||
break;
|
||||
|
|
@ -185,7 +200,7 @@ namespace Flow.Launcher
|
|||
_settings.SelectNextItemHotkey2 = value;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
throw new System.NotImplementedException("Hotkey type not set");
|
||||
}
|
||||
|
||||
// After setting the hotkey, we need to refresh the interface
|
||||
|
|
|
|||
Loading…
Reference in a new issue