diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs index e0a217251..003e72a5d 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPluginSettings.cs @@ -113,7 +113,7 @@ namespace Flow.Launcher.Core.Plugin // If can parse the default value to bool, use it, otherwise use false : value is string stringValue && bool.TryParse(stringValue, out var boolValueFromString) && boolValueFromString; - checkBox.Dispatcher.Invoke(() =>checkBox.IsChecked = isChecked); + checkBox.Dispatcher.Invoke(() => checkBox.IsChecked = isChecked); break; } } @@ -154,8 +154,7 @@ namespace Flow.Launcher.Core.Plugin public Control CreateSettingPanel() { - // No need to check if NeedCreateSettingPanel is true because CreateSettingPanel will only be called if it's true - // if (!NeedCreateSettingPanel()) return null; + if (!NeedCreateSettingPanel()) return null!; // Create main grid with two columns (Column 1: Auto, Column 2: *) var mainPanel = new Grid { Margin = SettingPanelMargin, VerticalAlignment = VerticalAlignment.Center }; diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8500e7aa4..1cccc38d9 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; 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; @@ -31,7 +32,7 @@ namespace Flow.Launcher.Infrastructure.UserSettings { _storage.Save(); } - + private string _theme = Constant.DefaultTheme; public string Hotkey { get; set; } = $"{KeyConstant.Alt} + {KeyConstant.Space}"; public string OpenResultModifiers { get; set; } = KeyConstant.Alt; @@ -103,6 +104,22 @@ namespace Flow.Launcher.Infrastructure.UserSettings public bool ShowBadges { get; set; } = false; public bool ShowBadgesGlobalOnly { get; set; } = false; + private string _settingWindowFont { get; set; } = Win32Helper.GetSystemDefaultFont(false); + public string SettingWindowFont + { + get => _settingWindowFont; + set + { + if (_settingWindowFont != value) + { + _settingWindowFont = value; + OnPropertyChanged(); + Application.Current.Resources["SettingWindowFont"] = new FontFamily(value); + Application.Current.Resources["ContentControlThemeFontFamily"] = new FontFamily(value); + } + } + } + public bool UseClock { get; set; } = true; public bool UseDate { get; set; } = false; public string TimeFormat { get; set; } = "hh:mm tt"; diff --git a/Flow.Launcher.Infrastructure/Win32Helper.cs b/Flow.Launcher.Infrastructure/Win32Helper.cs index 6a5af41df..2788060eb 100644 --- a/Flow.Launcher.Infrastructure/Win32Helper.cs +++ b/Flow.Launcher.Infrastructure/Win32Helper.cs @@ -628,21 +628,33 @@ namespace Flow.Launcher.Infrastructure { "pt", "Noto Sans" } }; - public static string GetSystemDefaultFont() + /// + /// Gets the system default font. + /// + /// + /// If true, it will try to find the Noto font for the current culture. + /// + /// + /// The name of the system default font. + /// + public static string GetSystemDefaultFont(bool useNoto = true) { 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) { - // If the font is installed, return it - if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont))) + 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)) { - return notoFont; + // If the font is installed, return it + if (Fonts.SystemFontFamilies.Any(f => f.Source.Equals(notoFont))) + { + return notoFont; + } } } diff --git a/Flow.Launcher/ActionKeywords.xaml b/Flow.Launcher/ActionKeywords.xaml index 740b0d402..887b13126 100644 --- a/Flow.Launcher/ActionKeywords.xaml +++ b/Flow.Launcher/ActionKeywords.xaml @@ -53,11 +53,11 @@ - - + + - + - + @@ -112,20 +112,20 @@ Grid.Row="1" Background="{DynamicResource PopupButtonAreaBGColor}" BorderBrush="{DynamicResource PopupButtonAreaBorderColor}" - BorderThickness="0,1,0,0"> + BorderThickness="0 1 0 0"> - - + + - + @@ -124,14 +124,14 @@ LastChildFill="True"> - - + + - + (); - _viewModel = new SettingsPanePluginsViewModel(settings); + _viewModel = Ioc.Default.GetRequiredService(); DataContext = _viewModel; InitializeComponent(); } diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml index 768abbf97..f429a6e29 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneProxy.xaml @@ -2,11 +2,11 @@ x:Class="Flow.Launcher.SettingPages.Views.SettingsPaneProxy" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:ui="http://schemas.modernwpf.com/2019" - xmlns:cc="clr-namespace:Flow.Launcher.Resources.Controls" xmlns:viewModels="clr-namespace:Flow.Launcher.SettingPages.ViewModels" Title="Proxy" d:DataContext="{d:DesignInstance viewModels:SettingsPaneProxyViewModel}" @@ -18,8 +18,8 @@ @@ -71,9 +71,9 @@ diff --git a/Flow.Launcher/WelcomeWindow.xaml.cs b/Flow.Launcher/WelcomeWindow.xaml.cs index 637f9448d..ef0706765 100644 --- a/Flow.Launcher/WelcomeWindow.xaml.cs +++ b/Flow.Launcher/WelcomeWindow.xaml.cs @@ -2,16 +2,17 @@ using System.Windows; using System.Windows.Input; using System.Windows.Controls; -using Flow.Launcher.Resources.Pages; -using ModernWpf.Media.Animation; using CommunityToolkit.Mvvm.DependencyInjection; -using Flow.Launcher.ViewModel; using Flow.Launcher.Infrastructure.UserSettings; +using Flow.Launcher.Resources.Pages; +using Flow.Launcher.ViewModel; +using ModernWpf.Media.Animation; namespace Flow.Launcher { public partial class WelcomeWindow : Window { + private readonly Settings _settings; private readonly WelcomeViewModel _viewModel; private readonly NavigationTransitionInfo _forwardTransitionInfo = new SlideNavigationTransitionInfo() @@ -25,6 +26,7 @@ namespace Flow.Launcher public WelcomeWindow() { + _settings = Ioc.Default.GetRequiredService(); _viewModel = Ioc.Default.GetRequiredService(); DataContext = _viewModel; InitializeComponent(); @@ -76,10 +78,7 @@ namespace Flow.Launcher private void window_MouseDown(object sender, MouseButtonEventArgs e) /* for close hotkey popup */ { - if (Keyboard.FocusedElement is not TextBox textBox) - { - return; - } + if (Keyboard.FocusedElement is not TextBox textBox) return; var tRequest = new TraversalRequest(FocusNavigationDirection.Next); textBox.MoveFocus(tRequest); } @@ -96,8 +95,10 @@ namespace Flow.Launcher private void Window_Closed(object sender, EventArgs e) { + // If app is exiting, settings save is not needed because main window closing event will handle this + if (App.Exiting) return; // Save settings when window is closed - Ioc.Default.GetRequiredService().Save(); + _settings.Save(); } } } diff --git a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml index f5017ced5..80b004ff9 100644 --- a/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml +++ b/Plugins/Flow.Launcher.Plugin.BrowserBookmark/Views/CustomBrowserSetting.xaml @@ -60,17 +60,17 @@ - - + + - + @@ -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">