Skip to content

Commit 3baaa2d

Browse files
authored
Merge pull request #704 from onesounds/ModernTheme
Modern Design
2 parents 6001192 + 42dda34 commit 3baaa2d

40 files changed

+2162
-493
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ private ResourceDictionary CurrentThemeResourceDictionary()
145145
public ResourceDictionary GetResourceDictionary()
146146
{
147147
var dict = CurrentThemeResourceDictionary();
148-
149-
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
150-
Style querySuggestionBoxStyle = dict["QuerySuggestionBoxStyle"] as Style;
151-
152-
if (queryBoxStyle != null && querySuggestionBoxStyle != null)
148+
149+
if (dict["QueryBoxStyle"] is Style queryBoxStyle &&
150+
dict["QuerySuggestionBoxStyle"] is Style querySuggestionBoxStyle)
153151
{
154152
var fontFamily = new FontFamily(Settings.QueryBoxFont);
155153
var fontStyle = FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.QueryBoxFontStyle);
@@ -174,19 +172,22 @@ public ResourceDictionary GetResourceDictionary()
174172
querySuggestionBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, fontStretch));
175173
}
176174

177-
Style resultItemStyle = dict["ItemTitleStyle"] as Style;
178-
Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
179-
Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
180-
Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
181-
if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
175+
if (dict["ItemTitleStyle"] is Style resultItemStyle &&
176+
dict["ItemSubTitleStyle"] is Style resultSubItemStyle &&
177+
dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle &&
178+
dict["ItemTitleSelectedStyle"] is Style resultItemSelectedStyle &&
179+
dict["ItemHotkeyStyle"] is Style resultHotkeyItemStyle &&
180+
dict["ItemHotkeySelectedStyle"] is Style resultHotkeyItemSelectedStyle)
182181
{
183182
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultFont));
184183
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultFontStyle));
185184
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultFontWeight));
186185
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultFontStretch));
187186

188187
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
189-
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
188+
Array.ForEach(
189+
new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
190+
=> Array.ForEach(setters, p => o.Setters.Add(p)));
190191
}
191192

192193
var windowStyle = dict["WindowStyle"] as Style;
@@ -236,17 +237,19 @@ private string GetThemePath(string themeName)
236237

237238
public void AddDropShadowEffectToCurrentTheme()
238239
{
239-
var dict = CurrentThemeResourceDictionary();
240+
var dict = GetResourceDictionary();
240241

241242
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
242243

243-
var effectSetter = new Setter();
244-
effectSetter.Property = Border.EffectProperty;
245-
effectSetter.Value = new DropShadowEffect
244+
var effectSetter = new Setter
246245
{
247-
Opacity = 0.9,
248-
ShadowDepth = 2,
249-
BlurRadius = 15
246+
Property = Border.EffectProperty,
247+
Value = new DropShadowEffect
248+
{
249+
Opacity = 0.4,
250+
ShadowDepth = 2,
251+
BlurRadius = 15
252+
}
250253
};
251254

252255
var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter;
@@ -261,7 +264,7 @@ public void AddDropShadowEffectToCurrentTheme()
261264
}
262265
else
263266
{
264-
var baseMargin = (Thickness) marginSetter.Value;
267+
var baseMargin = (Thickness)marginSetter.Value;
265268
var newMargin = new Thickness(
266269
baseMargin.Left + ShadowExtraMargin,
267270
baseMargin.Top + ShadowExtraMargin,
@@ -282,8 +285,8 @@ public void RemoveDropShadowEffectFromCurrentTheme()
282285

283286
var effectSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.EffectProperty) as Setter;
284287
var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter;
285-
286-
if(effectSetter != null)
288+
289+
if (effectSetter != null)
287290
{
288291
windowBorderStyle.Setters.Remove(effectSetter);
289292
}
@@ -371,11 +374,11 @@ private bool IsBlurTheme()
371374
private void SetWindowAccent(Window w, AccentState state)
372375
{
373376
var windowHelper = new WindowInteropHelper(w);
374-
377+
375378
// this determines the width of the main query window
376379
w.Width = mainWindowWidth;
377380
windowHelper.EnsureHandle();
378-
381+
379382
var accent = new AccentPolicy { AccentState = state };
380383
var accentStructSize = Marshal.SizeOf(accent);
381384

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>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
using System.Windows.Media;
10+
using System.Windows.Documents;
11+
using System.Windows.Shapes;
12+
13+
// For Clipping inside listbox item
14+
15+
namespace Flow.Launcher.Converters
16+
{
17+
public class BorderClipConverter : IMultiValueConverter
18+
{
19+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
if (values.Length == 3 && values[0] is double && values[1] is double && values[2] is CornerRadius)
22+
{
23+
var width = (double)values[0];
24+
var height = (double)values[1];
25+
Path myPath = new Path();
26+
if (width < Double.Epsilon || height < Double.Epsilon)
27+
{
28+
return Geometry.Empty;
29+
}
30+
var radius = (CornerRadius)values[2];
31+
var radiusHeight = radius.TopLeft;
32+
33+
// Drawing Round box for bottom round, and rect for top area of listbox.
34+
var corner = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft);
35+
var box = new RectangleGeometry(new Rect(0, 0, width, radiusHeight), 0, 0);
36+
37+
GeometryGroup myGeometryGroup = new GeometryGroup();
38+
myGeometryGroup.Children.Add(corner);
39+
myGeometryGroup.Children.Add(box);
40+
41+
CombinedGeometry c1 = new CombinedGeometry(GeometryCombineMode.Union, corner, box);
42+
myPath.Data = c1;
43+
44+
myPath.Data.Freeze();
45+
return myPath.Data;
46+
}
47+
48+
return DependencyProperty.UnsetValue;
49+
}
50+
51+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
52+
{
53+
throw new NotSupportedException();
54+
}
55+
}
56+
57+
}

