11using System . Collections . Generic ;
22using System . Collections . ObjectModel ;
3- using System . Diagnostics ;
4- using System . Drawing ;
5- using System . Globalization ;
6- using System . Linq ;
73using System . Text . Json . Serialization ;
84using System . Windows ;
9- using System . Windows . Media ;
105using CommunityToolkit . Mvvm . DependencyInjection ;
116using Flow . Launcher . Infrastructure . Hotkey ;
127using Flow . Launcher . Infrastructure . Logger ;
138using Flow . Launcher . Infrastructure . Storage ;
149using Flow . Launcher . Plugin ;
1510using Flow . Launcher . Plugin . SharedModels ;
1611using Flow . Launcher . ViewModel ;
17- using SystemFonts = System . Windows . SystemFonts ;
1812
1913namespace Flow . Launcher . Infrastructure . UserSettings
2014{
@@ -37,67 +31,6 @@ public void Save()
3731 {
3832 _storage . Save ( ) ;
3933 }
40-
41- private string language = Constant . SystemLanguageCode ;
42- private static readonly Dictionary < string , string > LanguageToNotoSans = new ( )
43- {
44- { "ko" , "Noto Sans KR" } ,
45- { "ja" , "Noto Sans JP" } ,
46- { "zh-CN" , "Noto Sans SC" } ,
47- { "zh-SG" , "Noto Sans SC" } ,
48- { "zh-Hans" , "Noto Sans SC" } ,
49- { "zh-TW" , "Noto Sans TC" } ,
50- { "zh-HK" , "Noto Sans TC" } ,
51- { "zh-MO" , "Noto Sans TC" } ,
52- { "zh-Hant" , "Noto Sans TC" } ,
53- { "th" , "Noto Sans Thai" } ,
54- { "ar" , "Noto Sans Arabic" } ,
55- { "he" , "Noto Sans Hebrew" } ,
56- { "hi" , "Noto Sans Devanagari" } ,
57- { "bn" , "Noto Sans Bengali" } ,
58- { "ta" , "Noto Sans Tamil" } ,
59- { "el" , "Noto Sans Greek" } ,
60- { "ru" , "Noto Sans" } ,
61- { "en" , "Noto Sans" } ,
62- { "fr" , "Noto Sans" } ,
63- { "de" , "Noto Sans" } ,
64- { "es" , "Noto Sans" } ,
65- { "pt" , "Noto Sans" }
66- } ;
67-
68- public static string GetSystemDefaultFont ( )
69- {
70- try
71- {
72- var culture = CultureInfo . CurrentCulture ;
73- var language = culture . Name ; // e.g., "zh-TW"
74- var langPrefix = language . Split ( '-' ) [ 0 ] ; // e.g., "zh"
75-
76- // First, try to find by full name, and if not found, fallback to prefix
77- if ( TryGetNotoFont ( language , out var notoFont ) || TryGetNotoFont ( langPrefix , out notoFont ) )
78- {
79- if ( Fonts . SystemFontFamilies . Any ( f => f . Source . Equals ( notoFont ) ) )
80- return notoFont ;
81- }
82-
83- var font = SystemFonts . MessageFontFamily ;
84- if ( font . FamilyNames . TryGetValue ( System . Windows . Markup . XmlLanguage . GetLanguage ( "en-US" ) , out var englishName ) )
85- {
86- return englishName ;
87- }
88-
89- return font . Source ?? "Segoe UI" ;
90- }
91- catch
92- {
93- return "Segoe UI" ;
94- }
95- }
96-
97- private static bool TryGetNotoFont ( string langKey , out string notoFont )
98- {
99- return LanguageToNotoSans . TryGetValue ( langKey , out notoFont ) ;
100- }
10134
10235 private string _theme = Constant . DefaultTheme ;
10336 public string Hotkey { get ; set ; } = $ "{ KeyConstant . Alt } + { KeyConstant . Space } ";
@@ -119,12 +52,13 @@ private static bool TryGetNotoFont(string langKey, out string notoFont)
11952 public string CycleHistoryUpHotkey { get ; set ; } = $ "{ KeyConstant . Alt } + Up";
12053 public string CycleHistoryDownHotkey { get ; set ; } = $ "{ KeyConstant . Alt } + Down";
12154
55+ private string _language = Constant . SystemLanguageCode ;
12256 public string Language
12357 {
124- get => language ;
58+ get => _language ;
12559 set
12660 {
127- language = value ;
61+ _language = value ;
12862 OnPropertyChanged ( ) ;
12963 }
13064 }
@@ -150,15 +84,15 @@ public string Theme
15084 public double QueryBoxFontSize { get ; set ; } = 16 ;
15185 public double ResultItemFontSize { get ; set ; } = 16 ;
15286 public double ResultSubItemFontSize { get ; set ; } = 13 ;
153- public string QueryBoxFont { get ; set ; } = GetSystemDefaultFont ( ) ;
87+ public string QueryBoxFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
15488 public string QueryBoxFontStyle { get ; set ; }
15589 public string QueryBoxFontWeight { get ; set ; }
15690 public string QueryBoxFontStretch { get ; set ; }
157- public string ResultFont { get ; set ; } = GetSystemDefaultFont ( ) ;
91+ public string ResultFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
15892 public string ResultFontStyle { get ; set ; }
15993 public string ResultFontWeight { get ; set ; }
16094 public string ResultFontStretch { get ; set ; }
161- public string ResultSubFont { get ; set ; } = GetSystemDefaultFont ( ) ;
95+ public string ResultSubFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
16296 public string ResultSubFontStyle { get ; set ; }
16397 public string ResultSubFontWeight { get ; set ; }
16498 public string ResultSubFontStretch { get ; set ; }
@@ -181,7 +115,7 @@ public string Theme
181115 public double ? SettingWindowLeft { get ; set ; } = null ;
182116 public WindowState SettingWindowState { get ; set ; } = WindowState . Normal ;
183117
184- bool _showPlaceholder { get ; set ; } = true ;
118+ private bool _showPlaceholder { get ; set ; } = true ;
185119 public bool ShowPlaceholder
186120 {
187121 get => _showPlaceholder ;
@@ -194,7 +128,7 @@ public bool ShowPlaceholder
194128 }
195129 }
196130 }
197- string _placeholderText { get ; set ; } = string . Empty ;
131+ private string _placeholderText { get ; set ; } = string . Empty ;
198132 public string PlaceholderText
199133 {
200134 get => _placeholderText ;
@@ -373,7 +307,7 @@ public bool KeepMaxResults
373307 public bool StartFlowLauncherOnSystemStartup { get ; set ; } = false ;
374308 public bool UseLogonTaskForStartup { get ; set ; } = false ;
375309 public bool HideOnStartup { get ; set ; } = true ;
376- bool _hideNotifyIcon { get ; set ; }
310+ private bool _hideNotifyIcon ;
377311 public bool HideNotifyIcon
378312 {
379313 get => _hideNotifyIcon ;
@@ -551,5 +485,4 @@ public enum BackdropTypes
551485 Mica ,
552486 MicaAlt
553487 }
554-
555488}
0 commit comments