Skip to content

Commit cd2037d

Browse files
committed
Merge branch 'dev' into feat_appveyor
2 parents 945c124 + 26e06f7 commit cd2037d

File tree

75 files changed

+766
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+766
-365
lines changed

Doc/app.ico

-31.1 KB
Binary file not shown.

Doc/app.png

-5.91 KB
Loading

Doc/app.psd

-77.5 KB
Binary file not shown.

Doc/app_error.png

-9.06 KB
Loading

Doc/app_error.psd

-77.5 KB
Binary file not shown.

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -8,6 +8,7 @@
88
using System.Windows.Interop;
99
using System.Windows.Markup;
1010
using System.Windows.Media;
11+
using System.Windows.Media.Effects;
1112
using Flow.Launcher.Infrastructure;
1213
using Flow.Launcher.Infrastructure.Logger;
1314
using Flow.Launcher.Infrastructure.UserSettings;
@@ -34,6 +35,9 @@ public Theme()
3435
var dicts = Application.Current.Resources.MergedDictionaries;
3536
_oldResource = dicts.First(d =>
3637
{
38+
if (d.Source == null)
39+
return false;
40+
3741
var p = d.Source.AbsolutePath;
3842
var dir = Path.GetDirectoryName(p).NonNull();
3943
var info = new DirectoryInfo(dir);
@@ -65,7 +69,7 @@ private void MakesureThemeDirectoriesExist()
6569

6670
public bool ChangeTheme(string theme)
6771
{
68-
const string defaultTheme = "Dark";
72+
const string defaultTheme = Constant.DefaultTheme;
6973

7074
string path = GetThemePath(theme);
7175
try
@@ -75,16 +79,15 @@ public bool ChangeTheme(string theme)
7579

7680
Settings.Theme = theme;
7781

78-
var dicts = Application.Current.Resources.MergedDictionaries;
7982
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
8083
if (_oldTheme != theme || theme == defaultTheme)
8184
{
82-
dicts.Remove(_oldResource);
83-
var newResource = GetResourceDictionary();
84-
dicts.Add(newResource);
85-
_oldResource = newResource;
85+
UpdateResourceDictionary(GetResourceDictionary());
8686
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
8787
}
88+
89+
if (Settings.UseDropShadowEffect)
90+
AddDropShadowEffectToCurrentTheme();
8891
}
8992
catch (DirectoryNotFoundException e)
9093
{
@@ -109,14 +112,30 @@ public bool ChangeTheme(string theme)
109112
return true;
110113
}
111114

112-
public ResourceDictionary GetResourceDictionary()
115+
private void UpdateResourceDictionary(ResourceDictionary dictionaryToUpdate)
116+
{
117+
var dicts = Application.Current.Resources.MergedDictionaries;
118+
119+
dicts.Remove(_oldResource);
120+
dicts.Add(dictionaryToUpdate);
121+
_oldResource = dictionaryToUpdate;
122+
}
123+
124+
private ResourceDictionary CurrentThemeResourceDictionary()
113125
{
114126
var uri = GetThemePath(Settings.Theme);
115127
var dict = new ResourceDictionary
116128
{
117129
Source = new Uri(uri, UriKind.Absolute)
118130
};
119131

132+
return dict;
133+
}
134+
135+
public ResourceDictionary GetResourceDictionary()
136+
{
137+
var dict = CurrentThemeResourceDictionary();
138+
120139
Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
121140
if (queryBoxStyle != null)
122141
{
@@ -146,6 +165,7 @@ public ResourceDictionary GetResourceDictionary()
146165
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
147166
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
148167
}
168+
149169
return dict;
150170
}
151171

@@ -176,6 +196,36 @@ private string GetThemePath(string themeName)
176196
return string.Empty;
177197
}
178198

199+
public void AddDropShadowEffectToCurrentTheme()
200+
{
201+
var dict = CurrentThemeResourceDictionary();
202+
203+
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
204+
205+
var effectSetter = new Setter();
206+
effectSetter.Property = Border.EffectProperty;
207+
effectSetter.Value = new DropShadowEffect
208+
{
209+
Opacity = 0.9,
210+
ShadowDepth = 2,
211+
BlurRadius = 15
212+
};
213+
214+
windowBorderStyle.Setters.Add(effectSetter);
215+
216+
UpdateResourceDictionary(dict);
217+
}
218+
219+
public void RemoveDropShadowEffectToCurrentTheme()
220+
{
221+
var dict = CurrentThemeResourceDictionary();
222+
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
223+
224+
dict.Remove(Border.EffectProperty);
225+
226+
UpdateResourceDictionary(dict);
227+
}
228+
179229
#region Blur Handling
180230
/*
181231
Found on https://github.com/riverar/sample-win10-aeroglass
-9.06 KB
Loading

Flow.Launcher.Infrastructure/Constant.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,9 @@ public static class Constant
2727

2828
public static string PythonPath;
2929
public static string EverythingSDKPath;
30+
31+
public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.png";
32+
33+
public const string DefaultTheme = "Darker";
3034
}
3135
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Flow.Launcher.Infrastructure
2+
{
3+
public static class KeyConstant
4+
{
5+
public const string Ctrl = nameof(Ctrl);
6+
public const string Alt = nameof(Alt);
7+
public const string Space = nameof(Space);
8+
}
9+
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ namespace Flow.Launcher.Infrastructure.UserSettings
99
{
1010
public class Settings : BaseModel
1111
{
12-
public string Hotkey { get; set; } = "Alt + Space";
12+
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
13+
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
14+
public bool ShowOpenResultHotkey { get; set; } = true;
1315
public string Language { get; set; } = "en";
14-
public string Theme { get; set; } = "Dark";
16+
public string Theme { get; set; } = Constant.DefaultTheme;
17+
public bool UseDropShadowEffect { get; set; } = false;
1518
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
1619
public string QueryBoxFontStyle { get; set; }
1720
public string QueryBoxFontWeight { get; set; }
@@ -59,7 +62,7 @@ public string QuerySearchPrecisionString
5962

6063
public double WindowLeft { get; set; }
6164
public double WindowTop { get; set; }
62-
public int MaxResultsToShow { get; set; } = 6;
65+
public int MaxResultsToShow { get; set; } = 5;
6366
public int ActivateTimes { get; set; }
6467

6568
// Order defaults to 0 or -1, so 1 will let this property appear last

0 commit comments

Comments
 (0)