@@ -22,6 +22,7 @@ namespace Flow.Launcher.SettingPages.ViewModels;
22
22
23
23
public partial class SettingsPaneThemeViewModel : BaseModel
24
24
{
25
+ private const string DefaultFont = "Segoe UI" ;
25
26
public Settings Settings { get ; }
26
27
27
28
public static string LinkHowToCreateTheme => @"https://flowlauncher.com/docs/#/how-to-create-a-theme" ;
@@ -82,6 +83,7 @@ public double QueryBoxFontSize
82
83
get => Settings . QueryBoxFontSize ;
83
84
set => Settings . QueryBoxFontSize = value ;
84
85
}
86
+
85
87
public double ResultItemFontSize
86
88
{
87
89
get => Settings . ResultItemFontSize ;
@@ -97,30 +99,9 @@ public double ResultSubItemFontSize
97
99
private List < Theme . ThemeData > _themes ;
98
100
public List < Theme . ThemeData > Themes => _themes ??= ThemeManager . Instance . LoadAvailableThemes ( ) ;
99
101
102
+ public class ColorSchemeData : DropdownDataGeneric < ColorSchemes > { }
100
103
101
- public class ColorScheme
102
- {
103
- public string Display { get ; set ; }
104
- public ColorSchemes Value { get ; set ; }
105
- }
106
-
107
- public List < ColorScheme > ColorSchemes
108
- {
109
- get
110
- {
111
- List < ColorScheme > modes = new List < ColorScheme > ( ) ;
112
- var enums = ( ColorSchemes [ ] ) Enum . GetValues ( typeof ( ColorSchemes ) ) ;
113
- foreach ( var e in enums )
114
- {
115
- var key = $ "ColorScheme{ e } ";
116
- var display = InternationalizationManager . Instance . GetTranslation ( key ) ;
117
- var m = new ColorScheme { Display = display , Value = e , } ;
118
- modes . Add ( m ) ;
119
- }
120
-
121
- return modes ;
122
- }
123
- }
104
+ public List < ColorSchemeData > ColorSchemes { get ; } = DropdownDataGeneric < ColorSchemes > . GetValues < ColorSchemeData > ( "ColorScheme" ) ;
124
105
125
106
public List < string > TimeFormatList { get ; } = new ( )
126
107
{
@@ -167,11 +148,13 @@ public string DateFormat
167
148
}
168
149
169
150
public IEnumerable < int > MaxResultsRange => Enumerable . Range ( 2 , 16 ) ;
151
+
170
152
public bool KeepMaxResults
171
153
{
172
154
get => Settings . KeepMaxResults ;
173
155
set => Settings . KeepMaxResults = value ;
174
156
}
157
+
175
158
public string ClockText => DateTime . Now . ToString ( TimeFormat , CultureInfo . CurrentCulture ) ;
176
159
177
160
public string DateText => DateTime . Now . ToString ( DateFormat , CultureInfo . CurrentCulture ) ;
@@ -188,29 +171,9 @@ public bool UseAnimation
188
171
set => Settings . UseAnimation = value ;
189
172
}
190
173
191
- public class AnimationSpeed
192
- {
193
- public string Display { get ; set ; }
194
- public AnimationSpeeds Value { get ; set ; }
195
- }
174
+ public class AnimationSpeedData : DropdownDataGeneric < AnimationSpeeds > { }
175
+ public List < AnimationSpeedData > AnimationSpeeds { get ; } = DropdownDataGeneric < AnimationSpeeds > . GetValues < AnimationSpeedData > ( "AnimationSpeed" ) ;
196
176
197
- public List < AnimationSpeed > AnimationSpeeds
198
- {
199
- get
200
- {
201
- List < AnimationSpeed > speeds = new List < AnimationSpeed > ( ) ;
202
- var enums = ( AnimationSpeeds [ ] ) Enum . GetValues ( typeof ( AnimationSpeeds ) ) ;
203
- foreach ( var e in enums )
204
- {
205
- var key = $ "AnimationSpeed{ e } ";
206
- var display = InternationalizationManager . Instance . GetTranslation ( key ) ;
207
- var m = new AnimationSpeed { Display = display , Value = e , } ;
208
- speeds . Add ( m ) ;
209
- }
210
-
211
- return speeds ;
212
- }
213
- }
214
177
public bool UseSound
215
178
{
216
179
get => Settings . UseSound ;
@@ -329,7 +292,7 @@ public FontFamily SelectedQueryBoxFont
329
292
return fontExists switch
330
293
{
331
294
true => new FontFamily ( Settings . QueryBoxFont ) ,
332
- _ => new FontFamily ( "Segoe UI" )
295
+ _ => new FontFamily ( DefaultFont )
333
296
} ;
334
297
}
335
298
set
@@ -373,7 +336,7 @@ public FontFamily SelectedResultFont
373
336
return fontExists switch
374
337
{
375
338
true => new FontFamily ( Settings . ResultFont ) ,
376
- _ => new FontFamily ( "Segoe UI" )
339
+ _ => new FontFamily ( DefaultFont )
377
340
} ;
378
341
}
379
342
set
@@ -418,7 +381,7 @@ public FontFamily SelectedResultSubFont
418
381
}
419
382
else
420
383
{
421
- var font = new FontFamily ( "Segoe UI" ) ;
384
+ var font = new FontFamily ( DefaultFont ) ;
422
385
return font ;
423
386
}
424
387
}
@@ -449,6 +412,7 @@ public FamilyTypeface SelectedResultSubFontFaces
449
412
ThemeManager . Instance . ChangeTheme ( Settings . Theme ) ;
450
413
}
451
414
}
415
+
452
416
public string ThemeImage => Constant . QueryTextBoxIconImagePath ;
453
417
454
418
[ RelayCommand ]
@@ -473,4 +437,22 @@ public SettingsPaneThemeViewModel(Settings settings)
473
437
Settings = settings ;
474
438
}
475
439
440
+ [ RelayCommand ]
441
+ public void Reset ( )
442
+ {
443
+ SelectedQueryBoxFont = new FontFamily ( DefaultFont ) ;
444
+ SelectedQueryBoxFontFaces = new FamilyTypeface { Stretch = FontStretches . Normal , Weight = FontWeights . Normal , Style = FontStyles . Normal } ;
445
+ QueryBoxFontSize = 20 ;
446
+
447
+ SelectedResultFont = new FontFamily ( DefaultFont ) ;
448
+ SelectedResultFontFaces = new FamilyTypeface { Stretch = FontStretches . Normal , Weight = FontWeights . Normal , Style = FontStyles . Normal } ;
449
+ ResultItemFontSize = 16 ;
450
+
451
+ SelectedResultSubFont = new FontFamily ( DefaultFont ) ;
452
+ SelectedResultSubFontFaces = new FamilyTypeface { Stretch = FontStretches . Normal , Weight = FontWeights . Normal , Style = FontStyles . Normal } ;
453
+ ResultSubItemFontSize = 13 ;
454
+
455
+ WindowHeightSize = 42 ;
456
+ ItemHeightSize = 58 ;
457
+ }
476
458
}
0 commit comments