add glyph option to settings

This commit is contained in:
Jeremy 2021-10-07 21:58:54 +11:00
parent 5f0df980bf
commit 04a10ed62d
12 changed files with 89 additions and 40 deletions

View file

@ -32,6 +32,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public string ResultFontStyle { get; set; }
public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; }
public bool UseGlyphIcons { get; set; } = true;
/// <summary>

View file

@ -48,7 +48,6 @@
<ItemGroup>
<Page Remove="Themes\ThemeBuilder\Template.xaml" />
<Resource Include="resources\Segoe Fluent Icons.ttf" />
</ItemGroup>
<ItemGroup>
@ -78,6 +77,9 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\Segoe Fluent Icons.ttf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>

View file

@ -38,7 +38,7 @@
<system:String x:Key="hideNotifyIcon">Hide tray icon</system:String>
<system:String x:Key="querySearchPrecision">Query Search Precision</system:String>
<system:String x:Key="ShouldUsePinyin">Should Use Pinyin</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for transliterating Chinese</system:String>
<system:String x:Key="ShouldUsePinyinToolTip">Allows using Pinyin to search. Pinyin is the standard system of romanized spelling for translating Chinese</system:String>
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
<!--Setting Plugin-->
@ -81,8 +81,9 @@
<system:String x:Key="pleaseSelectAnItem">Please select an item</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU.</system:String>
<system:String x:Key="shadowEffectPerformance">Not recommended if your computer performance is limited.</system:String>
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU. Not recommended if your computer performance is limited.</system:String>
<system:String x:Key="useGlyphUI">Use Segoe Fluent Icons</system:String>
<system:String x:Key="useGlyphUIEffect">Use Segoe Fluent Icons where supported</system:String>
<!--Setting Proxy-->
<system:String x:Key="proxy">HTTP Proxy</system:String>

View file

@ -81,8 +81,7 @@
<system:String x:Key="pleaseSelectAnItem">Vyberte položku, prosím</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">Ste si istý, že chcete odstrániť klávesovú skratku {0} pre plugin?</system:String>
<system:String x:Key="queryWindowShadowEffect">Tieňový efekt v poli vyhľadávania</system:String>
<system:String x:Key="shadowEffectCPUUsage">Tieňový efekt významne využíva GPU.</system:String>
<system:String x:Key="shadowEffectPerformance">Neodporúča sa, ak je výkon počítača obmedzený.</system:String>
<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>
<!--Setting Proxy-->
<system:String x:Key="proxy">HTTP Proxy</system:String>

View file

@ -76,8 +76,7 @@
<system:String x:Key="pleaseSelectAnItem">请选择一项</system:String>
<system:String x:Key="deleteCustomHotkeyWarning">你确定要删除插件 {0} 的热键吗?</system:String>
<system:String x:Key="queryWindowShadowEffect">查询窗口阴影效果</system:String>
<system:String x:Key="shadowEffectCPUUsage">阴影效果将占用大量的GPU资源。</system:String>
<system:String x:Key="shadowEffectPerformance">如果您的计算机性能有限,则不建议使用。</system:String>
<system:String x:Key="shadowEffectCPUUsage">阴影效果将占用大量的GPU资源。 如果您的计算机性能有限,则不建议使用。</system:String>
<!--设置,代理-->
<system:String x:Key="proxy">HTTP 代理</system:String>

View file

@ -20,7 +20,7 @@
MinWidth="850"
MinHeight="600"
Loaded="OnLoaded"
Closed="OnClosed"
Closed="OnClosed"
d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}">
<Window.InputBindings>
<KeyBinding Key="Escape" Command="Close"/>
@ -29,7 +29,6 @@
<CommandBinding Command="Close" Executed="OnCloseExecuted"/>
</Window.CommandBindings>
<Window.Resources>
<converters:BorderClipConverter x:Key="BorderClipConverter"/>
<CollectionViewSource Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}" x:Key="SortedFonts">
@ -677,6 +676,19 @@
<Border Style="{DynamicResource SettingGroupBox}" Padding="0" CornerRadius="5" Margin="0 30 0 0">
<StackPanel Orientation="Vertical">
<Border Style="{DynamicResource SettingGroupBox}" Margin="0" BorderThickness="0">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Text="{DynamicResource useGlyphUI}" Style="{DynamicResource SettingTitleLabel}" />
<TextBlock Text="{DynamicResource useGlyphUIEffect}" Style="{DynamicResource SettingSubTitleLabel}" />
</StackPanel>
<ui:ToggleSwitch IsOn="{Binding UseGlyphIcons, Mode=TwoWay}" Width="80" Grid.Column="2" Grid.Row="0" Margin="0 0 18 0"/>
<TextBlock FontFamily="/Resources/#Segoe Fluent Icons" FontSize="20" Grid.Column="0" VerticalAlignment="Center" Margin="24 0 16 0">
&#xf6b8;
</TextBlock>
</ItemsControl>
</Border>
<Separator BorderBrush="#e5e5e5" BorderThickness="1" Width="Auto"/>
<Border Style="{DynamicResource SettingGroupBox}" Margin="0" BorderThickness="0">
<ItemsControl Style="{StaticResource SettingGrid}">
<TextBlock Grid.Column="1" Text="{DynamicResource queryBoxFont}" VerticalAlignment="Center" />

View file

