Skip to content

Commit 04a10ed

Browse files
committed
add glyph option to settings
1 parent 5f0df98 commit 04a10ed

File tree

12 files changed

+89
-40
lines changed

12 files changed

+89
-40
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public string Language
3232
public string ResultFontStyle { get; set; }
3333
public string ResultFontWeight { get; set; }
3434
public string ResultFontStretch { get; set; }
35+
public bool UseGlyphIcons { get; set; } = true;
3536

3637

3738
/// <summary>

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848

4949
<ItemGroup>
5050
<Page Remove="Themes\ThemeBuilder\Template.xaml" />
51-
<Resource Include="resources\Segoe Fluent Icons.ttf" />
5251
</ItemGroup>
5352

5453
<ItemGroup>
@@ -78,6 +77,9 @@
7877
<SubType>Designer</SubType>
7978
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8079
</Content>
80+
<Content Include="Resources\Segoe Fluent Icons.ttf">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</Content>
8183
</ItemGroup>
8284

8385
<ItemGroup>

Flow.Launcher/Languages/en.xaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
3939
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
4040
<system:String x:Key="ShouldUsePinyin">Should Use Pinyin</system:String>
41-
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for transliterating Chinese</system:String>
41+
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese</system:String>
4242
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
4343

4444
<!--Setting Plugin-->
@@ -81,8 +81,9 @@
8181
<system:String x:Key="pleaseSelectAnItem">Please select an item</system:String>
8282
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
8383
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
84-
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU.</system:String>
85-
<system:String x:Key="shadowEffectPerformance">Not recommended if your computer performance is limited.</system:String>
84+
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
85+
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
86+
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons where supported</system:String>
8687

8788
<!--Setting Proxy-->
8889
<system:String x:Key="proxy">HTTP Proxy</system:String>

Flow.Launcher/Languages/sk.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
<system:String x:Key="pleaseSelectAnItem">Vyberte položku, prosím</system:String>
8282
<system:String x:Key="deleteCustomHotkeyWarning">Ste si istý, že chcete odstrániť klávesovú skratku {0} pre plugin?</system:String>
8383
<system:String x:Key="queryWindowShadowEffect">Tieňový efekt v poli vyhľadávania</system:String>
84-
<system:String x:Key="shadowEffectCPUUsage">Tieňový efekt významne využíva GPU.</system:String>
85-
<system:String x:Key="shadowEffectPerformance">Neodporúča sa, ak je výkon počítača obmedzený.</system:String>
84+
<system:String x:Key="shadowEffectCPUUsage">Tieňový efekt významne využíva GPU. Neodporúča sa, ak je výkon počítača obmedzený.</system:String>
8685

8786
<!--Setting Proxy-->
8887
<system:String x:Key="proxy">HTTP Proxy</system:String>

Flow.Launcher/Languages/zh-cn.xaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@
7676
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
7777
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
7878
<system:String x:Key="queryWindowShadowEffect">查询窗口阴影效果</system:String>
79-
<system:String x:Key="shadowEffectCPUUsage">阴影效果将占用大量的GPU资源。</system:String>
80-
<system:String x:Key="shadowEffectPerformance">如果您的计算机性能有限,则不建议使用。</system:String>
79+
<system:String x:Key="shadowEffectCPUUsage">阴影效果将占用大量的GPU资源。 如果您的计算机性能有限,则不建议使用。</system:String>
8180

8281
<!--设置,代理-->
8382
<system:String x:Key="proxy">HTTP 代理</system:String>

Flow.Launcher/SettingWindow.xaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
MinWidth="850"
2121
MinHeight="600"
2222
Loaded="OnLoaded"
23-
Closed="OnClosed"
23+
Closed="OnClosed"
2424
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
2525
<Window.InputBindings>
2626
<KeyBinding Key="Escape" Command="Close"/>
@@ -29,7 +29,6 @@
2929
<CommandBinding Command="Close" Executed="OnCloseExecuted"/>
3030
</Window.CommandBindings>
3131

32-
3332
<Window.Resources>
3433
<converters:BorderClipConverter x:Key="BorderClipConverter"/>
3534
<CollectionViewSource Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" x:Key="SortedFonts">
@@ -677,6 +676,19 @@
677676

