1
1
using System . Collections . Generic ;
2
2
using System . Collections . ObjectModel ;
3
- using System . Diagnostics ;
4
- using System . Drawing ;
5
- using System . Globalization ;
6
- using System . Linq ;
7
3
using System . Text . Json . Serialization ;
8
4
using System . Windows ;
9
- using System . Windows . Media ;
10
5
using CommunityToolkit . Mvvm . DependencyInjection ;
11
6
using Flow . Launcher . Infrastructure . Hotkey ;
12
7
using Flow . Launcher . Infrastructure . Logger ;
13
8
using Flow . Launcher . Infrastructure . Storage ;
14
9
using Flow . Launcher . Plugin ;
15
10
using Flow . Launcher . Plugin . SharedModels ;
16
11
using Flow . Launcher . ViewModel ;
17
- using SystemFonts = System . Windows . SystemFonts ;
18
12
19
13
namespace Flow . Launcher . Infrastructure . UserSettings
20
14
{
@@ -37,67 +31,6 @@ public void Save()
37
31
{
38
32
_storage . Save ( ) ;
39
33
}
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
- }
101
34
102
35
private string _theme = Constant . DefaultTheme ;
103
36
public string Hotkey { get ; set ; } = $ "{ KeyConstant . Alt } + { KeyConstant . Space } ";
@@ -119,12 +52,13 @@ private static bool TryGetNotoFont(string langKey, out string notoFont)
119
52
public string CycleHistoryUpHotkey { get ; set ; } = $ "{ KeyConstant . Alt } + Up";
120
53
public string CycleHistoryDownHotkey { get ; set ; } = $ "{ KeyConstant . Alt } + Down";
121
54
55
+ private string _language = Constant . SystemLanguageCode ;
122
56
public string Language
123
57
{
124
- get => language ;
58
+ get => _language ;
125
59
set
126
60
{
127
- language = value ;
61
+ _language = value ;
128
62
OnPropertyChanged ( ) ;
129
63
}
130
64
}
@@ -150,15 +84,15 @@ public string Theme
150
84
public double QueryBoxFontSize { get ; set ; } = 16 ;
151
85
public double ResultItemFontSize { get ; set ; } = 16 ;
152
86
public double ResultSubItemFontSize { get ; set ; } = 13 ;
153
- public string QueryBoxFont { get ; set ; } = GetSystemDefaultFont ( ) ;
87
+ public string QueryBoxFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
154
88
public string QueryBoxFontStyle { get ; set ; }
155
89
public string QueryBoxFontWeight { get ; set ; }
156
90
public string QueryBoxFontStretch { get ; set ; }
157
- public string ResultFont { get ; set ; } = GetSystemDefaultFont ( ) ;
91
+ public string ResultFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
158
92
public string ResultFontStyle { get ; set ; }
159
93
public string ResultFontWeight { get ; set ; }
160
94
public string ResultFontStretch { get ; set ; }
161
- public string ResultSubFont { get ; set ; } = GetSystemDefaultFont ( ) ;
95
+ public string ResultSubFont { get ; set ; } = Win32Helper . GetSystemDefaultFont ( ) ;
162
96
public string ResultSubFontStyle { get ; set ; }
163
97
public string ResultSubFontWeight { get ; set ; }
164
98
public string ResultSubFontStretch { get ; set ; }
@@ -181,7 +115,7 @@ public string Theme
181
115
public double ? SettingWindowLeft { get ; set ; } = null ;
182
116
public WindowState SettingWindowState { get ; set ; } = WindowState . Normal ;
183
117
184
- bool _showPlaceholder { get ; set ; } = true ;
118
+ private bool _showPlaceholder { get ; set ; } = true ;
185
119
public bool ShowPlaceholder
186
120
{
187
121
get => _showPlaceholder ;
@@ -194,7 +128,7 @@ public bool ShowPlaceholder
194
128
}
195
129
}
196
130
}
197
- string _placeholderText { get ; set ; } = string . Empty ;
131
+ private string _placeholderText { get ; set ; } = string . Empty ;
198
132
public string PlaceholderText
199
133
{
200
134
get => _placeholderText ;
@@ -373,7 +307,7 @@ public bool KeepMaxResults
373
307
public bool StartFlowLauncherOnSystemStartup { get ; set ; } = false ;
374
308
public bool UseLogonTaskForStartup { get ; set ; } = false ;
375
309
public bool HideOnStartup { get ; set ; } = true ;
376
- bool _hideNotifyIcon { get ; set ; }
310
+ private bool _hideNotifyIcon ;
377
311
public bool HideNotifyIcon
378
312
{
379
313
get => _hideNotifyIcon ;
@@ -551,5 +485,4 @@ public enum BackdropTypes
551
485
Mica ,
552
486
MicaAlt
553
487
}
554
-
555
488
}
0 commit comments