Move log level to about page

This commit is contained in:
Jack251970 2025-03-13 12:53:26 +08:00
parent 59b4859a6c
commit e8be131221
4 changed files with 34 additions and 32 deletions

View file

@ -8,6 +8,7 @@ using CommunityToolkit.Mvvm.Input;
using Flow.Launcher.Core;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
@ -45,10 +46,35 @@ public partial class SettingsPaneAboutViewModel : BaseModel
_settings.ActivateTimes
);
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
public List<LogLevelData> LogLevels { get; } =
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
public LOGLEVEL LogLevel
{
get => _settings.LogLevel;
set
{
if (_settings.LogLevel != value)
{
_settings.LogLevel = value;
Log.SetLogLevel(value);
}
}
}
public SettingsPaneAboutViewModel(Settings settings, Updater updater)
{
_settings = settings;
_updater = updater;
UpdateEnumDropdownLocalizations();
}
private void UpdateEnumDropdownLocalizations()
{
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
}
[RelayCommand]
@ -138,5 +164,4 @@ public partial class SettingsPaneAboutViewModel : BaseModel
return "0 B";
}
}

View file

@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using CommunityToolkit.Mvvm.Input;
using Flow.Launcher.Core;
using Flow.Launcher.Core.Configuration;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.SharedModels;
@ -32,7 +30,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
public class SearchWindowAlignData : DropdownDataGeneric<SearchWindowAligns> { }
public class SearchPrecisionData : DropdownDataGeneric<SearchPrecisionScore> { }
public class LastQueryModeData : DropdownDataGeneric<LastQueryMode> { }
public class LogLevelData : DropdownDataGeneric<LOGLEVEL> { }
public bool StartFlowLauncherOnSystemStartup
{
@ -145,16 +142,12 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
public List<LastQueryModeData> LastQueryModes { get; } =
DropdownDataGeneric<LastQueryMode>.GetValues<LastQueryModeData>("LastQuery");
public List<LogLevelData> LogLevels { get; } =
DropdownDataGeneric<LOGLEVEL>.GetValues<LogLevelData>("LogLevel");
private void UpdateEnumDropdownLocalizations()
{
DropdownDataGeneric<SearchWindowScreens>.UpdateLabels(SearchWindowScreens);
DropdownDataGeneric<SearchWindowAligns>.UpdateLabels(SearchWindowAligns);
DropdownDataGeneric<SearchPrecisionScore>.UpdateLabels(SearchPrecisionScores);
DropdownDataGeneric<LastQueryMode>.UpdateLabels(LastQueryModes);
DropdownDataGeneric<LOGLEVEL>.UpdateLabels(LogLevels);
}
public string Language
@ -222,22 +215,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
}
}
public LOGLEVEL LogLevel
{
get => Settings.LogLevel;
set
{
if (Settings.LogLevel != value)
{
Settings.LogLevel = value;
Log.SetLogLevel(value);
UpdateEnumDropdownLocalizations();
}
}
}
[RelayCommand]
private void SelectPython()
{

View file

@ -123,6 +123,14 @@
</StackPanel>
</cc:Card>
<cc:Card Title="{DynamicResource logLevel}">
<ComboBox
DisplayMemberPath="Display"
ItemsSource="{Binding LogLevels}"
SelectedValue="{Binding LogLevel}"
SelectedValuePath="Value" />
</cc:Card>
<TextBlock
Margin="14 20 0 0"
HorizontalAlignment="Center"

View file

@ -278,14 +278,6 @@
SelectedValue="{Binding Language}"
SelectedValuePath="LanguageCode" />
</cc:Card>
<cc:Card Title="{DynamicResource logLevel}" Margin="0 14 0 0">
<ComboBox
DisplayMemberPath="Display"
ItemsSource="{Binding LogLevels}"
SelectedValue="{Binding LogLevel}"
SelectedValuePath="Value" />
</cc:Card>
</VirtualizingStackPanel>
</ScrollViewer>
</ui:Page>