Skip to content

Commit

Permalink
Merge pull request #37 from Flow-Launcher/update_ui
Browse files Browse the repository at this point in the history
Launcher appearance uplift
  • Loading branch information
jjw24 authored May 14, 2020
2 parents db358e6 + 5a0faba commit 0d9c956
Show file tree
Hide file tree
Showing 55 changed files with 603 additions and 358 deletions.
66 changes: 58 additions & 8 deletions Flow.Launcher.Core/Resource/Theme.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -8,6 +8,7 @@
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Effects;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
Expand All @@ -34,6 +35,9 @@ public Theme()
var dicts = Application.Current.Resources.MergedDictionaries;
_oldResource = dicts.First(d =>
{
if (d.Source == null)
return false;
var p = d.Source.AbsolutePath;
var dir = Path.GetDirectoryName(p).NonNull();
var info = new DirectoryInfo(dir);
Expand Down Expand Up @@ -65,7 +69,7 @@ private void MakesureThemeDirectoriesExist()

public bool ChangeTheme(string theme)
{
const string defaultTheme = "Dark";
const string defaultTheme = Constant.DefaultTheme;

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

Settings.Theme = theme;

var dicts = Application.Current.Resources.MergedDictionaries;
//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
if (_oldTheme != theme || theme == defaultTheme)
{
dicts.Remove(_oldResource);
var newResource = GetResourceDictionary();
dicts.Add(newResource);
_oldResource = newResource;
UpdateResourceDictionary(GetResourceDictionary());
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
}

if (Settings.UseDropShadowEffect)
AddDropShadowEffectToCurrentTheme();
}
catch (DirectoryNotFoundException e)
{
Expand All @@ -109,14 +112,30 @@ public bool ChangeTheme(string theme)
return true;
}

public ResourceDictionary GetResourceDictionary()
private void UpdateResourceDictionary(ResourceDictionary dictionaryToUpdate)
{
var dicts = Application.Current.Resources.MergedDictionaries;

dicts.Remove(_oldResource);
dicts.Add(dictionaryToUpdate);
_oldResource = dictionaryToUpdate;
}

private ResourceDictionary CurrentThemeResourceDictionary()
{
var uri = GetThemePath(Settings.Theme);
var dict = new ResourceDictionary
{
Source = new Uri(uri, UriKind.Absolute)
};

return dict;
}

public ResourceDictionary GetResourceDictionary()
{
var dict = CurrentThemeResourceDictionary();

Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
if (queryBoxStyle != null)
{
Expand Down Expand Up @@ -146,6 +165,7 @@ public ResourceDictionary GetResourceDictionary()
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
}

return dict;
}

Expand Down Expand Up @@ -176,6 +196,36 @@ private string GetThemePath(string themeName)
return string.Empty;
}

public void AddDropShadowEffectToCurrentTheme()
{
var dict = CurrentThemeResourceDictionary();

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

var effectSetter = new Setter();
effectSetter.Property = Border.EffectProperty;
effectSetter.Value = new DropShadowEffect
{
Opacity = 0.9,
ShadowDepth = 2,
BlurRadius = 15
};

windowBorderStyle.Setters.Add(effectSetter);

UpdateResourceDictionary(dict);
}

public void RemoveDropShadowEffectToCurrentTheme()
{
var dict = CurrentThemeResourceDictionary();
var windowBorderStyle = dict["WindowBorderStyle"] as Style;

dict.Remove(Border.EffectProperty);

UpdateResourceDictionary(dict);
}

#region Blur Handling
/*
Found on https://github.com/riverar/sample-win10-aeroglass
Expand Down
4 changes: 4 additions & 0 deletions Flow.Launcher.Infrastructure/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ public static class Constant

public static string PythonPath;
public static string EverythingSDKPath;

public static readonly string QueryTextBoxIconImagePath = $"{ProgramDirectory}\\Images\\mainsearch.png";

public const string DefaultTheme = "Darker";
}
}
5 changes: 3 additions & 2 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class Settings : BaseModel
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
public bool ShowOpenResultHotkey { get; set; } = true;
public string Language { get; set; } = "en";
public string Theme { get; set; } = "Dark";
public string Theme { get; set; } = Constant.DefaultTheme;
public bool UseDropShadowEffect { get; set; } = false;
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; }
Expand Down Expand Up @@ -61,7 +62,7 @@ public string QuerySearchPrecisionString

public double WindowLeft { get; set; }
public double WindowTop { get; set; }
public int MaxResultsToShow { get; set; } = 6;
public int MaxResultsToShow { get; set; } = 5;
public int ActivateTimes { get; set; }

// Order defaults to 0 or -1, so 1 will let this property appear last
Expand Down
5 changes: 4 additions & 1 deletion Flow.Launcher/App.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Application x:Class="Flow.Launcher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.modernwpf.com/2019"
ShutdownMode="OnMainWindowClose"
Startup="OnStartup">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Themes/Dark.xaml" />
<ui:ThemeResources RequestedTheme="Light" />
<ui:XamlControlsResources />
<ResourceDictionary Source="pack://application:,,,/Themes/Darker.xaml" />
<ResourceDictionary Source="pack://application:,,,/Languages/en.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
var queryText = (string)values[0];

if (string.IsNullOrEmpty(queryText))
return "Type here to search";
return string.Empty;

// second prop is the current selected item result
var val = values[1];
Expand Down
4 changes: 4 additions & 0 deletions Flow.Launcher/Flow.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<PackageReference Include="InputSimulator" Version="1.0.4" />
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Mages" Version="1.6.0" />
<PackageReference Include="ModernWpfUI" Version="0.8.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NHotkey.Wpf" Version="1.2.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />
Expand Down Expand Up @@ -142,6 +143,9 @@
<None Update="Images\logoff.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\mainsearch.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Images\New Message.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Binary file added Flow.Launcher/Images/mainsearch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/da.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Tema</system:String>
<system:String x:Key="browserMoreThemes">Søg efter flere temaer</system:String>
<system:String x:Key="helloFlowLauncher">Hej Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Søgefelt skrifttype</system:String>
<system:String x:Key="resultItemFont">Resultat skrifttype</system:String>
<system:String x:Key="windowMode">Vindue mode</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/de.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Theme</system:String>
<system:String x:Key="browserMoreThemes">Suche nach weiteren Themes</system:String>
<system:String x:Key="helloFlowLauncher">Hallo Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Abfragebox Schriftart</system:String>
<system:String x:Key="resultItemFont">Ergebnis Schriftart</system:String>
<system:String x:Key="windowMode">Fenstermodus</system:String>
Expand Down
7 changes: 5 additions & 2 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<!--Setting Theme-->
<system:String x:Key="theme">Theme</system:String>
<system:String x:Key="browserMoreThemes">Browse for more themes</system:String>
<system:String x:Key="helloFlowLauncher">Hello Flow Launcher</system:String>
<system:String x:Key="hiThere">Hi There</system:String>
<system:String x:Key="queryBoxFont">Query Box Font</system:String>
<system:String x:Key="resultItemFont">Result Item Font</system:String>
<system:String x:Key="windowMode">Window Mode</system:String>
Expand All @@ -68,6 +68,9 @@
<system:String x:Key="add">Add</system:String>
<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 you computer performance is limited.</system:String>

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

<!--Action Keyword Setting Dialog-->
<system:String x:Key="oldActionKeywords">Old Action Keyword</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/fr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Thèmes</system:String>
<system:String x:Key="browserMoreThemes">Trouver plus de thèmes</system:String>
<system:String x:Key="helloFlowLauncher">Hello Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Police (barre de recherche)</system:String>
<system:String x:Key="resultItemFont">Police (liste des résultats) </system:String>
<system:String x:Key="windowMode">Mode fenêtré</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/it.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Tema</system:String>
<system:String x:Key="browserMoreThemes">Sfoglia per altri temi</system:String>
<system:String x:Key="helloFlowLauncher">Hello Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Font campo di ricerca</system:String>
<system:String x:Key="resultItemFont">Font campo risultati</system:String>
<system:String x:Key="windowMode">Modalità finestra</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/ja.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">テーマ</system:String>
<system:String x:Key="browserMoreThemes">テーマを探す</system:String>
<system:String x:Key="helloFlowLauncher">こんにちは Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">検索ボックスのフォント</system:String>
<system:String x:Key="resultItemFont">検索結果一覧のフォント</system:String>
<system:String x:Key="windowMode">ウィンドウモード</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/ko.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">테마</system:String>
<system:String x:Key="browserMoreThemes">테마 더 찾아보기</system:String>
<system:String x:Key="helloFlowLauncher">Hello Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">쿼리 상자 글꼴</system:String>
<system:String x:Key="resultItemFont">결과 항목 글꼴</system:String>
<system:String x:Key="windowMode">윈도우 모드</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/nb-NO.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Tema</system:String>
<system:String x:Key="browserMoreThemes">Finn flere temaer</system:String>
<system:String x:Key="helloFlowLauncher">Hallo Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Font for spørringsboks</system:String>
<system:String x:Key="resultItemFont">Font for resultat</system:String>
<system:String x:Key="windowMode">Vindusmodus</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/nl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Thema</system:String>
<system:String x:Key="browserMoreThemes">Zoek meer thema´s</system:String>
<system:String x:Key="helloFlowLauncher">Hallo Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Query Box lettertype</system:String>
<system:String x:Key="resultItemFont">Resultaat Item lettertype</system:String>
<system:String x:Key="windowMode">Window Mode</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/pl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Skórka</system:String>
<system:String x:Key="browserMoreThemes">Znajdź więcej skórek</system:String>
<system:String x:Key="helloFlowLauncher">Witaj Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Czcionka okna zapytania</system:String>
<system:String x:Key="resultItemFont">Czcionka okna wyników</system:String>
<system:String x:Key="windowMode">Tryb w oknie</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/pt-br.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Tema</system:String>
<system:String x:Key="browserMoreThemes">Ver mais temas</system:String>
<system:String x:Key="helloFlowLauncher">Olá Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Fonte da caixa de Consulta</system:String>
<system:String x:Key="resultItemFont">Fonte do Resultado</system:String>
<system:String x:Key="windowMode">Modo Janela</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/ru.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Темы</system:String>
<system:String x:Key="browserMoreThemes">Найти больше тем</system:String>
<system:String x:Key="helloFlowLauncher">Привет Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Шрифт запросов</system:String>
<system:String x:Key="resultItemFont">Шрифт результатов</system:String>
<system:String x:Key="windowMode">Оконный режим</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/sk.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Motív</system:String>
<system:String x:Key="browserMoreThemes">Prehliadať viac motívov</system:String>
<system:String x:Key="helloFlowLauncher">Ahoj Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Písmo poľa pre dopyt</system:String>
<system:String x:Key="resultItemFont">Písmo výsledkov</system:String>
<system:String x:Key="windowMode">Režim okno</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/sr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Tema</system:String>
<system:String x:Key="browserMoreThemes">Pretražite još tema</system:String>
<system:String x:Key="helloFlowLauncher">Zdravo Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Font upita</system:String>
<system:String x:Key="resultItemFont">Font rezultata</system:String>
<system:String x:Key="windowMode">Režim prozora</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/tr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Temalar</system:String>
<system:String x:Key="browserMoreThemes">Daha fazla tema bul</system:String>
<system:String x:Key="helloFlowLauncher">Merhaba Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Pencere Yazı Tipi</system:String>
<system:String x:Key="resultItemFont">Sonuç Yazı Tipi</system:String>
<system:String x:Key="windowMode">Pencere Modu</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/uk-UA.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--Setting Theme-->
<system:String x:Key="theme">Теми</system:String>
<system:String x:Key="browserMoreThemes">Знайти більше тем</system:String>
<system:String x:Key="helloFlowLauncher">Привіт Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">Шрифт запитів</system:String>
<system:String x:Key="resultItemFont">Шрифт результатів</system:String>
<system:String x:Key="windowMode">Віконний режим</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
<!--设置,主题-->
<system:String x:Key="theme">主题</system:String>
<system:String x:Key="browserMoreThemes">浏览更多主题</system:String>
<system:String x:Key="helloFlowLauncher">你好,Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">查询框字体</system:String>
<system:String x:Key="resultItemFont">结果项字体</system:String>
<system:String x:Key="windowMode">窗口模式</system:String>
Expand Down
1 change: 0 additions & 1 deletion Flow.Launcher/Languages/zh-tw.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<!--設定,主題-->
<system:String x:Key="theme">主題</system:String>
<system:String x:Key="browserMoreThemes">瀏覽更多主題</system:String>
<system:String x:Key="helloFlowLauncher">你好,Flow Launcher</system:String>
<system:String x:Key="queryBoxFont">查詢框字體</system:String>
<system:String x:Key="resultItemFont">結果項字體</system:String>
<system:String x:Key="windowMode">視窗模式</system:String>
Expand Down
Loading

0 comments on commit 0d9c956

Please sign in to comment.