Skip to content

Commit e8be131

Browse files
committed
Move log level to about page
1 parent 59b4859 commit e8be131

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

Flow.Launcher/SettingPages/ViewModels/SettingsPaneAboutViewModel.cs

+26-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Flow.Launcher.Core;
99
using Flow.Launcher.Core.Resource;
1010
using Flow.Launcher.Infrastructure;
11+
using Flow.Launcher.Infrastructure.Logger;
1112
using Flow.Launcher.Infrastructure.UserSettings;
1213
using Flow.Launcher.Plugin;
1314

@@ -45,10 +46,35 @@ public string LogFolderSize
4546
_settings.ActivateTimes
4647
);
4748

49+
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
50+
51+
public List<LogLevelData> LogLevels { get; } =
52+
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
53+
54+
public LOGLEVEL LogLevel
55+
{
56+
get => _settings.LogLevel;
57+
set
58+
{
59+
if (_settings.LogLevel != value)
60+
{
61+
_settings.LogLevel = value;
62+
63+
Log.SetLogLevel(value);
64+
}
65+
}
66+
}
67+
4868
public SettingsPaneAboutViewModel(Settings settings, Updater updater)
4969
{
5070
_settings = settings;
5171
_updater = updater;
72+
UpdateEnumDropdownLocalizations();
73+
}
74+
75+
private void UpdateEnumDropdownLocalizations()
76+
{
77+
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
5278
}
5379

5480
[RelayCommand]
@@ -138,5 +164,4 @@ private static string BytesToReadableString(long bytes)
138164

139165
return "0 B";
140166
}
141-
142167
}

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

-23
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.Windows.Forms;
54
using CommunityToolkit.Mvvm.Input;
65
using Flow.Launcher.Core;
76
using Flow.Launcher.Core.Configuration;
87
using Flow.Launcher.Core.Resource;
98
using Flow.Launcher.Helper;
10-
using Flow.Launcher.Infrastructure.Logger;
119
using Flow.Launcher.Infrastructure.UserSettings;
1210
using Flow.Launcher.Plugin;
1311
using Flow.Launcher.Plugin.SharedModels;
@@ -32,7 +30,6 @@ public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> {
3230
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
3331
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
3432
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
35-
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
3633

3734
public bool StartFlowLauncherOnSystemStartup
3835
{
@@ -145,16 +142,12 @@ public bool PortableMode
145142
public List<LastQueryModeData> LastQueryModes { get; } =
146143
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
147144

148-
public List<LogLevelData> LogLevels { get; } =
149-
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
150-
151145
private void UpdateEnumDropdownLocalizations()
152146
{
153147
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
154148
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
155149
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
156150
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
157-
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
158151
}
159152

160153
public string Language
@@ -222,22 +215,6 @@ public bool AutoUpdates
222215
}
223216
}
224217

225-
public LOGLEVEL LogLevel
226-
{
227-
get => Settings.LogLevel;
228-
set
229-
{
230-
if (Settings.LogLevel != value)
231-
{
232-
Settings.LogLevel = value;
233-
234-
Log.SetLogLevel(value);
235-
236-
UpdateEnumDropdownLocalizations();
237-
}
238-
}
239-
}
240-
241218
[RelayCommand]
242219
private void SelectPython()
243220
{

Flow.Launcher/SettingPages/Views/SettingsPaneAbout.xaml

+8
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@
123123
</StackPanel>
124124
</cc:Card>
125125

126+
<cc:Card Title="{DynamicResource logLevel}">
127+
<ComboBox
128+
DisplayMemberPath="Display"
129+
ItemsSource="{Binding LogLevels}"
130+
SelectedValue="{Binding LogLevel}"
131+
SelectedValuePath="Value" />
132+
</cc:Card>
133+
126134
<TextBlock
127135
Margin="14 20 0 0"
128136
HorizontalAlignment="Center"

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

-8
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,6 @@
278278
SelectedValue="{Binding Language}"
279279
SelectedValuePath="LanguageCode" />
280280
</cc:Card>
281-
282-
<cc:Card Title="{DynamicResource logLevel}" Margin="0 14 0 0">
283-
<ComboBox
284-
DisplayMemberPath="Display"
285-
ItemsSource="{Binding LogLevels}"
286-
SelectedValue="{Binding LogLevel}"
287-
SelectedValuePath="Value" />
288-
</cc:Card>
289281
</VirtualizingStackPanel>
290282
</ScrollViewer>
291283
</ui:Page>

0 commit comments

Comments
 (0)