Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry08 committed Dec 28, 2024
1 parent de4f5c2 commit 69480ac
Showing 1 changed file with 47 additions and 23 deletions.
70 changes: 47 additions & 23 deletions SoundCloudDownloader/Services/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,63 @@

namespace SoundCloudDownloader.Services;

// Can't use [ObservableProperty] here because System.Text.Json's source generator doesn't see
// the generated properties.
[INotifyPropertyChanged]
public partial class SettingsService : SettingsBase
public partial class SettingsService()
: SettingsBase(
Path.Combine(AppContext.BaseDirectory, "Settings.dat"),
SerializerContext.Default
)
{
[ObservableProperty]
public partial ThemeVariant Theme { get; set; }
private ThemeVariant _theme;
public ThemeVariant Theme
{
get => _theme;
set => SetProperty(ref _theme, value);
}

[ObservableProperty]
public partial bool IsAutoUpdateEnabled { get; set; }
private bool _isAutoUpdateEnabled = true;
public bool IsAutoUpdateEnabled
{
get => _isAutoUpdateEnabled;
set => SetProperty(ref _isAutoUpdateEnabled, value);
}

[ObservableProperty]
public partial bool ShouldInjectTags { get; set; }
private bool _shouldInjectTags = true;
public bool ShouldInjectTags
{
get => _shouldInjectTags;
set => SetProperty(ref _shouldInjectTags, value);
}

[ObservableProperty]
public partial bool ShouldSkipExistingFiles { get; set; }
private bool _shouldSkipExistingFiles;
public bool ShouldSkipExistingFiles
{
get => _shouldSkipExistingFiles;
set => SetProperty(ref _shouldSkipExistingFiles, value);
}

[ObservableProperty]
public partial string FileNameTemplate { get; set; }
private string _fileNameTemplate = "$title";
public string FileNameTemplate
{
get => _fileNameTemplate;
set => SetProperty(ref _fileNameTemplate, value);
}

[ObservableProperty]
public partial int ParallelLimit { get; set; }
private int _parallelLimit = 5;
public int ParallelLimit
{
get => _parallelLimit;
set => SetProperty(ref _parallelLimit, value);
}

[ObservableProperty]
public partial string LastContainer { get; set; }
private string _lastContainer = "Mp3";

public SettingsService()
: base(Path.Combine(AppContext.BaseDirectory, "Settings.dat"), SerializerContext.Default)
public string LastContainer
{
// Initialize properties here to prevent linux build error CS8050
IsAutoUpdateEnabled = true;
ShouldInjectTags = true;
FileNameTemplate = "$title";
ParallelLimit = 5;
LastContainer = "Mp3";
get => _lastContainer;
set => SetProperty(ref _lastContainer, value);
}
}

Expand Down

0 comments on commit 69480ac

Please sign in to comment.