Skip to content

Commit 3d7669f

Browse files
committed
Merge branch 'dev'
2 parents 80fc62e + 7aa9e98 commit 3d7669f

File tree

55 files changed

+611
-358
lines changed

Some content is hidden

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

55 files changed

+611
-358
lines changed

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

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
}

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ public class Settings : BaseModel
1313
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
1414
public bool ShowOpenResultHotkey { get; set; } = true;
1515
public string Language { get; set; } = "en";
16-
public string Theme { get; set; } = "Dark";
16+
public string Theme { get; set; } = Constant.DefaultTheme;
17+
public bool UseDropShadowEffect { get; set; } = false;
1718
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
1819
public string QueryBoxFontStyle { get; set; }
1920
public string QueryBoxFontWeight { get; set; }
@@ -61,7 +62,7 @@ public string QuerySearchPrecisionString
6162

6263
public double WindowLeft { get; set; }
6364
public double WindowTop { get; set; }
64-
public int MaxResultsToShow { get; set; } = 6;
65+
public int MaxResultsToShow { get; set; } = 5;
6566
public int ActivateTimes { get; set; }
6667

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

Flow.Launcher/App.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<Application x:Class="Flow.Launcher.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:ui="http://schemas.modernwpf.com/2019"
45
ShutdownMode="OnMainWindowClose"
56
Startup="OnStartup">
67
<Application.Resources>
78
<ResourceDictionary>
89
<ResourceDictionary.MergedDictionaries>
9-
<ResourceDictionary Source="pack://application:,,,/Themes/Dark.xaml" />
10+
<ui:ThemeResources RequestedTheme="Light" />
11+
<ui:XamlControlsResources />
12+
<ResourceDictionary Source="pack://application:,,,/Themes/Darker.xaml" />
1013
<ResourceDictionary Source="pack://application:,,,/Languages/en.xaml" />
1114
</ResourceDictionary.MergedDictionaries>
1215
</ResourceDictionary>

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
1919
var queryText = (string)values[0];
2020

2121
if (string.IsNullOrEmpty(queryText))
22-
return "Type here to search";
22+
return string.Empty;
2323

2424
// second prop is the current selected item result
2525
var val = values[1];

Flow.Launcher/Flow.Launcher.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,19 @@
5454
<Compile Include="..\SolutionAssemblyInfo.cs" Link="Properties\SolutionAssemblyInfo.cs" />
5555
</ItemGroup>
5656

57+
<ItemGroup>
58+
<Content Include="Languages\*.xaml">
59+
<Generator>MSBuild:Compile</Generator>
60+
<SubType>Designer</SubType>
61+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
62+
</Content>
63+
</ItemGroup>
64+
5765
<ItemGroup>
5866
<PackageReference Include="InputSimulator" Version="1.0.4" />
5967
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
6068
<PackageReference Include="Mages" Version="1.6.0" />
69+
<PackageReference Include="ModernWpfUI" Version="0.8.3" />
6170
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
6271
<PackageReference Include="NHotkey.Wpf" Version="1.2.1" />
6372
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />
@@ -142,6 +151,9 @@
142151
<None Update="Images\logoff.png">
143152
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
144153
</None>
154+
<None Update="Images\mainsearch.png">
155+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156+
</None>
145157
<None Update="Images\New Message.png">
146158
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
147159
</None>

Flow.Launcher/Images/mainsearch.png

61.6 KB
Loading

Flow.Launcher/Languages/da.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<!--Setting Theme-->
4343
<system:String x:Key="theme">Tema</system:String>
4444
<system:String x:Key="browserMoreThemes">Søg efter flere temaer</system:String>
45-
<system:String x:Key="helloFlowLauncher">Hej Flow Launcher</system:String>
4645
<system:String x:Key="queryBoxFont">Søgefelt skrifttype</system:String>
4746
<system:String x:Key="resultItemFont">Resultat skrifttype</system:String>
4847
<system:String x:Key="windowMode">Vindue mode</system:String>

Flow.Launcher/Languages/de.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
<!--Setting Theme-->
4343
<system:String x:Key="theme">Theme</system:String>
4444
<system:String x:Key="browserMoreThemes">Suche nach weiteren Themes</system:String>
45-
<system:String x:Key="helloFlowLauncher">Hallo Flow Launcher</system:String>
4645
<system:String x:Key="queryBoxFont">Abfragebox Schriftart</system:String>
4746
<system:String x:Key="resultItemFont">Ergebnis Schriftart</system:String>
4847
<system:String x:Key="windowMode">Fenstermodus</system:String>

Flow.Launcher/Languages/en.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<!--Setting Theme-->
5050
<system:String x:Key="theme">Theme</system:String>
5151
<system:String x:Key="browserMoreThemes">Browse for more themes</system:String>
52-
<system:String x:Key="helloFlowLauncher">Hello Flow Launcher</system:String>
52+
<system:String x:Key="hiThere">Hi There</system:String>
5353
<system:String x:Key="queryBoxFont">Query Box Font</system:String>
5454
<system:String x:Key="resultItemFont">Result Item Font</system:String>
5555
<system:String x:Key="windowMode">Window Mode</system:String>
@@ -68,6 +68,9 @@
6868
<system:String x:Key="add">Add</system:String>
6969
<system:String x:Key="pleaseSelectAnItem">Please select an item</system:String>
7070
<system:String x:Key="deleteCustomHotkeyWarning">Are you sure you want to delete {0} plugin hotkey?</system:String>
71+
<system:String x:Key="queryWindowShadowEffect">Query window shadow effect</system:String>
72+
<system:String x:Key="shadowEffectCPUUsage">Shadow effect has a substantial usage of GPU.</system:String>
73+
<system:String x:Key="shadowEffectPerformance">Not recommended if you computer performance is limited.</system:String>
7174

7275
<!--Setting Proxy-->
7376
<system:String x:Key="proxy">HTTP Proxy</system:String>
@@ -97,7 +100,7 @@
97100
Download updates failed, please check your connection and proxy settings to github-cloud.s3.amazonaws.com,
98101
or go to https://github.com/Flow-Launcher/Flow.Launcher/releases to download updates manually.
99102
</system:String>
100-
<system:String x:Key="releaseNotes">Release Notes:</system:String>
103+
<system:String x:Key="releaseNotes">Release Notes</system:String>
101104

102105
<!--Action Keyword Setting Dialog-->
103106
<system:String x:Key="oldActionKeywords">Old Action Keyword</system:String>

0 commit comments

Comments
 (0)