Merge pull request #3458 from onesounds/250412-ImportThemePreset

Import Theme Size / Select Default Font / Small Design Fixes
This commit is contained in:
DB P 2025-04-18 08:46:58 +09:00 committed by GitHub
commit 05919704d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 320 additions and 92 deletions

View file

@ -325,7 +325,7 @@ namespace Flow.Launcher.Core.Resource
return dict;
}
private ResourceDictionary GetCurrentResourceDictionary()
public ResourceDictionary GetCurrentResourceDictionary()
{
return GetResourceDictionary(_settings.Theme);
}
@ -772,22 +772,18 @@ namespace Flow.Launcher.Core.Resource
{
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)));
@ -798,9 +794,26 @@ namespace Flow.Launcher.Core.Resource
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);

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Text.Json.Serialization;
using System.Windows;
using CommunityToolkit.Mvvm.DependencyInjection;
@ -32,8 +31,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
{
_storage.Save();
}
private string language = Constant.SystemLanguageCode;
private string _theme = Constant.DefaultTheme;
public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}";
public string OpenResultModifiers { get; set; } = KeyConstant.Alt;
@ -54,12 +52,13 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public string CycleHistoryUpHotkey { get; set; } = $"{KeyConstant.Alt} + Up";
public string CycleHistoryDownHotkey { get; set; } = $"{KeyConstant.Alt} + Down";
private string _language = Constant.SystemLanguageCode;
public string Language
{
get => language;
get => _language;
set
{
language = value;
_language = value;
OnPropertyChanged();
}
}
@ -82,18 +81,18 @@ namespace Flow.Launcher.Infrastructure.UserSettings
/* 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; } = Win32Helper.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; } = Win32Helper.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; } = Win32Helper.GetSystemDefaultFont();
public string ResultSubFontStyle { get; set; }
public string ResultSubFontWeight { get; set; }
public string ResultSubFontStretch { get; set; }
@ -116,7 +115,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public double? SettingWindowLeft { get; set; } = null;
public WindowState SettingWindowState { get; set; } = WindowState.Normal;
bool _showPlaceholder { get; set; } = false;
private bool _showPlaceholder { get; set; } = true;
public bool ShowPlaceholder
{
get => _showPlaceholder;
@ -129,7 +128,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
}
}
}
string _placeholderText { get; set; } = string.Empty;
private string _placeholderText { get; set; } = string.Empty;
public string PlaceholderText
{
get => _placeholderText;
@ -142,7 +141,6 @@ namespace Flow.Launcher.Infrastructure.UserSettings
}
}
}
public int CustomExplorerIndex { get; set; } = 0;
[JsonIgnore]
@ -309,7 +307,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public bool StartFlowLauncherOnSystemStartup { get; set; } = false;
public bool UseLogonTaskForStartup { get; set; } = false;
public bool HideOnStartup { get; set; } = true;
bool _hideNotifyIcon { get; set; }
private bool _hideNotifyIcon;
public bool HideNotifyIcon
{
get => _hideNotifyIcon;

View file

@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using Flow.Launcher.Infrastructure.UserSettings;
using Microsoft.Win32;
@ -14,6 +17,7 @@ using Windows.Win32.Graphics.Dwm;
using Windows.Win32.UI.Input.KeyboardAndMouse;
using Windows.Win32.UI.WindowsAndMessaging;
using Point = System.Windows.Point;
using SystemFonts = System.Windows.SystemFonts;
namespace Flow.Launcher.Infrastructure
{
@ -595,5 +599,73 @@ namespace Flow.Launcher.Infrastructure
}
#endregion
#region System Font
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 the font is installed, return it
if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont)))
{
return notoFont;
}
}
// If Noto font is not found, fallback to the system default font
var font = SystemFonts.MessageFontFamily;
if (font.FamilyNames.TryGetValue(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);
}
#endregion
}
}

View file

@ -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>
@ -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>

View file

@ -755,17 +755,33 @@
<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>
@ -773,7 +789,7 @@
<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>
@ -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>
@ -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>
@ -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>
@ -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>
@ -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
@ -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>
@ -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}" />

View file

@ -13,13 +13,14 @@
<SolidColorBrush x:Key="SubTitleSelectedForeground" Color="#33FFFFFF" />
<SolidColorBrush x:Key="SearchIconForeground" Color="#33FFFFFF" />
<SolidColorBrush x:Key="SeparatorForeground" Color="#24FFFFFF" />
<SolidColorBrush x:Key="ThumbColor" Color="#9a9a9a" />
<SolidColorBrush x:Key="ThumbColor" Color="#28F7F3FF" />
<SolidColorBrush x:Key="InlineHighlight" Color="#0078d7" />
<SolidColorBrush x:Key="HotkeyForeground" Color="#33FFFFFF" />
<SolidColorBrush x:Key="HotkeySelectedForeground" Color="#33FFFFFF" />
<SolidColorBrush x:Key="ClockDateForeground" Color="#26FFFFFF" />
<Color x:Key="ItemSelectedBackgroundColorBrush">#198F8F8F</Color>
<SolidColorBrush x:Key="BasicSystemAccentColor" Color="{m:DynamicColor SystemAccentColorLight1}" />
<SolidColorBrush x:Key="Color00B" Color="#2b2b2b" />
<SolidColorBrush x:Key="Color01B" Color="#202020" />
@ -159,8 +160,14 @@
<m:StaticResource x:Key="CustomComboOutline" ResourceKey="Color13B" />
<m:StaticResource x:Key="CustomComboInline" ResourceKey="Color21B" />
<m:StaticResource x:Key="PopUpBorderBG" ResourceKey="Color07B" />
<SolidColorBrush x:Key="CustomPopUpBorderBG" Color="#373737" />
<SolidColorBrush x:Key="CustomComboBorder" Color="#3f3f3f" />
<m:StaticResource x:Key="CustomComboHoverBG" ResourceKey="Color22B" />
<m:StaticResource x:Key="CustomComboPressedBG" ResourceKey="Color23B" />
<SolidColorBrush x:Key="CustomComboItemHoverBG" Color="#4E4E4E" />
<SolidColorBrush x:Key="CustomComboItemSelectedHoverBG" Color="#484848" />
<m:StaticResource x:Key="CustomComboPressedOutLine" ResourceKey="Color19B" />
<m:StaticResource x:Key="CustomComboPressedText" ResourceKey="Color08B" />
<m:StaticResource x:Key="CustomComboDisabledBG" ResourceKey="Color07B" />

View file

@ -13,14 +13,16 @@
<SolidColorBrush x:Key="SubTitleSelectedForeground" Color="#72767d" />
<SolidColorBrush x:Key="SearchIconForeground" Color="#20000000" />
<SolidColorBrush x:Key="SeparatorForeground" Color="#20000000" />
<SolidColorBrush x:Key="ThumbColor" Color="#868686" />
<SolidColorBrush x:Key="ThumbColor" Color="#1F000000" />
<SolidColorBrush x:Key="InlineHighlight" Color="#0078d7" />
<SolidColorBrush x:Key="HotkeyForeground" Color="#51000000" />
<SolidColorBrush x:Key="HotkeySelectedForeground" Color="#51000000" />
<SolidColorBrush x:Key="ClockDateForeground" Color="#44000000" />
<Color x:Key="ItemSelectedBackgroundColorBrush">#0C000000</Color>
<Color x:Key="ItemSelectedBackgroundColorBrush">#7EFFFFFF</Color>
<SolidColorBrush x:Key="Color00B" Color="#fbfbfb" />
<SolidColorBrush x:Key="BasicSystemAccentColor" Color="{m:DynamicColor SystemAccentColor}" />
<SolidColorBrush x:Key="Color00B" Color="#CEFAFAFA" />
<SolidColorBrush x:Key="Color01B" Color="#f3f3f3" />
<SolidColorBrush x:Key="Color02B" Color="#ffffff" />
<SolidColorBrush x:Key="Color03B" Color="#e5e5e5" />
@ -153,8 +155,17 @@
<m:StaticResource x:Key="CustomComboOutline" ResourceKey="Color13B" />
<m:StaticResource x:Key="CustomComboInline" ResourceKey="Color21B" />
<m:StaticResource x:Key="PopUpBorderBG" ResourceKey="Color07B" />
<SolidColorBrush x:Key="CustomPopUpBorderBG" Color="#f6f6f6" />
<SolidColorBrush
x:Key="CustomComboBorder"
Opacity="0.14"
Color="#000000" />
<m:StaticResource x:Key="CustomComboHoverBG" ResourceKey="Color07B" />
<m:StaticResource x:Key="CustomComboPressedBG" ResourceKey="Color07B" />
<SolidColorBrush x:Key="CustomComboItemHoverBG" Color="#E5E5E5" />
<SolidColorBrush x:Key="CustomComboItemSelectedHoverBG" Color="#D9D9D9" />
<m:StaticResource x:Key="CustomComboPressedOutLine" ResourceKey="Color13B" />
<m:StaticResource x:Key="CustomComboPressedText" ResourceKey="Color08B" />
<m:StaticResource x:Key="CustomComboDisabledBG" ResourceKey="Color07B" />
@ -165,7 +176,7 @@
<Thickness x:Key="CustomComboOutlineThickness">1,1,1,0</Thickness>
<Thickness x:Key="CustomComboInlineThickness">0,0,0,2</Thickness>
<Thickness x:Key="PressedCustomComboOutlineThickness">1,1,1,1</Thickness>
<Thickness x:Key="PressedCustomComboOutlineThickness">1,1,1,0</Thickness>
<Thickness x:Key="DisabledCustomComboOutlineThickness">1,1,1,1</Thickness>

View file

@ -180,8 +180,6 @@
<TextBlock
x:Name="Title"
Grid.Row="0"
Margin="0 0 0 1"
VerticalAlignment="Bottom"
DockPanel.Dock="Left"
FontSize="{Binding Settings.ResultItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
@ -200,8 +198,6 @@
<TextBlock
x:Name="SubTitle"
Grid.Row="1"
Margin="0 1 0 0"
VerticalAlignment="Top"
FontSize="{Binding Settings.ResultSubItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
Style="{DynamicResource ItemSubTitleStyle}"

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Globalization;
using System.IO;
using System.Linq;
@ -21,7 +22,7 @@ namespace Flow.Launcher.SettingPages.ViewModels;
public partial class SettingsPaneThemeViewModel : BaseModel
{
private const string DefaultFont = "Segoe UI";
private readonly string DefaultFont = Win32Helper.GetSystemDefaultFont();
public string BackdropSubText => !Win32Helper.IsBackdropSupported() ? App.API.GetTranslation("BackdropTypeDisabledToolTip") : "";
public Settings Settings { get; }
private readonly Theme _theme = Ioc.Default.GetRequiredService<Theme>();
@ -494,7 +495,7 @@ public partial class SettingsPaneThemeViewModel : BaseModel
{
SelectedQueryBoxFont = new FontFamily(DefaultFont);
SelectedQueryBoxFontFaces = new FamilyTypeface { Stretch = FontStretches.Normal, Weight = FontWeights.Normal, Style = FontStyles.Normal };
QueryBoxFontSize = 20;
QueryBoxFontSize = 16;
SelectedResultFont = new FontFamily(DefaultFont);
SelectedResultFontFaces = new FamilyTypeface { Stretch = FontStretches.Normal, Weight = FontWeights.Normal, Style = FontStyles.Normal };
@ -507,4 +508,56 @@ public partial class SettingsPaneThemeViewModel : BaseModel
WindowHeightSize = 42;
ItemHeightSize = 58;
}
[RelayCommand]
private void Import()
{
var resourceDictionary = _theme.GetCurrentResourceDictionary();
if (resourceDictionary["QueryBoxStyle"] is Style queryBoxStyle)
{
var fontSizeSetter = queryBoxStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBox.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
QueryBoxFontSize = fontSize;
}
var heightSetter = queryBoxStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == FrameworkElement.HeightProperty);
if (heightSetter?.Value is double height)
{
WindowHeightSize = height;
}
}
if (resourceDictionary["ResultItemHeight"] is double resultItemHeight)
{
ItemHeightSize = resultItemHeight;
}
if (resourceDictionary["ItemTitleStyle"] is Style itemTitleStyle)
{
var fontSizeSetter = itemTitleStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
ResultItemFontSize = fontSize;
}
}
if (resourceDictionary["ItemSubTitleStyle"] is Style itemSubTitleStyle)
{
var fontSizeSetter = itemSubTitleStyle.Setters
.OfType<Setter>()
.FirstOrDefault(setter => setter.Property == TextBlock.FontSizeProperty);
if (fontSizeSetter?.Value is double fontSize)
{
ResultSubItemFontSize = fontSize;
}
}
}
}

View file

@ -194,6 +194,7 @@
<cc:Card Title="{DynamicResource lastQueryMode}" Sub="{DynamicResource lastQueryModeToolTip}">
<ComboBox
MinWidth="210"
DisplayMemberPath="Display"
ItemsSource="{Binding LastQueryModes}"
SelectedValue="{Binding Settings.LastQueryMode}"

View file

@ -256,10 +256,17 @@
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Button
Margin="8"
Margin="12 8 12 4"
HorizontalAlignment="Stretch"
Command="{Binding ImportCommand}"
Content="{DynamicResource ImportThemeSize}"
ToolTip="{DynamicResource ImportThemeSizeToolTip}" />
<Button
Margin="12 4 12 12"
HorizontalAlignment="Stretch"
Command="{Binding ResetCommand}"
Content="{DynamicResource resetCustomize}" />
Content="{DynamicResource resetCustomize}"
ToolTip="{DynamicResource resetCustomizeToolTip}" />
</StackPanel>
</ScrollViewer>
</Border>
@ -305,7 +312,7 @@
<StackPanel VerticalAlignment="Center" DockPanel.Dock="Left">
<Border
Width="400"
Margin="40 30 0 30"
Margin="40 30 0 10"
SnapsToDevicePixels="True"
Style="{DynamicResource PreviewWindowBorderStyle}">
<Border BorderThickness="0" Style="{DynamicResource WindowRadius}">
@ -370,6 +377,17 @@
</Grid>
</Border>
</Border>
<Border
Margin="0 0 0 30"
Padding="8 4 8 4"
HorizontalAlignment="Center"
Background="#89000000"
CornerRadius="4">
<TextBlock
FontSize="10"
Foreground="#62FFFFFF"
Text="{DynamicResource BackdropInfo}" />
</Border>
</StackPanel>
</DockPanel>
</Border>

View file

@ -19,9 +19,9 @@
MouseDown="window_MouseDown"
ResizeMode="CanResize"
SnapsToDevicePixels="True"
UseLayoutRounding="True"
StateChanged="Window_StateChanged"
Top="{Binding SettingWindowTop, Mode=TwoWay}"
UseLayoutRounding="True"
WindowStartupLocation="Manual"
mc:Ignorable="d">
<WindowChrome.WindowChrome>

View file

@ -180,9 +180,13 @@
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#FFFFF8" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Margin" Value="0 0 0 1" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
<Style x:Key="BaseItemSubTitleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#D9D9D4" />
<Setter Property="Margin" Value="0 1 0 0" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="FontSize" Value="13" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
@ -215,10 +219,14 @@
<Style x:Key="BaseItemTitleSelectedStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#FFFFF8" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Margin" Value="0 0 0 1" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
<Style x:Key="BaseItemSubTitleSelectedStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#D9D9D4" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Margin" Value="0 1 0 0" />
<Setter Property="VerticalAlignment" Value="Top" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SubTitle, UpdateSourceTrigger=PropertyChanged, Path=Text.Length}" Value="0">
<Setter Property="Height" Value="0" />

View file

@ -14,8 +14,8 @@
</ResourceDictionary.MergedDictionaries>
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
<system:String x:Key="SystemBG">Auto</system:String>
<Color x:Key="LightBG">#E5E6E6E6</Color>
<Color x:Key="DarkBG">#DF1F1F1F</Color>
<Color x:Key="LightBG">#CEFAFAFA</Color>
<Color x:Key="DarkBG">#D6202020</Color>
<Style
x:Key="ItemGlyph"
BasedOn="{StaticResource BaseGlyphStyle}"

View file

@ -11,23 +11,23 @@
<Setter Property="Width" Value="46" />
</Style>
<Style x:Key="ImageIconStyle" TargetType="{x:Type Image}">
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="20" />
<Setter Property="Width" Value="20" />
</Style>
<Style
x:Key="ItemGlyph"
BasedOn="{StaticResource BaseGlyphStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="24" />
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
<Setter Property="Foreground" Value="#100f0f" />
</Style>
<Style
x:Key="QueryBoxStyle"
BasedOn="{StaticResource BaseQueryBoxStyle}"
TargetType="{x:Type TextBox}">
<Setter Property="Padding" Value="0,0,42,0" />
<Setter Property="Padding" Value="0 0 42 0" />
<Setter Property="Foreground" Value="#282728" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Height" Value="24" />
@ -37,7 +37,7 @@
x:Key="QuerySuggestionBoxStyle"
BasedOn="{StaticResource BaseQuerySuggestionBoxStyle}"
TargetType="{x:Type TextBox}">
<Setter Property="Padding" Value="0,0,42,0" />
<Setter Property="Padding" Value="0 0 42 0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Height" Value="24" />
<Setter Property="FontSize" Value="16" />
@ -50,7 +50,7 @@
TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="#bcbabd" />
<Setter Property="Background" Value="#edebee" />
<Setter Property="Background" Value="#FAFAFA" />
<Setter Property="CornerRadius" Value="6" />
<Setter Property="UseLayoutRounding" Value="True" />
</Style>
@ -68,6 +68,7 @@
x:Key="ItemTitleStyle"
BasedOn="{StaticResource BaseItemTitleStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="0" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="#100f0f" />
</Style>
@ -75,6 +76,7 @@
x:Key="ItemSubTitleStyle"
BasedOn="{StaticResource BaseItemSubTitleStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="0" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Foreground" Value="#8f8d90" />
</Style>
@ -84,7 +86,7 @@
TargetType="{x:Type Rectangle}">
<Setter Property="Fill" Value="#dedcde" />
<Setter Property="Height" Value="1" />
<Setter Property="Margin" Value="0,0,0,4" />
<Setter Property="Margin" Value="0 0 0 4" />
</Style>
<Style x:Key="HighlightStyle" />
<Style
@ -92,6 +94,7 @@
BasedOn="{StaticResource BaseItemTitleSelectedStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0" />
<Setter Property="Foreground" Value="#100f0f" />
</Style>
<Style
@ -99,6 +102,7 @@
BasedOn="{StaticResource BaseItemSubTitleSelectedStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="10" />
<Setter Property="Margin" Value="0" />
<Setter Property="Foreground" Value="#8f8d90" />
</Style>
<SolidColorBrush x:Key="ItemSelectedBackgroundColor">#d6d4d7</SolidColorBrush>
@ -113,7 +117,7 @@
<ControlTemplate TargetType="{x:Type Thumb}">
<Border
Width="4"
Margin="0,0,2,0"
Margin="0 0 2 0"
Background="#878687"
BorderBrush="Transparent"
BorderThickness="0"
@ -136,33 +140,49 @@
<Setter Property="Height" Value="24" />
</Style>
<Style x:Key="SearchIconPosition" TargetType="{x:Type Canvas}">
<Setter Property="Background" Value="#edebee" />
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="Margin" Value="0,0,8,0" />
<Setter Property="Margin" Value="0 0 8 0" />
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
<Style x:Key="PluginActivationIcon" TargetType="{x:Type Image}">
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="Margin" Value="0,0,8,0" />
<Setter Property="Margin" Value="0 0 8 0" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="ItemHotkeyStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontSize" Value="9" />
<Setter Property="Foreground" Value="#8f8d90" />
</Style>
<Style x:Key="ItemHotkeySelectedStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="12" />
<Setter Property="FontSize" Value="9" />
<Setter Property="Foreground" Value="#8f8d90" />
</Style>
<Style
x:Key="ItemHotkeyBGStyle"
BasedOn="{StaticResource BaseItemHotkeyBGStyle}"
TargetType="{x:Type Border}">
<Setter Property="Margin" Value="6 0 6 0" />
<Setter Property="Padding" Value="4 2 4 2" />
<Setter Property="CornerRadius" Value="2" />
</Style>
<Style
x:Key="ItemHotkeyBGSelectedStyle"
BasedOn="{StaticResource BaseItemHotkeyBGSelectedStyle}"
TargetType="{x:Type Border}">
<Setter Property="Margin" Value="6 0 6 0" />
<Setter Property="Padding" Value="4 2 4 2" />
<Setter Property="CornerRadius" Value="2" />
</Style>
<Style x:Key="ItemGlyphSelectedStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#100f0f" />
<Setter Property="Width" Value="24" />
<Setter Property="Height" Value="24" />
<Setter Property="FontSize" Value="24" />
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
<Setter Property="FontSize" Value="20" />
</Style>
<CornerRadius x:Key="ItemRadius">6</CornerRadius>
<Thickness x:Key="ItemMargin">4 0 4 0</Thickness>
@ -172,7 +192,7 @@
BasedOn="{StaticResource ClockPanel}"
TargetType="{x:Type StackPanel}">
<Setter Property="Orientation" Value="Horizontal" />
<Setter Property="Margin" Value="0,0,42,0" />
<Setter Property="Margin" Value="0 0 42 0" />
</Style>
<Style
x:Key="ClockBox"
@ -180,11 +200,11 @@
TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="#bebebe" />
<Setter Property="Margin" Value="0,0,10,0" />
<Setter Property="Margin" Value="0 0 10 0" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=DateBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0,0,10,3" />
<Setter Property="Margin" Value="0 0 10 3" />
</DataTrigger>
</Style.Triggers>
@ -198,7 +218,7 @@
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=ClockBox, Path=Visibility}" Value="Visible">
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0,0,0,3" />
<Setter Property="Margin" Value="0 0 0 3" />
</DataTrigger>
</Style.Triggers>
</Style>
@ -206,7 +226,7 @@
x:Key="PreviewBorderStyle"
BasedOn="{StaticResource BasePreviewBorderStyle}"
TargetType="{x:Type Border}">
<Setter Property="Margin" Value="0,0,10,8" />
<Setter Property="Margin" Value="0 0 10 8" />
<Setter Property="BorderBrush" Value="#dedcde" />
</Style>
<Style

View file

@ -14,8 +14,8 @@
</ResourceDictionary.MergedDictionaries>
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
<system:String x:Key="SystemBG">Auto</system:String>
<Color x:Key="LightBG">#BFFAFAFA</Color>
<Color x:Key="DarkBG">#DD202020</Color>
<Color x:Key="LightBG">#CEFAFAFA</Color>
<Color x:Key="DarkBG">#D6202020</Color>
<Style
x:Key="BulletStyle"
BasedOn="{StaticResource BaseBulletStyle}"
@ -31,14 +31,19 @@
<Setter Property="Width" Value="4" />
<Setter Property="Height" Value="38" />
<Setter Property="CornerRadius" Value="2" />
<Setter Property="Background" Value="{StaticResource SystemAccentColorLight1Brush}" />
<Setter Property="Background" Value="{DynamicResource BasicSystemAccentColor}" />
</Style>
<Style x:Key="ImageIconStyle" TargetType="{x:Type Image}">
<Setter Property="Height" Value="32" />
<Setter Property="Width" Value="32" />
<Setter Property="Margin" Value="-2 0 0 0" />
</Style>
<Style
x:Key="ItemGlyph"
BasedOn="{StaticResource BaseGlyphStyle}"
TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="{DynamicResource Color05B}" />
<Setter Property="Margin" Value="0 0 0 0" />
<Setter Property="Margin" Value="-2 0 0 0" />
</Style>
<Style
x:Key="QueryBoxStyle"
@ -48,7 +53,7 @@
<Setter Property="Foreground" Value="{DynamicResource Color05B}" />
<Setter Property="CaretBrush" Value="{DynamicResource Color05B}" />
<Setter Property="SelectionBrush" Value="{StaticResource SystemAccentColorLight1Brush}" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Height" Value="42" />
</Style>
@ -59,7 +64,7 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="0 0 50 0" />
<Setter Property="Height" Value="42" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value="{DynamicResource QuerySuggestionBoxForeground}" />
</Style>
@ -79,7 +84,9 @@
<Style
x:Key="PendingLineStyle"
BasedOn="{StaticResource BasePendingLineStyle}"
TargetType="{x:Type Line}" />
TargetType="{x:Type Line}">
<Setter Property="Stroke" Value="{DynamicResource BasicSystemAccentColor}" />
</Style>
<!-- Item Style -->
<Style
@ -180,7 +187,7 @@
<Setter Property="Foreground" Value="{DynamicResource Color05B}" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="0 0 0 0" />
<Setter Property="Margin" Value="-2 0 0 0" />
<Setter Property="Width" Value="25" />
<Setter Property="Height" Value="25" />
<Setter Property="FontSize" Value="25" />
@ -188,6 +195,7 @@
<CornerRadius x:Key="ItemRadius">5</CornerRadius>
<Thickness x:Key="ItemMargin">10 0 10 0</Thickness>
<Thickness x:Key="ResultMargin">0 10 0 10</Thickness>
<system:Double x:Key="ResultItemHeight">58</system:Double>
<Style
x:Key="ClockPanel"
BasedOn="{StaticResource ClockPanel}"