From a28ee701b8a562c6974a4b6139055854881bc45c Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 17 Apr 2025 18:45:31 +0900 Subject: [PATCH 01/40] Add settingwindowfont config and menu --- .../UserSettings/Settings.cs | 21 ++++---- .../ViewModels/SettingsPaneAboutViewModel.cs | 49 +++++++++++++++++++ .../SettingPages/Views/SettingsPaneAbout.xaml | 46 ++++++++++++++--- .../Views/SettingsPaneAbout.xaml.cs | 22 ++++++++- Flow.Launcher/SettingWindow.xaml | 1 + Flow.Launcher/SettingWindow.xaml.cs | 1 + .../ViewModel/SettingWindowViewModel.cs | 26 +++++++++- 7 files changed, 147 insertions(+), 19 deletions(-) diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 0bd1a809b..d91574bdc 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -65,19 +65,21 @@ namespace Flow.Launcher.Infrastructure.UserSettings { "pt", "Noto Sans" } }; - public static string GetSystemDefaultFont() + public static string GetSystemDefaultFont(bool? useNoto = null) { 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 (useNoto != false) { - if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont))) - return notoFont; + var culture = CultureInfo.CurrentCulture; + var language = culture.Name; // e.g., "zh-TW" + var langPrefix = language.Split('-')[0]; // e.g., "zh" + + 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; @@ -162,6 +164,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings public string ResultSubFontStyle { get; set; } public string ResultSubFontWeight { get; set; } public string ResultSubFontStretch { get; set; } + public string SettingWindowFont { get; set; } = GetSystemDefaultFont(false); public bool UseGlyphIcons { get; set; } = true; public bool UseAnimation { get; set; } = true; public bool UseSound { get; set; } = true; diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs index 6cfb98306..abc7a2d16 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core; using Flow.Launcher.Infrastructure; @@ -268,4 +270,51 @@ public partial class SettingsPaneAboutViewModel : BaseModel return "0 B"; } + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + private string _settingWindowFont; + + public string SettingWindowFont + { + get => _settings.SettingWindowFont; + set + { + if (_settings.SettingWindowFont != value) + { + _settings.SettingWindowFont = value; + OnPropertyChanged(nameof(SettingWindowFont)); + } + } + } + + [RelayCommand] + private void ResetSettingWindowFont() + { + string defaultFont = GetSystemDefaultFont(); + _settings.SettingWindowFont = defaultFont; + } + + public static string GetSystemDefaultFont() + { + try + { + 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"; + } + } + } diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml index f7deee7cf..b3991743d 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml @@ -12,6 +12,11 @@ d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> + + + + + - - - + + + + + + + + - - + + - + - - + + - + @@ -124,14 +125,14 @@ LastChildFill="True"> + IsEnabled="{Binding NextEnabled, Mode=OneWay}"> + + From 25f39f6934921cc52a4f59243f7adef430b2ed0e Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 24 Apr 2025 11:08:02 +0900 Subject: [PATCH 14/40] Add dynamic font support for the setting window --- Flow.Launcher/App.xaml.cs | 2 ++ Flow.Launcher/SettingWindow.xaml | 1 + 2 files changed, 3 insertions(+) diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 87698a545..606536dad 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -4,6 +4,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media; using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Core; using Flow.Launcher.Core.Configuration; @@ -175,6 +176,7 @@ namespace Flow.Launcher await imageLoadertask; _mainWindow = new MainWindow(); + Current.Resources["SettingWindowFont"] = new FontFamily(_settings.SettingWindowFont); API.LogInfo(ClassName, "Dependencies Info:{ErrorReporting.DependenciesInfo()}"); diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index ab27b235a..a34777d30 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -13,6 +13,7 @@ MinHeight="600" d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}" Closed="OnClosed" + FontFamily="{Binding Settings.SettingWindowFont, Mode=TwoWay}" Icon="Images\app.ico" Left="{Binding SettingWindowLeft, Mode=TwoWay}" Loaded="OnLoaded" From 8432fa3b40ceb87916676fc5021e7e72dac54078 Mon Sep 17 00:00:00 2001 From: DB p Date: Thu, 24 Apr 2025 11:25:21 +0900 Subject: [PATCH 15/40] Add SettingWindowFont definition to CustomControlTemplate --- Flow.Launcher/Resources/CustomControlTemplate.xaml | 1 + Flow.Launcher/Resources/SettingWindowStyle.xaml | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Flow.Launcher/Resources/CustomControlTemplate.xaml b/Flow.Launcher/Resources/CustomControlTemplate.xaml index be68fc1b1..4e94da526 100644 --- a/Flow.Launcher/Resources/CustomControlTemplate.xaml +++ b/Flow.Launcher/Resources/CustomControlTemplate.xaml @@ -5,6 +5,7 @@ xmlns:ui="http://schemas.modernwpf.com/2019"> + Segoe UI diff --git a/Flow.Launcher/Resources/SettingWindowStyle.xaml b/Flow.Launcher/Resources/SettingWindowStyle.xaml index c59baeaea..60655fa7c 100644 --- a/Flow.Launcher/Resources/SettingWindowStyle.xaml +++ b/Flow.Launcher/Resources/SettingWindowStyle.xaml @@ -7,8 +7,6 @@ - Segoe UI - F1 M512,512z M0,0z M448,256C448,150,362,64,256,64L256,448C362,448,448,362,448,256z M0,256A256,256,0,1,1,512,256A256,256,0,1,1,0,256z + + {DynamicResource SettingWindowFont} + @@ -1360,7 +1363,6 @@ - @@ -1584,6 +1586,7 @@ diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml index 32fdb62fc..b6a99d9e9 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml +++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml @@ -127,7 +127,7 @@ Style="{DynamicResource StyleImageFadeIn}" /> - - + + @@ -89,29 +89,29 @@ - + @@ -81,26 +81,26 @@ Canvas.Left="0" Width="450" Height="280" - Margin="0,0,0,0" + Margin="0 0 0 0" Source="../../images/page_img01.png" Style="{DynamicResource StyleImageFadeIn}" /> - + diff --git a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml index 3df4b506e..7495231ae 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage5.xaml +++ b/Flow.Launcher/Resources/Pages/WelcomePage5.xaml @@ -79,18 +79,18 @@ - + - + - + + Padding="5 18 0 0"> + Margin="5 24 0 0"> @@ -97,8 +97,8 @@ - - + + - + @@ -86,23 +86,23 @@ Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" - Margin="5,0,0,20"> + Margin="5 0 0 20"> @@ -180,18 +180,18 @@ Grid.Row="1" Background="{DynamicResource PopupButtonAreaBGColor}" BorderBrush="{DynamicResource PopupButtonAreaBorderColor}" - BorderThickness="0,1,0,0"> + BorderThickness="0 1 0 0"> - - + + - + - + + BorderThickness="0 1 0 0"> - - + + - + @@ -104,16 +104,16 @@ HorizontalAlignment="Stretch" Click="BrowseButton_Click" Content="{DynamicResource flowlauncher_plugin_program_browse}" - Visibility="{Binding IsCustomSource, Converter={StaticResource BooleanToVisibilityConverter}}" - DockPanel.Dock="Right" /> + DockPanel.Dock="Right" + Visibility="{Binding IsCustomSource, Converter={StaticResource BooleanToVisibilityConverter}}" /> + VerticalAlignment="Center" + IsReadOnly="{Binding IsNotCustomSource}" + Text="{Binding Location, Mode=TwoWay}" /> + Margin="10 0" + VerticalAlignment="Center" + IsChecked="{Binding Enabled, Mode=TwoWay}" /> + BorderThickness="0 1 0 0"> - + - + @@ -151,82 +151,82 @@ TextWrapping="Wrap" /> - + - + appref-ms exe lnk + BorderThickness="1 0 0 0"> @@ -237,27 +237,27 @@ Grid.Row="1" Background="{DynamicResource PopupButtonAreaBGColor}" BorderBrush="{DynamicResource PopupButtonAreaBorderColor}" - BorderThickness="0,1,0,0"> + BorderThickness="0 1 0 0">