Skip to content

Commit 1a49178

Browse files
committed
Add Subtext Highlight Setting
1 parent 1f64dc8 commit 1a49178

File tree

5 files changed

+43
-1
lines changed

5 files changed

+43
-1
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public string Language
4040
public string ResultFontStretch { get; set; }
4141
public bool UseGlyphIcons { get; set; } = true;
4242
public bool UseAnimation { get; set; } = true;
43+
public bool SubtitleHighlight { get; set; } = false;
4344
public bool UseSound { get; set; } = true;
4445
public bool FirstLaunch { get; set; } = true;
4546

Flow.Launcher/Converters/HighlightTextConverter.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88
using System.Windows.Data;
99
using System.Windows.Media;
1010
using System.Windows.Documents;
11+
using Flow.Launcher.Infrastructure.UserSettings;
12+
using Flow.Launcher.Core.Resource;
1113

1214
namespace Flow.Launcher.Converters
1315
{
1416
public class HighlightTextConverter : IMultiValueConverter
1517
{
18+
public Settings Settings { get;}
19+
Settings settings = new Settings();
1620
public object Convert(object[] value, Type targetType, object parameter, CultureInfo cultureInfo)
1721
{
1822
var text = value[0] as string;
@@ -31,8 +35,14 @@ public object Convert(object[] value, Type targetType, object parameter, Culture
3135
var currentCharacter = text.Substring(i, 1);
3236
if (this.ShouldHighlight(highlightData, i))
3337
{
34-
38+
System.Diagnostics.Debug.WriteLine(settings.SubtitleHighlight);
39+
if (settings.SubtitleHighlight == true)
40+
{
3541
textBlock.Inlines.Add(new Run(currentCharacter) { Style = (Style)Application.Current.FindResource("HighlightStyle") });
42+
}
43+
else
44+
{
45+
}
3646

3747
}
3848
else
@@ -52,5 +62,6 @@ private bool ShouldHighlight(List<int> highlightData, int index)
5262
{
5363
return highlightData.Contains(index);
5464
}
65+
5566
}
5667
}

Flow.Launcher/Languages/en.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<system:String x:Key="ThemeFolder">Theme Folder</system:String>
9191
<system:String x:Key="OpenThemeFolder">Open Theme Folder</system:String>
9292
<system:String x:Key="ColorScheme">Color Scheme</system:String>
93+
<system:String x:Key="SubtitleHihglight">Subtitle Highlight</system:String>
9394
<system:String x:Key="ColorSchemeSystem">System Default</system:String>
9495
<system:String x:Key="ColorSchemeLight">Light</system:String>
9596
<system:String x:Key="ColorSchemeDark">Dark</system:String>

Flow.Launcher/SettingWindow.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,29 @@
19371937
</TextBlock>
19381938
</ItemsControl>
19391939
</Border>
1940+
<Separator
1941+
Width="Auto"
1942+
BorderThickness="1"
1943+
Style="{StaticResource SettingSeparatorStyle}" />
1944+
<Border
1945+
Margin="0,0,0,0"
1946+
BorderThickness="0"
1947+
Style="{DynamicResource SettingGroupBox}">
1948+
<ItemsControl Style="{StaticResource SettingGrid}">
1949+
<StackPanel Style="{StaticResource TextPanel}">
1950+
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SubtitleHihglight}" />
1951+
</StackPanel>
1952+
<ui:ToggleSwitch
1953+
Grid.Row="0"
1954+
Grid.Column="2"
1955+
Width="100"
1956+
Margin="0,0,2,0"
1957+
IsOn="{Binding SubtitleHighlight, Mode=TwoWay}" />
1958+
<TextBlock Style="{StaticResource Glyph}">
1959+
&#xea80;
1960+
</TextBlock>
1961+
</ItemsControl>
1962+
</Border>
19401963
</StackPanel>
19411964
</Border>
19421965

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,18 @@ public bool UseAnimation
356356
set => Settings.UseAnimation = value;
357357
}
358358

359+
359360
public bool UseSound
360361
{
361362
get => Settings.UseSound;
362363
set => Settings.UseSound = value;
363364
}
364365

366+
public bool SubtitleHighlight
367+
{
368+
get => Settings.SubtitleHighlight;
369+
set => Settings.SubtitleHighlight = value;
370+
}
365371
public Brush PreviewBackground
366372
{
367373
get

0 commit comments

Comments
 (0)