mirror of
https://github.com/real-zony/ZonyLrcToolsX.git
synced 2025-09-05 21:16:52 +00:00
fix(Fixed some issues in the settings page.):
This commit is contained in:
@@ -10,26 +10,25 @@ namespace ZonyLrcTools.Desktop.ViewModels.Settings;
|
||||
|
||||
public class GlobalConfigurationViewModel : ViewModelBase
|
||||
{
|
||||
private readonly GlobalLyricsConfigOptions _config;
|
||||
|
||||
public GlobalConfigurationViewModel(GlobalLyricsConfigOptions config)
|
||||
public GlobalConfigurationViewModel(GlobalOptions config)
|
||||
{
|
||||
_config = config;
|
||||
InitializeLineBreakComboBoxItem();
|
||||
var globalConfig = config.Provider.Lyric.Config;
|
||||
|
||||
IsOneLine = _config.IsOneLine;
|
||||
IsEnableTranslation = _config.IsEnableTranslation;
|
||||
IsSkipExistLyricFiles = _config.IsSkipExistLyricFiles;
|
||||
IsOnlyOutputTranslation = _config.IsOnlyOutputTranslation;
|
||||
InitializeLineBreakComboBoxItem(globalConfig);
|
||||
|
||||
IsOneLine = globalConfig.IsOneLine;
|
||||
IsEnableTranslation = globalConfig.IsEnableTranslation;
|
||||
IsSkipExistLyricFiles = globalConfig.IsSkipExistLyricFiles;
|
||||
IsOnlyOutputTranslation = globalConfig.IsOnlyOutputTranslation;
|
||||
|
||||
this.WhenAnyValue(x => x.IsOneLine)
|
||||
.Subscribe(x => _config.IsOneLine = x);
|
||||
.Subscribe(x => globalConfig.IsOneLine = x);
|
||||
this.WhenAnyValue(x => x.IsEnableTranslation)
|
||||
.Subscribe(x => _config.IsEnableTranslation = x);
|
||||
.Subscribe(x => globalConfig.IsEnableTranslation = x);
|
||||
this.WhenAnyValue(x => x.IsSkipExistLyricFiles)
|
||||
.Subscribe(x => _config.IsSkipExistLyricFiles = x);
|
||||
.Subscribe(x => globalConfig.IsSkipExistLyricFiles = x);
|
||||
this.WhenAnyValue(x => x.IsOnlyOutputTranslation)
|
||||
.Subscribe(x => _config.IsOnlyOutputTranslation = x);
|
||||
.Subscribe(x => globalConfig.IsOnlyOutputTranslation = x);
|
||||
}
|
||||
|
||||
[Reactive] public bool IsOneLine { get; set; }
|
||||
@@ -38,11 +37,9 @@ public class GlobalConfigurationViewModel : ViewModelBase
|
||||
|
||||
[Reactive] public bool IsSkipExistLyricFiles { get; set; }
|
||||
|
||||
[Reactive] public string FileEncoding { get; set; }
|
||||
|
||||
[Reactive] public bool IsOnlyOutputTranslation { get; set; }
|
||||
|
||||
private void InitializeLineBreakComboBoxItem()
|
||||
private void InitializeLineBreakComboBoxItem(GlobalLyricsConfigOptions config)
|
||||
{
|
||||
LineBreakOptions =
|
||||
[
|
||||
@@ -50,20 +47,20 @@ public class GlobalConfigurationViewModel : ViewModelBase
|
||||
new TextComboboxItem { Name = "Unix", Value = "\n" },
|
||||
new TextComboboxItem { Name = "Mac", Value = "\r" }
|
||||
];
|
||||
SelectedLineBreak = LineBreakOptions.FirstOrDefault(x => x.Value == _config.LineBreak)
|
||||
SelectedLineBreak = LineBreakOptions.FirstOrDefault(x => x.Value == config.LineBreak)
|
||||
?? LineBreakOptions.First();
|
||||
|
||||
FileEncodingOptions = Encoding.GetEncodings()
|
||||
.Select(x => new TextComboboxItem { Name = x.DisplayName, Value = x.Name })
|
||||
.ToList();
|
||||
FileEncodingOptions.Insert(0, new TextComboboxItem { Name = "UTF-8-BOM", Value = "utf-8-bom" });
|
||||
SelectedFileEncoding = FileEncodingOptions.FirstOrDefault(x => x.Value == _config.FileEncoding)
|
||||
SelectedFileEncoding = FileEncodingOptions.FirstOrDefault(x => x.Value == config.FileEncoding)
|
||||
?? FileEncodingOptions.First();
|
||||
|
||||
this.WhenAnyValue(x => x.SelectedLineBreak)
|
||||
.Subscribe(x => _config.LineBreak = x.Value);
|
||||
.Subscribe(x => config.LineBreak = x.Value);
|
||||
this.WhenAnyValue(x => x.SelectedFileEncoding)
|
||||
.Subscribe(x => _config.FileEncoding = x.Value);
|
||||
.Subscribe(x => config.FileEncoding = x.Value);
|
||||
}
|
||||
|
||||
public List<TextComboboxItem> LineBreakOptions { get; private set; }
|
||||
|
Reference in New Issue
Block a user