Flow.Launcher/Converters/HighlightTextConverter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading.Tasks;
77
using System.Windows;
88
using System.Windows.Data;
9+
using System.Windows.Media;
910
using System.Windows.Documents;
1011

1112
namespace Flow.Launcher.Converters
@@ -30,7 +31,9 @@ public object Convert(object[] value, Type targetType, object parameter, Culture
3031
var currentCharacter = text.Substring(i, 1);
3132
if (this.ShouldHighlight(highlightData, i))
3233
{
33-
textBlock.Inlines.Add(new Bold(new Run(currentCharacter)));
34+
35+
textBlock.Inlines.Add(new Run(currentCharacter) { Style = (Style)Application.Current.FindResource("HighlightStyle") });
36+
3437
}
3538
else
3639
{

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
<SubType>Designer</SubType>
7878
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
7979
</Content>
80+
<Content Include="Resources\Segoe Fluent Icons.ttf">
81+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
82+
</Content>
8083
</ItemGroup>
8184

8285
<ItemGroup>

Flow.Launcher/HotkeyControl.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
d:DesignHeight="300" d:DesignWidth="300">
1010
<Grid>
1111
<Grid.ColumnDefinitions>
12-
<ColumnDefinition Width="150" />
1312
<ColumnDefinition Width="125" />
13+
<ColumnDefinition Width="160" />
1414
</Grid.ColumnDefinitions>
15-
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center" Grid.Column="0"
16-
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False"/>
17-
<TextBlock x:Name="tbMsg" Visibility="Hidden" Margin="5 0 0 0" VerticalAlignment="Center" Grid.Column="1" />
15+
<TextBlock x:Name="tbMsg" Visibility="Hidden" Margin="8 0 0 0" VerticalAlignment="Center" Grid.Column="0" HorizontalAlignment="Right"/>
16+
<TextBox x:Name="tbHotkey" TabIndex="100" VerticalContentAlignment="Center" Grid.Column="1"
17+
PreviewKeyDown="TbHotkey_OnPreviewKeyDown" input:InputMethod.IsInputMethodEnabled="False" Margin="5 0 18 0"/>
1818
</Grid>
1919
</UserControl>

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 for query results 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>

0 commit comments

Comments
 (0)