Skip to content

Commit 3ae2ede

Browse files
Merge pull request #1693 from onesounds/LanguageStart
Always Start in English Layout
2 parents c428df0 + 9d59933 commit 3ae2ede

File tree

7 files changed

+113
-31
lines changed

7 files changed

+113
-31
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ public CustomBrowserViewModel CustomBrowser
147147
/// </summary>
148148
public bool ShouldUsePinyin { get; set; } = false;
149149
public bool AlwaysPreview { get; set; } = false;
150+
public bool AlwaysStartEn { get; set; } = false;
150151

151152
[JsonInclude, JsonConverter(typeof(JsonStringEnumConverter))]
152153
public SearchPrecisionScore QuerySearchPrecision { get; private set; } = SearchPrecisionScore.Regular;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows.Data;
4+
using System.Windows.Input;
5+
6+
namespace Flow.Launcher.Converters
7+
{
8+
internal class BoolToIMEConversionModeConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
if (value is bool v)
13+
{
14+
if (v)
15+
{
16+
return ImeConversionModeValues.Alphanumeric;
17+
}
18+
else
19+
{
20+
return ImeConversionModeValues.DoNotCare;
21+
}
22+
}
23+
return ImeConversionModeValues.DoNotCare;
24+
}
25+
26+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27+
{
28+
throw new NotImplementedException();
29+
}
30+
}
31+
32+
internal class BoolToIMEStateConverter : IValueConverter
33+
{
34+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
35+
{
36+
if (value is bool v)
37+
{
38+
if (v)
39+
{
40+
return InputMethodState.Off;
41+
}
42+
else
43+
{
44+
return InputMethodState.DoNotCare;
45+
}
46+
}
47+
return InputMethodState.DoNotCare;
48+
}
49+
50+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
51+
{
52+
throw new NotImplementedException();
53+
}
54+
}
55+
}

Flow.Launcher/Languages/en.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
<system:String x:Key="defaultFileManagerToolTip">Select the file manager to use when opening the folder.</system:String>
5656
<system:String x:Key="defaultBrowser">Default Web Browser</system:String>
5757
<system:String x:Key="defaultBrowserToolTip">Setting for New Tab, New Window, Private Mode.</system:String>
58+
<system:String x:Key="typingStartEn">Always Start Typing in English Mode</system:String>
59+
<system:String x:Key="typingStartEnTooltip">Temporarily change your input method to English mode when activating Flow.</system:String>
5860
<system:String x:Key="pythonDirectory">Python Directory</system:String>
5961
<system:String x:Key="autoUpdates">Auto Update</system:String>
6062
<system:String x:Key="selectPythonDirectory">Select</system:String>

Flow.Launcher/MainWindow.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
1010
xmlns:ui="http://schemas.modernwpf.com/2019"
1111
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
12+
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
1213
Name="FlowMainWindow"
1314
Title="Flow Launcher"
1415
MinWidth="{Binding MainWindowWidth, Mode=OneWay}"
@@ -37,6 +38,8 @@
3738
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
3839
<converters:BorderClipConverter x:Key="BorderClipConverter" />
3940
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
41+
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
42+
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter"/>
4043
</Window.Resources>
4144
<Window.InputBindings>
4245
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
@@ -204,6 +207,8 @@
204207
PreviewKeyUp="QueryTextBox_KeyUp"
205208
Style="{DynamicResource QueryBoxStyle}"
206209
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
210+
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
211+
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
207212
Visibility="Visible">
208213
<TextBox.CommandBindings>
209214
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
@@ -244,6 +249,7 @@
244249
</TextBox>
245250
</Grid>
246251
</Border>
252+
247253
<StackPanel
248254
x:Name="ClockPanel"
249255
IsHitTestVisible="False"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,10 @@
2020
using System.Windows.Media;
2121
using Flow.Launcher.Infrastructure.Hotkey;
2222
using Flow.Launcher.Plugin.SharedCommands;
23-
using System.Text;
24-
using DataObject = System.Windows.DataObject;
25-
using System.Diagnostics;
26-
using Microsoft.AspNetCore.Http;
27-
using System.IO;
2823
using System.Windows.Threading;
2924
using System.Windows.Data;
3025
using ModernWpf.Controls;
31-
using System.Drawing;
32-
using System.Windows.Forms.Design.Behavior;
33-
using System.Security.Cryptography;
34-
using System.Runtime.CompilerServices;
35-
using Microsoft.VisualBasic.Devices;
36-
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
26+
using Key = System.Windows.Input.Key;
3727

