Merge pull request #3342 from Jack251970/log_level_card

Move log level to about page
This commit is contained in:
Jack Ye 2025-03-13 13:25:55 +08:00 committed by GitHub
commit 424b575919
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 35 deletions

View file

@ -104,9 +104,6 @@
<system:String x:Key="AlwaysPreview">Always Preview</system:String>
<system:String x:Key="AlwaysPreviewToolTip">Always open preview panel when Flow activates. Press {0} to toggle preview.</system:String>
<system:String x:Key="shadowEffectNotAllowed">Shadow effect is not allowed while current theme has blur effect enabled</system:String>
<system:String x:Key="logLevel">Log level</system:String>
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
<system:String x:Key="LogLevelINFO">Info</system:String>
<!-- Setting Plugin -->
<system:String x:Key="searchplugin">Search Plugin</system:String>
@ -303,6 +300,9 @@
<system:String x:Key="userdatapath">User Data Location</system:String>
<system:String x:Key="userdatapathToolTip">User settings and installed plugins are saved in the user data folder. This location may vary depending on whether it's in portable mode or not.</system:String>
<system:String x:Key="userdatapathButton">Open Folder</system:String>
<system:String x:Key="logLevel">Log Level</system:String>
<system:String x:Key="LogLevelDEBUG">Debug</system:String>
<system:String x:Key="LogLevelINFO">Info</system:String>
<!-- FileManager Setting Dialog -->
<system:String x:Key="fileManagerWindow">Select File Manager</system:String>

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}" Icon="&#xE749;">
<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>