Skip to content

Import Theme Size / Select Default Font / Small Design Fixes #3458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f8d82f3
Change default query font size
onesounds Apr 11, 2025
6264447
Change theme reset value
onesounds Apr 12, 2025
1b8336b
Adjust Theme Color
onesounds Apr 12, 2025
13aa475
- Change default font logic
onesounds Apr 12, 2025
051b6bb
Add a message stating that the backdrop is not applied to the Preview
onesounds Apr 12, 2025
fbe6e10
Merge Dev
onesounds Apr 12, 2025
49e0055
Adjust backdrop info
onesounds Apr 12, 2025
2cf7f97
Add Import Function
onesounds Apr 12, 2025
6ab2df6
Change to prioritize Noto Sans font if it is available.
onesounds Apr 12, 2025
06b105b
Adjust Query Font Size
onesounds Apr 12, 2025
5ebe2d8
Adjust Query Font Size
onesounds Apr 12, 2025
fd0f137
Merge remote-tracking branch 'origin/250412-ImportThemePreset' into 2…
onesounds Apr 12, 2025
664cbb5
Apply Noto Sans fonts based on system language with dynamic mapping
onesounds Apr 12, 2025
6b267c4
Adjust Button Margin
onesounds Apr 12, 2025
74d6eed
Adjust Combobox Control
onesounds Apr 13, 2025
c828c33
Change Combobox design
onesounds Apr 13, 2025
4ed9137
- Move some value to base.xaml
onesounds Apr 13, 2025
643e531
Merge branch 'dev' into 250412-ImportThemePreset
onesounds Apr 13, 2025
3d96a36
Fix Preview CornerRadius (Get BasedOn Style)
onesounds Apr 13, 2025
e7a3226
Merge remote-tracking branch 'origin/250412-ImportThemePreset' into 2…
onesounds Apr 13, 2025
e4fbce4
Adjust Scrollbar color and win11light theme
onesounds Apr 13, 2025
b2a3782
Merge branch 'dev' into 250412-ImportThemePreset
onesounds Apr 14, 2025
9981fab
Merge branch 'dev' into 250412-ImportThemePreset
onesounds Apr 17, 2025
d045c49
Merge branch 'dev' into 250412-ImportThemePreset
onesounds Apr 17, 2025
1cd6998
Cleanup codes
Jack251970 Apr 17, 2025
5cea434
Merge branch '250412-ImportThemePreset' of https://github.com/onesoun…
Jack251970 Apr 17, 2025
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
37 changes: 25 additions & 12 deletions Flow.Launcher.Core/Resource/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private ResourceDictionary GetResourceDictionary(string theme)
return dict;
}

private ResourceDictionary GetCurrentResourceDictionary()
public ResourceDictionary GetCurrentResourceDictionary()
{
return GetResourceDictionary(_settings.Theme);
}
Expand Down Expand Up @@ -772,22 +772,18 @@ private void ApplyPreviewBackground(Color? bgColor = null)
{
if (bgColor == null) return;

// Copy the existing WindowBorderStyle
// Create a new Style for the preview
var previewStyle = new Style(typeof(Border));
if (Application.Current.Resources.Contains("WindowBorderStyle"))

// Get the original WindowBorderStyle
if (Application.Current.Resources.Contains("WindowBorderStyle") &&
Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
{
if (Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
{
foreach (var setter in originalStyle.Setters.OfType<Setter>())
{
previewStyle.Setters.Add(new Setter(setter.Property, setter.Value));
}
}
// Copy the original style, including the base style if it exists
CopyStyle(originalStyle, previewStyle);
}

// Apply background color (remove transparency in color)
// WPF does not allow the use of an acrylic brush within the window's internal area,
// so transparency effects are not applied to the preview.
Color backgroundColor = Color.FromRgb(bgColor.Value.R, bgColor.Value.G, bgColor.Value.B);
previewStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(backgroundColor)));

Expand All @@ -798,9 +794,26 @@ private void ApplyPreviewBackground(Color? bgColor = null)
previewStyle.Setters.Add(new Setter(Border.CornerRadiusProperty, new CornerRadius(5)));
previewStyle.Setters.Add(new Setter(Border.BorderThicknessProperty, new Thickness(1)));
}

// Set the new style to the resource
Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle;
}

private void CopyStyle(Style originalStyle, Style targetStyle)
{
// If the style is based on another style, copy the base style first
if (originalStyle.BasedOn != null)
{
CopyStyle(originalStyle.BasedOn, targetStyle);
}

// Copy the setters from the original style
foreach (var setter in originalStyle.Setters.OfType<Setter>())
{
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
}
}