678677
<Border Style="{DynamicResource SettingGroupBox}" Padding="0" CornerRadius="5" Margin="0 30 0 0">
679678
<StackPanel Orientation="Vertical">
679+
<Border Style="{DynamicResource SettingGroupBox}" Margin="0" BorderThickness="0">
680+
<ItemsControl Style="{StaticResource SettingGrid}">
681+
<StackPanel Style="{StaticResource TextPanel}">
682+
<TextBlock Text="{DynamicResource useGlyphUI}" Style="{DynamicResource SettingTitleLabel}" />
683+
<TextBlock Text="{DynamicResource useGlyphUIEffect}" Style="{DynamicResource SettingSubTitleLabel}" />
684+
</StackPanel>
685+
<ui:ToggleSwitch IsOn="{Binding UseGlyphIcons, Mode=TwoWay}" Width="80" Grid.Column="2" Grid.Row="0" Margin="0 0 18 0"/>
686+
<TextBlock FontFamily="/Resources/#Segoe Fluent Icons" FontSize="20" Grid.Column="0" VerticalAlignment="Center" Margin="24 0 16 0">
687+
&#xf6b8;
688+
</TextBlock>
689+
</ItemsControl>
690+
</Border>
691+
<Separator BorderBrush="#e5e5e5" BorderThickness="1" Width="Auto"/>
680692
<Border Style="{DynamicResource SettingGroupBox}" Margin="0" BorderThickness="0">
681693
<ItemsControl Style="{StaticResource SettingGrid}">
682694
<TextBlock Grid.Column="1" Text="{DynamicResource queryBoxFont}" VerticalAlignment="Center" />

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ private Result ContextMenuTopMost(Result result)
596596
menu = new Result
597597
{
598598
Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"),
599-
//IcoPath = "Images\\up.png",
600-
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xeac2"),
599+
IcoPath = "Images\\up.png",
600+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xeac2"),
601601
PluginDirectory = Constant.ProgramDirectory,
602602
Action = _ =>
603603
{

Flow.Launcher/ViewModel/ResultViewModel.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,40 @@ public ResultViewModel(Result result, Settings settings)
4646
public Visibility ShowOpenResultHotkey =>
4747
Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Collapsed;
4848

49-
public Visibility ShowIcon => Result.IcoPath != null || Result.Icon is not null || Glyph == null
50-
? Visibility.Visible
51-
: Visibility.Hidden;
49+
public Visibility ShowIcon
50+
{
51+
get
52+
{
53+
// If both glyph and image icons are not available, it will then be the default icon
54+
if (!ImgIconAvailable && !GlyphAvailable)
55+
return Visibility.Visible;
56+
57+
// Although user can choose to use glyph icons, plugins may choose to supply only image icons.
58+
// In this case we ignore the setting because otherwise icons will not display as intended
59+
if (Settings.UseGlyphIcons && !GlyphAvailable && ImgIconAvailable)
60+
return Visibility.Visible;
61+
62+
return !Settings.UseGlyphIcons && ImgIconAvailable ? Visibility.Visible : Visibility.Hidden;
63+
}
64+
}
65+
66+
public Visibility ShowGlyph
67+
{
68+
get
69+
{
70+
// Although user can choose to not use glyph icons, plugins may choose to supply only glyph icons.
71+
// In this case we ignore the setting because otherwise icons will not display as intended
72+
if (!Settings.UseGlyphIcons && !ImgIconAvailable && GlyphAvailable)
73+
return Visibility.Visible;
74+
75+
return Settings.UseGlyphIcons && GlyphAvailable ? Visibility.Visible : Visibility.Hidden;
76+
}
77+
}
78+
79+
private bool GlyphAvailable => Glyph is not null;
80+
81+
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoPath) || Result.Icon is not null;
5282

53-
public Visibility ShowGlyph => Glyph is not null ? Visibility.Visible : Visibility.Hidden;
5483
public string OpenResultModifiers => Settings.OpenResultModifiers;
5584

5685
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@ public bool DropShadowEffect
304304
}
305305
}
306306

307+
public bool UseGlyphIcons
308+
{
309+
get { return Settings.UseGlyphIcons; }
310+
set { Settings.UseGlyphIcons = value; }
311+
}
312+
307313
public Brush PreviewBackground
308314
{
309315
get

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ public List<Result> LoadContextMenus(Result selectedResult)
190190
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
191191
return false;
192192
},
193-
//IcoPath = "Images/disable.png"
194-
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xece4"),
193+
IcoPath = "Images/disable.png",
194+
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xece4"),
195195
}
196196
);
197197

0 commit comments

Comments
 (0)