Skip to content

Commit 66bf046

Browse files
committed
Add log level change to general settings page
1 parent 05ff797 commit 66bf046

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
105105
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
106106
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
107+
<system:String x:Key="logLevel">Log level</system:String>
108+
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
109+
<system:String x:Key="LogLevelINFO">Info</system:String>
107110

108111
<!-- Setting Plugin -->
109112
<system:String x:Key="searchplugin">Search Plugin</system:String>

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Flow.Launcher.Core.Configuration;
88
using Flow.Launcher.Core.Resource;
99
using Flow.Launcher.Helper;
10+
using Flow.Launcher.Infrastructure.Logger;
1011
using Flow.Launcher.Infrastructure.UserSettings;
1112
using Flow.Launcher.Plugin;
1213
using Flow.Launcher.Plugin.SharedModels;
@@ -31,6 +32,7 @@ public class SearchWindowScreenData : DropdownDataGeneric<SearchWindowScreens> {
3132
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
3233
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
3334
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
35+
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
3436

3537
public bool StartFlowLauncherOnSystemStartup
3638
{
@@ -143,12 +145,16 @@ public bool PortableMode
143145
public List<LastQueryModeData> LastQueryModes { get; } =
144146
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
145147

148+
public List<LogLevelData> LogLevels { get; } =
149+
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
150+
146151
private void UpdateEnumDropdownLocalizations()
147152
{
148153
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
149154
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
150155
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
151156
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
157+
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
152158
}
153159

154160
public string Language
@@ -216,6 +222,22 @@ public bool AutoUpdates
216222
}
217223
}
218224

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+
219241
[RelayCommand]
220242
private void SelectPython()
221243
{

Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@
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>
281289
</VirtualizingStackPanel>
282290
</ScrollViewer>
283291
</ui:Page>

0 commit comments

Comments
 (0)