private void ColorizeWindow(string theme, BackdropTypes backdropType)
{
var dict = GetThemeResourceDictionary(theme);
Expand Down
77 changes: 71 additions & 6 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text.Json.Serialization;
using System.Windows;
using System.Windows.Media;
using CommunityToolkit.Mvvm.DependencyInjection;
using Flow.Launcher.Infrastructure.Hotkey;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
using Flow.Launcher.ViewModel;
using SystemFonts = System.Windows.SystemFonts;

namespace Flow.Launcher.Infrastructure.UserSettings
{
Expand All @@ -34,6 +39,66 @@ public void Save()
}

private string language = Constant.SystemLanguageCode;
private static readonly Dictionary<string, string> LanguageToNotoSans = new()
{
{ "ko", "Noto Sans KR" },
{ "ja", "Noto Sans JP" },
{ "zh-CN", "Noto Sans SC" },
{ "zh-SG", "Noto Sans SC" },
{ "zh-Hans", "Noto Sans SC" },
{ "zh-TW", "Noto Sans TC" },
{ "zh-HK", "Noto Sans TC" },
{ "zh-MO", "Noto Sans TC" },
{ "zh-Hant", "Noto Sans TC" },
{ "th", "Noto Sans Thai" },
{ "ar", "Noto Sans Arabic" },
{ "he", "Noto Sans Hebrew" },
{ "hi", "Noto Sans Devanagari" },
{ "bn", "Noto Sans Bengali" },
{ "ta", "Noto Sans Tamil" },
{ "el", "Noto Sans Greek" },
{ "ru", "Noto Sans" },
{ "en", "Noto Sans" },
{ "fr", "Noto Sans" },
{ "de", "Noto Sans" },
{ "es", "Noto Sans" },
{ "pt", "Noto Sans" }
};

public static string GetSystemDefaultFont()
{
try
{
var culture = CultureInfo.CurrentCulture;
var language = culture.Name; // e.g., "zh-TW"
var langPrefix = language.Split('-')[0]; // e.g., "zh"

// First, try to find by full name, and if not found, fallback to prefix
if (TryGetNotoFont(language, out var notoFont) || TryGetNotoFont(langPrefix, out notoFont))
{
if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont)))
return notoFont;
}

var font = SystemFonts.MessageFontFamily;
if (font.FamilyNames.TryGetValue(System.Windows.Markup.XmlLanguage.GetLanguage("en-US"), out var englishName))
{
return englishName;
}

return font.Source ?? "Segoe UI";
}
catch
{
return "Segoe UI";
}
}

private static bool TryGetNotoFont(string langKey, out string notoFont)
{
return LanguageToNotoSans.TryGetValue(langKey, out notoFont);
}

private string _theme = Constant.DefaultTheme;
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
Expand Down Expand Up @@ -82,18 +147,18 @@ public string Theme
/* Appearance Settings. It should be separated from the setting later.*/
public double WindowHeightSize { get; set; } = 42;
public double ItemHeightSize { get; set; } = 58;
public double QueryBoxFontSize { get; set; } = 20;
public double QueryBoxFontSize { get; set; } = 16;
public double ResultItemFontSize { get; set; } = 16;
public double ResultSubItemFontSize { get; set; } = 13;
public string QueryBoxFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string QueryBoxFont { get; set; } = GetSystemDefaultFont();
public string QueryBoxFontStyle { get; set; }
public string QueryBoxFontWeight { get; set; }
public string QueryBoxFontStretch { get; set; }
public string ResultFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string ResultFont { get; set; } = GetSystemDefaultFont();
public string ResultFontStyle { get; set; }
public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; }
public string ResultSubFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string ResultSubFont { get; set; } = GetSystemDefaultFont();
public string ResultSubFontStyle { get; set; }
public string ResultSubFontWeight { get; set; }
public string ResultSubFontStretch { get; set; }
Expand All @@ -116,7 +181,7 @@ public string Theme
public double? SettingWindowLeft { get; set; } = null;
public WindowState SettingWindowState { get; set; } = WindowState.Normal;

bool _showPlaceholder { get; set; } = false;
bool _showPlaceholder { get; set; } = true;
public bool ShowPlaceholder
{
get => _showPlaceholder;
Expand All @@ -142,7 +207,6 @@ public string PlaceholderText
}
}
}

public int CustomExplorerIndex { get; set; } = 0;

