Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c94e47b
- Adjust Themes
onesounds May 18, 2024
2b14bc4
Fix font Size
onesounds May 18, 2024
e87af5d
Adjust Height win11System
onesounds May 20, 2024
6abc95d
Merge Dev
onesounds May 28, 2024
82e9944
Rename Theme
onesounds May 28, 2024
498a9cb
Merge branch 'dev' into 240518Adjusthemes
onesounds May 29, 2024
e060e2f
- Change Default Theme Name (win11Light to win11System)
onesounds May 29, 2024
8287525
Merge branch '240518Adjusthemes' of https://github.com/onesounds/Flow…
onesounds May 29, 2024
3be0e44
Merge FixPreviewPanel
onesounds May 31, 2024
7c07317
Merge branch 'dev' into 240518Adjusthemes
onesounds May 31, 2024
7bd6393
Merge branch 'dev' into 240518Adjusthemes
onesounds May 31, 2024
a8fae4d
Merge branch 'dev' into 240518Adjusthemes
onesounds Jun 2, 2024
4ec7647
Add theme metadata
Yusyuriv Jun 2, 2024
f78521e
Merge branch 'add-theme-metadata' into 240518Adjusthemes
onesounds Jun 2, 2024
20b0db3
- Change BlurAmount to Bool
onesounds Jun 2, 2024
ebe824b
Rollback Default theme to win11light from win11system
onesounds Jun 2, 2024
ea532a3
Add Theme Info
onesounds Jun 2, 2024
e28626a
Adjust Theme List Style
onesounds Jun 2, 2024
aedb2d4
Add Selected Item TextBlock
onesounds Jun 2, 2024
4dcb35e
Convert SelectedTheme from string to record
Yusyuriv Jun 2, 2024
0d9f207
Add FontIcon
onesounds Jun 2, 2024
3a7f595
- Adjust Themes / Preview Margin
onesounds Jun 2, 2024
f38d1cb
Adjust Window11
onesounds Jun 2, 2024
da38172
Adjunst Windonws11 theme
onesounds Jun 2, 2024
f58c950
Theme metadata adjustments
Yusyuriv Jun 3, 2024
b37f21a
Fix Wrong Item Focusing
onesounds Jun 3, 2024
3bcd269
Revert "Fix Wrong Item Focusing"
onesounds Jun 3, 2024
f32e2bc
Adjust System Themes Color
onesounds Jun 3, 2024
8fa9897
Merge branch 'dev' into 240518Adjusthemes
onesounds Jun 3, 2024
d35c96d
Adjust Color
onesounds Jun 3, 2024
7df9826
Merge branch 'dev' into 240518Adjusthemes
onesounds Jun 3, 2024
b1ddc2c
Adjust Theme Editor Size when IsChcked
onesounds Jun 3, 2024
75c46d6
Remove Preview BorderClip
onesounds Jun 3, 2024
87c5a17
Fix BorderClip for Last Item when Preview Open in Full Width Selection
onesounds Jun 3, 2024
4865ae3
Fixed scroll wheel not working in the theme list
onesounds Jun 3, 2024
2fae06d
Merge branch 'dev' into 240518Adjusthemes
onesounds Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 55 additions & 12 deletions Flow.Launcher.Core/Resource/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
Expand All @@ -17,6 +18,10 @@ namespace Flow.Launcher.Core.Resource
{
public class Theme
{
private const string ThemeMetadataNamePrefix = "Name:";
private const string ThemeMetadataIsDarkPrefix = "IsDark:";
private const string ThemeMetadataHasBlurPrefix = "HasBlur:";

private const int ShadowExtraMargin = 32;

private readonly List<string> _themeDirectories = new List<string>();
Expand Down Expand Up @@ -79,14 +84,14 @@ public bool ChangeTheme(string theme)
{
if (string.IsNullOrEmpty(path))
throw new DirectoryNotFoundException("Theme path can't be found <{path}>");

// reload all resources even if the theme itself hasn't changed in order to pickup changes
// to things like fonts
UpdateResourceDictionary(GetResourceDictionary(theme));

Settings.Theme = theme;


//always allow re-loading default theme, in case of failure of switching to a new theme from default theme
if (_oldTheme != theme || theme == defaultTheme)
{
Expand Down Expand Up @@ -148,7 +153,7 @@ private ResourceDictionary GetThemeResourceDictionary(string theme)
public ResourceDictionary GetResourceDictionary(string theme)
{
var dict = GetThemeResourceDictionary(theme);

if (dict["QueryBoxStyle"] is Style queryBoxStyle &&
dict["QuerySuggestionBoxStyle"] is Style querySuggestionBoxStyle)
{
Expand Down Expand Up @@ -187,7 +192,7 @@ public ResourceDictionary GetResourceDictionary(string theme)

Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(
new[] { resultItemStyle, resultItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
new[] { resultItemStyle, resultItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
=> Array.ForEach(setters, p => o.Setters.Add(p)));
}

Expand Down Expand Up @@ -219,17 +224,53 @@ private ResourceDictionary GetCurrentResourceDictionary( )
return GetResourceDictionary(Settings.Theme);
}

public List<string> LoadAvailableThemes()
public List<ThemeData> LoadAvailableThemes()
{
List<string> themes = new List<string>();
List<ThemeData> themes = new List<ThemeData>();
foreach (var themeDirectory in _themeDirectories)
{
themes.AddRange(
Directory.GetFiles(themeDirectory)
.Where(filePath => filePath.EndsWith(Extension) && !filePath.EndsWith("Base.xaml"))
.ToList());
var filePaths = Directory
.GetFiles(themeDirectory)
.Where(filePath => filePath.EndsWith(Extension) && !filePath.EndsWith("Base.xaml"))
.Select(GetThemeDataFromPath);
themes.AddRange(filePaths);
}
return themes.OrderBy(o => o).ToList();

return themes.OrderBy(o => o.Name).ToList();
}

private ThemeData GetThemeDataFromPath(string path)
{
using var reader = XmlReader.Create(path);
reader.Read();

var extensionlessName = Path.GetFileNameWithoutExtension(path);

if (reader.NodeType is not XmlNodeType.Comment)
return new ThemeData(extensionlessName, extensionlessName);

var commentLines = reader.Value.Trim().Split('\n').Select(v => v.Trim());

var name = extensionlessName;
bool? isDark = null;
bool? hasBlur = null;
foreach (var line in commentLines)
{
if (line.StartsWith(ThemeMetadataNamePrefix, StringComparison.OrdinalIgnoreCase))
{
name = line.Remove(0, ThemeMetadataNamePrefix.Length).Trim();
}
else if (line.StartsWith(ThemeMetadataIsDarkPrefix, StringComparison.OrdinalIgnoreCase))
{
isDark = bool.Parse(line.Remove(0, ThemeMetadataIsDarkPrefix.Length).Trim());
}
else if (line.StartsWith(ThemeMetadataHasBlurPrefix, StringComparison.OrdinalIgnoreCase))
{
hasBlur = bool.Parse(line.Remove(0, ThemeMetadataHasBlurPrefix.Length).Trim());
}
}

return new ThemeData(extensionlessName, name, isDark, hasBlur);
}

private string GetThemePath(string themeName)
Expand Down Expand Up @@ -407,5 +448,7 @@ private void SetWindowAccent(Window w, AccentState state)
Marshal.FreeHGlobal(accentPtr);
}
#endregion

public record ThemeData(string FileNameWithoutExtension, string Name, bool? IsDark = null, bool? HasBlur = null);
}
}
2 changes: 1 addition & 1 deletion Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public string Theme
OnPropertyChanged(nameof(MaxResultsToShow));
}
}
public bool UseDropShadowEffect { get; set; } = false;
public bool UseDropShadowEffect { get; set; } = true;

/* Appearance Settings. It should be separated from the setting later.*/
public double WindowHeightSize { get; set; } = 42;
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<ui:XamlControlsResources />
<ResourceDictionary Source="pack://application:,,,/Resources/CustomControlTemplate.xaml" />
<ResourceDictionary Source="pack://application:,,,/Resources/SettingWindowStyle.xaml" />
<ResourceDictionary Source="pack://application:,,,/Themes/Win11System.xaml" />
<ResourceDictionary Source="pack://application:,,,/Themes/Win11Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/Languages/en.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
Expand Down
Loading