3828
namespace Flow.Launcher
3929
{

Flow.Launcher/SettingWindow.xaml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -737,30 +737,14 @@
737737
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource AlwaysPreview}" />
738738
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AlwaysPreviewToolTip}" />
739739
</StackPanel>
740-
<CheckBox
741-
IsChecked="{Binding Settings.AlwaysPreview}"
742-
Style="{DynamicResource SideControlCheckBox}"
743-
ToolTip="{DynamicResource AlwaysPreviewToolTip}" />
744-
<TextBlock Style="{StaticResource Glyph}">
745-
&#xe8a1;
746-
</TextBlock>
747-
</ItemsControl>
748-
</Border>
749-
750-
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
751-
<ItemsControl Style="{StaticResource SettingGrid}">
752-
<StackPanel Style="{StaticResource TextPanel}">
753-
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource ShouldUsePinyin}" />
754-
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource ShouldUsePinyinToolTip}" />
755-
</StackPanel>
756740
<ui:ToggleSwitch
757741
Grid.Column="2"
758742
FocusVisualMargin="5"
759-
IsOn="{Binding Settings.ShouldUsePinyin}"
743+
IsOn="{Binding Settings.AlwaysPreview}"
760744
Style="{DynamicResource SideToggleSwitch}"
761-
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
745+
ToolTip="{DynamicResource AlwaysPreviewToolTip}" />
762746
<TextBlock Style="{StaticResource Glyph}">
763-
&#xe98a;
747+
&#xe8a1;
764748
</TextBlock>
765749
</ItemsControl>
766750
</Border>
@@ -943,13 +927,52 @@
943927
Text="{Binding Settings.PluginSettings.PythonDirectory, TargetNullValue='No Setting'}" />
944928
<Button
945929
Height="34"
946-
Margin="10,10,18,10"
930+
Margin="10,0,18,0"
947931
Click="OnSelectPythonDirectoryClick"
948932
Content="{DynamicResource selectPythonDirectory}" />
949933
</StackPanel>
950934
</ItemsControl>
951935
</Border>
952936

937+
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
938+
<ItemsControl Style="{StaticResource SettingGrid}">
939+
<StackPanel Style="{StaticResource TextPanel}">
940+
<TextBlock
941+
Grid.Column="1"
942+
VerticalAlignment="Center"
943+
Style="{DynamicResource SettingTitleLabel}"
944+
Text="{DynamicResource typingStartEn}" />
945+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource typingStartEnTooltip}" />
946+
</StackPanel>
947+
<ui:ToggleSwitch
948+
Grid.Column="2"
949+
FocusVisualMargin="5"
950+
IsOn="{Binding Settings.AlwaysStartEn}"
951+
Style="{DynamicResource SideToggleSwitch}" />
952+
<TextBlock Style="{StaticResource Glyph}">
953+
&#xe8d3;
954+
</TextBlock>
955+
</ItemsControl>
956+
</Border>
957+
958+
<Border Margin="0,4,0,0" Style="{DynamicResource SettingGroupBox}">
959+
<ItemsControl Style="{StaticResource SettingGrid}">
960+
<StackPanel Style="{StaticResource TextPanel}">
961+
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource ShouldUsePinyin}" />
962+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource ShouldUsePinyinToolTip}" />
963+
</StackPanel>
964+
<ui:ToggleSwitch
965+
Grid.Column="2"
966+
FocusVisualMargin="5"
967+
IsOn="{Binding Settings.ShouldUsePinyin}"
968+
Style="{DynamicResource SideToggleSwitch}"
969+
ToolTip="{DynamicResource ShouldUsePinyinToolTip}" />
970+
<TextBlock Style="{StaticResource Glyph}">
971+
&#xe98a;
972+
</TextBlock>
973+
</ItemsControl>
974+
</Border>
975+
953976
<Border Style="{DynamicResource SettingGroupBox}">
954977
<ItemsControl Style="{StaticResource SettingGrid}">
955978
<StackPanel Style="{StaticResource TextPanel}">

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public MainViewModel(Settings settings)
7171
case nameof(Settings.WindowSize):
7272
OnPropertyChanged(nameof(MainWindowWidth));
7373
break;
74+
case nameof(Settings.AlwaysStartEn):
75+
OnPropertyChanged(nameof(StartWithEnglishMode));
76+
break;
7477
}
7578
};
7679

@@ -514,6 +517,8 @@ public double MainWindowWidth
514517

515518
public string Image => Constant.QueryTextBoxIconImagePath;
516519

520+
public bool StartWithEnglishMode => Settings.AlwaysStartEn;
521+
517522
#endregion
518523

519524
public void Query()

0 commit comments

Comments
 (0)