Skip to content
1 change: 1 addition & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public CustomBrowserViewModel CustomBrowser
/// </summary>
public bool ShouldUsePinyin { get; set; } = false;
public bool AlwaysPreview { get; set; } = false;
public bool AlwaysStartEn { get; set; } = false;

[JsonInclude, JsonConverter(typeof(JsonStringEnumConverter))]
public SearchPrecisionScore QuerySearchPrecision { get; private set; } = SearchPrecisionScore.Regular;
Expand Down
55 changes: 55 additions & 0 deletions Flow.Launcher/Converters/BoolToIMEConversionModeConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Input;

namespace Flow.Launcher.Converters
{
internal class BoolToIMEConversionModeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool v)
{
if (v)
{
return ImeConversionModeValues.Alphanumeric;
}
else
{
return ImeConversionModeValues.DoNotCare;
}
}
return ImeConversionModeValues.DoNotCare;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}

internal class BoolToIMEStateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool v)
{
if (v)
{
return InputMethodState.Off;
}
else
{
return InputMethodState.DoNotCare;
}
}
return InputMethodState.DoNotCare;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
2 changes: 2 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<system:String x:Key="defaultFileManagerToolTip">Select the file manager to use when opening the folder.</system:String>
<system:String x:Key="defaultBrowser">Default Web Browser</system:String>
<system:String x:Key="defaultBrowserToolTip">Setting for New Tab, New Window, Private Mode.</system:String>
<system:String x:Key="typingStartEn">Always Start Typing in English Mode</system:String>
<system:String x:Key="typingStartEnTooltip">Temporarily change your input method to English mode when activating Flow.</system:String>
<system:String x:Key="pythonDirectory">Python Directory</system:String>
<system:String x:Key="autoUpdates">Auto Update</system:String>
<system:String x:Key="selectPythonDirectory">Select</system:String>
Expand Down
6 changes: 6 additions & 0 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
Name="FlowMainWindow"
Title="Flow Launcher"
MinWidth="{Binding MainWindowWidth, Mode=OneWay}"
Expand Down Expand Up @@ -37,6 +38,8 @@
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter"/>
</Window.Resources>
<Window.InputBindings>
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
Expand Down Expand Up @@ -204,6 +207,8 @@
PreviewKeyUp="QueryTextBox_KeyUp"
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
Visibility="Visible">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
Expand Down Expand Up @@ -244,6 +249,7 @@
</TextBox>
</Grid>
</Border>

<StackPanel
x:Name="ClockPanel"
IsHitTestVisible="False"
Expand Down
12 changes: 1 addition & 11 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,10 @@
using System.Windows.Media;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Plugin.SharedCommands;
using System.Text;
using DataObject = System.Windows.DataObject;
using System.Diagnostics;
using Microsoft.AspNetCore.Http;
using System.IO;
using System.Windows.Threading;
using System.Windows.Data;
using ModernWpf.Controls;
using System.Drawing;
using System.Windows.Forms.Design.Behavior;
using System.Security.Cryptography;
using System.Runtime.CompilerServices;
using Microsoft.VisualBasic.Devices;
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
using Key = System.Windows.Input.Key;

namespace Flow.Launcher
{
Expand Down
63 changes: 43 additions & 20 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -737,30 +737,14 @@
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource AlwaysPreview}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AlwaysPreviewToolTip}" />
</StackPanel>
<CheckBox
IsChecked="{Binding Settings.AlwaysPreview}"
Style="{DynamicResource SideControlCheckBox}"
ToolTip="{DynamicResource AlwaysPreviewToolTip}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe8a1;
</TextBlock>
</ItemsControl>
</Border>

<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource ShouldUsePinyin}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource ShouldUsePinyinToolTip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Column="2"
FocusVisualMargin="5"
IsOn="{Binding Settings.ShouldUsePinyin}"
IsOn="{Binding Settings.AlwaysPreview}"
Style="{DynamicResource SideToggleSwitch}"
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
ToolTip="{DynamicResource AlwaysPreviewToolTip}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe98a;
&#xe8a1;
</TextBlock>
</ItemsControl>
</Border>
Expand Down Expand Up @@ -943,13 +927,52 @@
Text="{Binding Settings.PluginSettings.PythonDirectory, TargetNullValue='No Setting'}" />
<Button
Height="34"
Margin="10,10,18,10"
Margin="10,0,18,0"
Click="OnSelectPythonDirectoryClick"
Content="{DynamicResource selectPythonDirectory}" />
</StackPanel>
</ItemsControl>
</Border>

<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Style="{DynamicResource SettingTitleLabel}"
Text="{DynamicResource typingStartEn}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource typingStartEnTooltip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Column="2"
FocusVisualMargin="5"
IsOn="{Binding Settings.AlwaysStartEn}"
Style="{DynamicResource SideToggleSwitch}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe8d3;
</TextBlock>
</ItemsControl>
</Border>

<Border Margin="0,4,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource ShouldUsePinyin}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource ShouldUsePinyinToolTip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Column="2"
FocusVisualMargin="5"
IsOn="{Binding Settings.ShouldUsePinyin}"
Style="{DynamicResource SideToggleSwitch}"
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
<TextBlock Style="{StaticResource Glyph}">
&#xe98a;
</TextBlock>
</ItemsControl>
</Border>

<Border Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
Expand Down
5 changes: 5 additions & 0 deletions Flow.Launcher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public MainViewModel(Settings settings)
case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(MainWindowWidth));
break;
case nameof(Settings.AlwaysStartEn):
OnPropertyChanged(nameof(StartWithEnglishMode));
break;
}
};

Expand Down Expand Up @@ -514,6 +517,8 @@ public double MainWindowWidth

public string Image => Constant.QueryTextBoxIconImagePath;

public bool StartWithEnglishMode => Settings.AlwaysStartEn;

#endregion

public void Query()
Expand Down