@ -596,8 +596,8 @@ namespace Flow.Launcher.ViewModel
menu = new Result
{
Title = InternationalizationManager.Instance.GetTranslation("setAsTopMostInThisQuery"),
//IcoPath = "Images\\up.png",
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xeac2"),
IcoPath = "Images\\up.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xeac2"),
PluginDirectory = Constant.ProgramDirectory,
Action = _ =>
{

View file

@ -46,11 +46,40 @@ namespace Flow.Launcher.ViewModel
public Visibility ShowOpenResultHotkey =>
Settings.ShowOpenResultHotkey ? Visibility.Visible : Visibility.Collapsed;
public Visibility ShowIcon => Result.IcoPath != null || Result.Icon is not null || Glyph == null
? Visibility.Visible
: Visibility.Hidden;
public Visibility ShowIcon
{
get
{
// If both glyph and image icons are not available, it will then be the default icon
if (!ImgIconAvailable && !GlyphAvailable)
return Visibility.Visible;
// Although user can choose to use glyph icons, plugins may choose to supply only image icons.
// In this case we ignore the setting because otherwise icons will not display as intended
if (Settings.UseGlyphIcons && !GlyphAvailable && ImgIconAvailable)
return Visibility.Visible;
return !Settings.UseGlyphIcons && ImgIconAvailable ? Visibility.Visible : Visibility.Hidden;
}
}
public Visibility ShowGlyph
{
get
{
// Although user can choose to not use glyph icons, plugins may choose to supply only glyph icons.
// In this case we ignore the setting because otherwise icons will not display as intended
if (!Settings.UseGlyphIcons && !ImgIconAvailable && GlyphAvailable)
return Visibility.Visible;
return Settings.UseGlyphIcons && GlyphAvailable ? Visibility.Visible : Visibility.Hidden;
}
}
private bool GlyphAvailable => Glyph is not null;
private bool ImgIconAvailable => !string.IsNullOrEmpty(Result.IcoPath) || Result.Icon is not null;
public Visibility ShowGlyph => Glyph is not null ? Visibility.Visible : Visibility.Hidden;
public string OpenResultModifiers => Settings.OpenResultModifiers;
public string ShowTitleToolTip => string.IsNullOrEmpty(Result.TitleToolTip)

View file

@ -304,6 +304,12 @@ namespace Flow.Launcher.ViewModel
}
}
public bool UseGlyphIcons
{
get { return Settings.UseGlyphIcons; }
set { Settings.UseGlyphIcons = value; }
}
public Brush PreviewBackground
{
get

View file

@ -190,8 +190,8 @@ namespace Flow.Launcher.Plugin.Program
"flowlauncher_plugin_program_disable_dlgtitle_success_message"));
return false;
},
//IcoPath = "Images/disable.png"
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xece4"),
IcoPath = "Images/disable.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xece4"),
}
);

View file

@ -149,8 +149,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
return true;
},
//IcoPath = "Images/user.png"
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xe7ee"),
IcoPath = "Images/user.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe7ee"),
},
new Result
{
@ -169,8 +169,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
return true;
},
//IcoPath = "Images/cmd.png"
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xe7ef"),
IcoPath = "Images/cmd.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe7ef"),
},
new Result
{
@ -194,8 +194,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
return true;
},
//IcoPath = "Images/folder.png"
Glyph = new GlyphInfo(FontFamily: "Segoe Fluent Icons", Glyph: "\xe838"),
IcoPath = "Images/folder.png",
Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\xe838"),
}
};
return contextMenus;

View file

@ -96,8 +96,8 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Shutdown",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe7e8"),
//IcoPath = "Images\\shutdown.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe7e8"),
IcoPath = "Images\\shutdown.png",
Action = c =>
{
var reuslt = MessageBox.Show(
@ -116,8 +116,8 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Restart",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe777"),
//IcoPath = "Images\\restart.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe777"),
IcoPath = "Images\\restart.png",
Action = c =>
{
var result = MessageBox.Show(
@ -136,8 +136,8 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Restart With Advanced Boot Options",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_restart_advanced"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xecc5"),
//IcoPath = "Images\\restart_advanced.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xecc5"),
IcoPath = "Images\\restart_advanced.png",
Action = c =>
{
var result = MessageBox.Show(
@ -155,16 +155,16 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Log Off",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe77b"),
//IcoPath = "Images\\logoff.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe77b"),
IcoPath = "Images\\logoff.png",
Action = c => ExitWindowsEx(EWX_LOGOFF, 0)
},
new Result
{
Title = "Lock",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_lock"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe72e"),
//IcoPath = "Images\\lock.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe72e"),
IcoPath = "Images\\lock.png",
Action = c =>
{
LockWorkStation();
@ -175,16 +175,16 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Sleep",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_sleep"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xec46"),
//IcoPath = "Images\\sleep.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xec46"),
IcoPath = "Images\\sleep.png",
Action = c => FormsApplication.SetSuspendState(PowerState.Suspend, false, false)
},
new Result
{
Title = "Hibernate",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_hibernate"),
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe945"),
//IcoPath = "Images\\hibernate.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe945"),
IcoPath = "Images\\hibernate.png",
Action= c =>
{
var info = ShellCommand.SetProcessStartInfo("shutdown", arguments:"/h");
@ -200,8 +200,8 @@ namespace Flow.Launcher.Plugin.Sys
{
Title = "Empty Recycle Bin",
SubTitle = context.API.GetTranslation("flowlauncher_plugin_sys_emptyrecyclebin"),
//IcoPath = "Images\\recyclebin.png",
Glyph = new GlyphInfo (FontFamily:"Segoe Fluent Icons", Glyph:"\xe74d"),
IcoPath = "Images\\recyclebin.png",
Glyph = new GlyphInfo (FontFamily:"/Resources/#Segoe Fluent Icons", Glyph:"\xe74d"),
Action = c =>
{
// http://www.pinvoke.net/default.aspx/shell32/SHEmptyRecycleBin.html