Skip to content

Commit 5cc4a36

Browse files
committed
Add StartEn Setting
1 parent 9c369c4 commit 5cc4a36

File tree

5 files changed

+52
-4
lines changed

5 files changed

+52
-4
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;

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 in English Layout</system:String>
59+
<system:String x:Key="typingStartEnTooltip">If you are using both native language and English keyboard layouts, start the flow in English layout state.</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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
</TextBox>
245245
</Grid>
246246
</Border>
247+
247248
<StackPanel
248249
x:Name="ClockPanel"
249250
IsHitTestVisible="False"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
using System.Runtime.CompilerServices;
3535
using Microsoft.VisualBasic.Devices;
3636
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
37+
using NLog.Targets;
38+
using YamlDotNet.Core.Tokens;
39+
using Key = System.Windows.Input.Key;
3740

3841
namespace Flow.Launcher
3942
{
@@ -128,6 +131,7 @@ private void OnLoaded(object sender, RoutedEventArgs _)
128131
UpdatePosition();
129132
PreviewReset();
130133
Activate();
134+
QueryTextBox_StartEn();
131135
QueryTextBox.Focus();
132136
_settings.ActivateTimes++;
133137
if (!_viewModel.LastQuerySelected)
@@ -191,6 +195,9 @@ private void OnLoaded(object sender, RoutedEventArgs _)
191195
case nameof(Settings.Language):
192196
UpdateNotifyIconText();
193197
break;
198+
case nameof(Settings.AlwaysStartEn):
199+
QueryTextBox_StartEn();
200+
break;
194201
case nameof(Settings.Hotkey):
195202
UpdateNotifyIconText();
196203
break;
@@ -696,5 +703,19 @@ private void QueryTextBox_KeyUp(object sender, KeyEventArgs e)
696703
be.UpdateSource();
697704
}
698705
}
706+
707+
private void QueryTextBox_StartEn()
708+
{
709+
if (_settings.AlwaysStartEn)
710+
{
711+
QueryTextBox.SetValue(InputMethod.PreferredImeConversionModeProperty, ImeConversionModeValues.Alphanumeric);
712+
QueryTextBox.SetValue(InputMethod.PreferredImeStateProperty, InputMethodState.Off);
713+
}
714+
else
715+
{
716+
QueryTextBox.ClearValue(InputMethod.PreferredImeConversionModeProperty);
717+
QueryTextBox.ClearValue(InputMethod.PreferredImeStateProperty);
718+
}
719+
}
699720
}
700721
}

Flow.Launcher/SettingWindow.xaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,11 @@
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}"
740+
<ui:ToggleSwitch
741+
Grid.Column="2"
742+
FocusVisualMargin="5"
743+
IsOn="{Binding Settings.AlwaysPreview}"
744+
Style="{DynamicResource SideToggleSwitch}"
743745
ToolTip="{DynamicResource AlwaysPreviewToolTip}" />
744746
<TextBlock Style="{StaticResource Glyph}">
745747
&#xe8a1;
@@ -943,13 +945,34 @@
943945
Text="{Binding Settings.PluginSettings.PythonDirectory, TargetNullValue='No Setting'}" />
944946
<Button
945947
Height="34"
946-
Margin="10,10,18,10"
948+
Margin="10,0,18,0"
947949
Click="OnSelectPythonDirectoryClick"
948950
Content="{DynamicResource selectPythonDirectory}" />
949951
</StackPanel>
950952
</ItemsControl>
951953
</Border>
952954

955+
<Border Margin="0,30,0,0" Style="{DynamicResource SettingGroupBox}">
956+
<ItemsControl Style="{StaticResource SettingGrid}">
957+
<StackPanel Style="{StaticResource TextPanel}">
958+
<TextBlock
959+
Grid.Column="1"
960+
VerticalAlignment="Center"
961+
Style="{DynamicResource SettingTitleLabel}"
962+
Text="{DynamicResource typingStartEn}" />
963+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource typingStartEnTooltip}" />
964+
</StackPanel>
965+
<ui:ToggleSwitch
966+
Grid.Column="2"
967+
FocusVisualMargin="5"
968+
IsOn="{Binding Settings.AlwaysStartEn}"
969+
Style="{DynamicResource SideToggleSwitch}" />
970+
<TextBlock Style="{StaticResource Glyph}">
971+
&#xe8d3;
972+
</TextBlock>
973+
</ItemsControl>
974+
</Border>
975+
953976
<Border Style="{DynamicResource SettingGroupBox}">
954977
<ItemsControl Style="{StaticResource SettingGrid}">
955978
<StackPanel Style="{StaticResource TextPanel}">

0 commit comments

Comments
 (0)