Add option to modify preview hotkey

This commit is contained in:
Vic 2022-12-28 00:57:30 +08:00
parent 3ff7566daa
commit b243683332
3 changed files with 50 additions and 10 deletions

View file

@ -70,7 +70,7 @@
<system:String x:Key="ShouldUsePinyin">Search with Pinyin</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese.</system:String>
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press F1 to toggle preview.</system:String>
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow starts. Press {0} to toggle preview.</system:String>
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
<!-- Setting Plugin -->
@ -153,6 +153,8 @@
<system:String x:Key="hotkey">Hotkey</system:String>
<system:String x:Key="flowlauncherHotkey">Flow Launcher Hotkey</system:String>
<system:String x:Key="flowlauncherHotkeyToolTip">Enter shortcut to show/hide Flow Launcher.</system:String>
<system:String x:Key="previewHotkey">Preview Hotkey</system:String>
<system:String x:Key="previewHotkeyToolTip">Enter shortcut to show/hide preview in search window.</system:String>
<system:String x:Key="openResultModifiers">Open Result Modifier Key</system:String>
<system:String x:Key="openResultModifiersToolTip">Select a modifier key to open selected result via keyboard.</system:String>
<system:String x:Key="showOpenResultHotkey">Show Hotkey</system:String>

View file

@ -2415,8 +2415,33 @@
</Border>
</StackPanel>
<StackPanel Grid.Row="2">
<Border Margin="0,8,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource previewHotkey}"/>
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource previewHotkeyToolTip}" />
</StackPanel>
<flowlauncher:HotkeyControl
x:Name="PreviewHotkeyControl"
Grid.Row="0"
Grid.Column="2"
Width="300"
Height="35"
Margin="0,0,0,0"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right"
Loaded="OnPreviewHotkeyControlLoaded"
LostFocus="OnPreviewHotkeyControlFocusLost" />
<TextBlock Style="{StaticResource Glyph}">
&#xeda7;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
<Border
Grid.Row="2"
Grid.Row="3"
Margin="0,12,0,0"
Padding="0"
CornerRadius="5"
@ -2473,7 +2498,7 @@
</Border>
<TextBlock
Grid.Row="3"
Grid.Row="4"
Margin="0,10,12,10"
Padding="0,12,0,0"
VerticalAlignment="Center"
@ -2481,7 +2506,7 @@
Foreground="{DynamicResource Color05B}"
Text="{DynamicResource customQueryHotkey}" />
<ListView
Grid.Row="4"
Grid.Row="5"
MinHeight="160"
Margin="0,0,0,0"
Background="{DynamicResource Color02B}"
@ -2510,7 +2535,7 @@
</ListView.View>
</ListView>
<StackPanel
Grid.Row="5"
Grid.Row="6"
Margin="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
@ -2533,7 +2558,7 @@
</StackPanel>
<TextBlock
Grid.Row="6"
Grid.Row="7"
Margin="0,0,12,2"
Padding="0,12,0,0"
VerticalAlignment="Center"
@ -2542,7 +2567,7 @@
Text="{DynamicResource customQueryShortcut}" />
<ListView
Name="customShortcutView"
Grid.Row="7"
Grid.Row="8"
MinHeight="160"
Margin="0,6,0,0"
Background="{DynamicResource Color02B}"
@ -2571,7 +2596,7 @@
</ListView.View>
</ListView>
<StackPanel
Grid.Row="8"
Grid.Row="9"
Margin="0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
@ -2594,7 +2619,7 @@
</StackPanel>
<TextBlock
Grid.Row="9"
Grid.Row="10"
Margin="0,0,12,2"
Padding="0,12,0,0"
VerticalAlignment="Center"
@ -2602,7 +2627,7 @@
Foreground="{DynamicResource Color05B}"
Text="{DynamicResource builtinShortcuts}" />
<ListView
Grid.Row="10"
Grid.Row="11"
MinHeight="160"
Margin="0,6,0,20"
Background="{DynamicResource Color02B}"

View file

@ -131,6 +131,19 @@ namespace Flow.Launcher
}
}
private void OnPreviewHotkeyControlLoaded(object sender, RoutedEventArgs e)
{
_ = PreviewHotkeyControl.SetHotkeyAsync(settings.PreviewHotkey, false);
}
private void OnPreviewHotkeyControlFocusLost(object sender, RoutedEventArgs e)
{
if (PreviewHotkeyControl.CurrentHotkeyAvailable)
{
settings.PreviewHotkey = PreviewHotkeyControl.CurrentHotkey.ToString();
}
}
private void OnDeleteCustomHotkeyClick(object sender, RoutedEventArgs e)
{
var item = viewModel.SelectedCustomPluginHotkey;