[JsonIgnore]
Expand Down Expand Up @@ -487,4 +551,5 @@ public enum BackdropTypes
Mica,
MicaAlt
}

}
4 changes: 4 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@
<system:String x:Key="resultItemFont">Result Title Font</system:String>
<system:String x:Key="resultSubItemFont">Result Subtitle Font</system:String>
<system:String x:Key="resetCustomize">Reset</system:String>
<system:String x:Key="resetCustomizeToolTip">Reset to the recommended font and size settings.</system:String>
<system:String x:Key="ImportThemeSize">Import Theme Size</system:String>
<system:String x:Key="ImportThemeSizeToolTip">If a size value intended by the theme designer is available, it will be retrieved and applied.</system:String>
<system:String x:Key="CustomizeToolTip">Customize</system:String>
<system:String x:Key="windowMode">Window Mode</system:String>
<system:String x:Key="opacity">Opacity</system:String>
Expand Down Expand Up @@ -226,6 +229,7 @@
<system:String x:Key="Clock">Clock</system:String>
<system:String x:Key="Date">Date</system:String>
<system:String x:Key="BackdropType">Backdrop Type</system:String>
<system:String x:Key="BackdropInfo">The backdrop effect is not applied in the preview.</system:String>
<system:String x:Key="BackdropTypeDisabledToolTip">Backdrop supported starting from Windows 11 build 22000 and above</system:String>
<system:String x:Key="BackdropTypesNone">None</system:String>
<system:String x:Key="BackdropTypesAcrylic">Acrylic</system:String>
Expand Down
57 changes: 38 additions & 19 deletions Flow.Launcher/Resources/CustomControlTemplate.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -755,25 +755,41 @@
<ControlTemplate TargetType="ComboBoxItem">
<Border
x:Name="LayoutRoot"
Margin="0 2 0 2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="True">
<ContentPresenter
x:Name="ContentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border
x:Name="ComboBullet"
Grid.Column="0"
Width="3"
Height="14"
Background="Transparent"
CornerRadius="2" />
<ContentPresenter
x:Name="ContentPresenter"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundPointerOver}" />
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource CustomComboItemHoverBG}" />
<Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushPointerOver}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundPointerOver}" />
</MultiTrigger>
Expand All @@ -792,7 +808,8 @@
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsFocused" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelected}" />
<Setter TargetName="ComboBullet" Property="Background" Value="{StaticResource SystemControlBackgroundAccentBrush}" />
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource CustomComboItemHoverBG}" />
<Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelected}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelected}" />
</MultiTrigger>
Expand All @@ -802,7 +819,8 @@
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedUnfocused}" />
<Setter TargetName="ComboBullet" Property="Background" Value="{StaticResource SystemControlBackgroundAccentBrush}" />
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource CustomComboItemHoverBG}" />
<Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedUnfocused}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedUnfocused}" />
</MultiTrigger>
Expand All @@ -822,7 +840,7 @@
<Condition Property="IsSelected" Value="True" />
<Condition Property="IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource ComboBoxItemBackgroundSelectedPointerOver}" />
<Setter TargetName="LayoutRoot" Property="Background" Value="{DynamicResource CustomComboItemSelectedHoverBG}" />
<Setter TargetName="LayoutRoot" Property="BorderBrush" Value="{DynamicResource ComboBoxItemBorderBrushSelectedPointerOver}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource ComboBoxItemForegroundSelectedPointerOver}" />
</MultiTrigger>
Expand Down Expand Up @@ -1103,7 +1121,8 @@
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=Background}"
PopupAnimation="None">
PopupAnimation="None"
VerticalOffset="-1">
<Popup.PlacementRectangle>
<MultiBinding>
<MultiBinding.Converter>
Expand All @@ -1123,11 +1142,11 @@
<Border
x:Name="PopupBorder"
HorizontalAlignment="Stretch"
Background="{DynamicResource PopUpBorderBG}"
CornerRadius="{DynamicResource OverlayCornerRadius}">
Background="{DynamicResource CustomPopUpBorderBG}"
CornerRadius="5">
<Border
Padding="{DynamicResource ComboBoxDropdownBorderPadding}"
BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}"
Padding="5"
BorderBrush="{DynamicResource CustomComboBorder}"
BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}"
CornerRadius="{Binding ElementName=PopupBorder, Path=CornerRadius}">
<ScrollViewer
Expand All @@ -1137,7 +1156,7 @@
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
Margin="0"
KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
Expand All @@ -1157,8 +1176,8 @@
<!-- Pressed -->
<Trigger SourceName="ToggleButton" Property="IsPressed" Value="True">
<Setter TargetName="Background" Property="Background" Value="{DynamicResource CustomComboPressedBG}" />
<Setter TargetName="Background" Property="BorderThickness" Value="0" />
<Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource ComboBoxBorderBrushPressed}" />
<Setter TargetName="Background" Property="BorderThickness" Value="0 0 0 1" />
<Setter TargetName="Background" Property="BorderBrush" Value="{DynamicResource CustomComboPressedOutLine}" />
<Setter TargetName="OutLine" Property="BorderBrush" Value="{DynamicResource CustomComboPressedOutLine}" />
<Setter TargetName="OutLine" Property="BorderThickness" Value="{DynamicResource PressedCustomComboOutlineThickness}" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource CustomComboPressedText}" />
Expand Down
Loading
Loading