Add AutoComplete Hotkey Item

This commit is contained in:
DB p 2024-04-13 18:47:37 +09:00
parent 2339941008
commit 22021c10ee
5 changed files with 62 additions and 6 deletions

View file

@ -20,6 +20,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool ShowOpenResultHotkey { get; set; } = true;
public double WindowSize { get; set; } = 580;
public string PreviewHotkey { get; set; } = $"F1";
public string AutoCompleteHotkey { get; set; } = $"F2";
public string Language
{

View file

@ -46,7 +46,6 @@
<Window.InputBindings>
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
<KeyBinding Key="F5" Command="{Binding ReloadPluginDataCommand}" />
<KeyBinding Key="Tab" Command="{Binding AutocompleteQueryCommand}" />
<KeyBinding
Key="Tab"
Command="{Binding AutocompleteQueryCommand}"
@ -188,12 +187,16 @@
Modifiers="Ctrl" />
<KeyBinding
Key="C"
Modifiers="Ctrl+Shift"
Command="{Binding CopyAlternativeCommand}" />
Command="{Binding CopyAlternativeCommand}"
Modifiers="Ctrl+Shift" />
<KeyBinding
Key="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
Command="{Binding TogglePreviewCommand}"
Modifiers="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
<KeyBinding
Key="{Binding AutoCompleteHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
Command="{Binding AutocompleteQueryCommand}"
Modifiers="{Binding AutoCompleteHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
</Window.InputBindings>
<Grid>
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">

View file

@ -2648,7 +2648,7 @@
Margin="0,0,16,0"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right"
DataContext="{Binding ToggleHotkeyViewModel}"/>
DataContext="{Binding ToggleHotkeyViewModel}" />
<TextBlock Style="{StaticResource Glyph}">
&#xeda7;
@ -2665,13 +2665,13 @@
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource previewHotkeyToolTip}" />
</StackPanel>
<flowlauncher:HotkeyControl
DataContext="{Binding PreviewHotkeyViewModel}"
x:Name="PreviewHotkeyControl"
Grid.Row="0"
Grid.Column="2"
Margin="0,0,16,0"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right" />
HorizontalContentAlignment="Right"
DataContext="{Binding PreviewHotkeyViewModel}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe8a1;
</TextBlock>
@ -2736,6 +2736,27 @@
</StackPanel>
</Border>
<StackPanel Grid.Row="2">
<Border Margin="0,16,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="Auto Complete Hotkey" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="Auto Complete Hotkey Subtitle" />
</StackPanel>
<flowlauncher:HotkeyControl
Grid.Row="0"
Grid.Column="2"
Margin="0,0,16,0"
HorizontalAlignment="Right"
HorizontalContentAlignment="Right"
DataContext="{Binding AutoCompleteHotkeyViewModel}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe765;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
<TextBlock
Grid.Row="4"
Margin="0,10,12,10"

View file

@ -80,6 +80,9 @@ namespace Flow.Launcher.ViewModel
case nameof(Settings.PreviewHotkey):
OnPropertyChanged(nameof(PreviewHotkey));
break;
case nameof(Settings.AutoCompleteHotkey):
OnPropertyChanged(nameof(AutoCompleteHotkey));
break;
}
};
@ -647,6 +650,27 @@ namespace Flow.Launcher.ViewModel
}
}
public string AutoCompleteHotkey
{
get
{
// TODO try to patch issue #1755
// Added in v1.14.0, remove after v1.16.0.
try
{
var converter = new KeyGestureConverter();
var key = (KeyGesture)converter.ConvertFromString(Settings.AutoCompleteHotkey);
}
catch (Exception e) when (e is NotSupportedException || e is InvalidEnumArgumentException)
{
Settings.AutoCompleteHotkey = "F2";
}
return Settings.AutoCompleteHotkey;
}
}
public string Image => Constant.QueryTextBoxIconImagePath;
public bool StartWithEnglishMode => Settings.AlwaysStartEn;

View file

@ -82,6 +82,12 @@ namespace Flow.Launcher.ViewModel
{
Settings.PreviewHotkey = hotkey.ToString();
});
AutoCompleteHotkeyViewModel =
new HotkeyControlViewModel(Settings.AutoCompleteHotkey, "F2", false, hotkey =>
{
Settings.AutoCompleteHotkey = hotkey.ToString();
});
}
public Settings Settings { get; set; }
@ -962,6 +968,7 @@ namespace Flow.Launcher.ViewModel
public HotkeyControlViewModel ToggleHotkeyViewModel { get; set; }
public HotkeyControlViewModel PreviewHotkeyViewModel { get; set; }
public HotkeyControlViewModel AutoCompleteHotkeyViewModel { get; set; }
private static DirectoryInfo GetLogDir(string version = "")
{