diff --git a/EmbyToolbox/Models/AddFilesOptions.cs b/EmbyToolbox/Models/AddFilesOptions.cs index 28a5814..b30eea2 100644 --- a/EmbyToolbox/Models/AddFilesOptions.cs +++ b/EmbyToolbox/Models/AddFilesOptions.cs @@ -2,5 +2,6 @@ namespace EmbyToolbox.Models; public sealed class AddFilesOptions { + public string Profile { get; init; } = "Emby"; public bool RemoveForeignAudioAndSubtitles { get; init; } } diff --git a/EmbyToolbox/ViewModels/AddFilesOptionsViewModel.cs b/EmbyToolbox/ViewModels/AddFilesOptionsViewModel.cs index 2a084fc..c18c513 100644 --- a/EmbyToolbox/ViewModels/AddFilesOptionsViewModel.cs +++ b/EmbyToolbox/ViewModels/AddFilesOptionsViewModel.cs @@ -1,4 +1,5 @@ using System.ComponentModel; +using System.Collections.ObjectModel; using System.Runtime.CompilerServices; using EmbyToolbox.Models; @@ -10,11 +11,20 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged private readonly Action _onCancel; private bool _removeForeignAudioAndSubtitles; + private ConversionProfilePresetRow? _selectedProfile; - public AddFilesOptionsViewModel(Action onAdd, Action onCancel) + public AddFilesOptionsViewModel( + IReadOnlyList profiles, + string selectedProfileName, + Action onAdd, + Action onCancel) { _onAdd = onAdd; _onCancel = onCancel; + Profiles = new ObservableCollection(profiles); + _selectedProfile = Profiles.FirstOrDefault(p => p.Profile.Equals(selectedProfileName, StringComparison.OrdinalIgnoreCase)) + ?? Profiles.FirstOrDefault(p => p.Profile.Equals("Emby", StringComparison.OrdinalIgnoreCase)) + ?? Profiles.FirstOrDefault(); AddCommand = new RelayCommand(ExecuteAdd); CancelCommand = new RelayCommand(() => _onCancel()); } @@ -62,6 +72,23 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged } } + public ObservableCollection Profiles { get; } + + public ConversionProfilePresetRow? SelectedProfile + { + get => _selectedProfile; + set + { + if (ReferenceEquals(_selectedProfile, value)) + { + return; + } + + _selectedProfile = value; + OnPropertyChanged(); + } + } + public RelayCommand AddCommand { get; } public RelayCommand CancelCommand { get; } @@ -70,6 +97,7 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged _onAdd( new AddFilesOptions { + Profile = string.IsNullOrWhiteSpace(_selectedProfile?.Profile) ? "Emby" : _selectedProfile.Profile, RemoveForeignAudioAndSubtitles = _removeForeignAudioAndSubtitles }); } diff --git a/EmbyToolbox/ViewModels/ConversionViewModel.cs b/EmbyToolbox/ViewModels/ConversionViewModel.cs index f62f72e..afe2f7a 100644 --- a/EmbyToolbox/ViewModels/ConversionViewModel.cs +++ b/EmbyToolbox/ViewModels/ConversionViewModel.cs @@ -1539,7 +1539,7 @@ public sealed class ConversionViewModel : INotifyPropertyChanged return; } - var profile = CurrentProfileNameForNewTasks(); + var profile = string.IsNullOrWhiteSpace(addOptions.Profile) ? "Emby" : addOptions.Profile.Trim(); var added = 0; var dups = 0; var newBatch = new List(); @@ -1754,9 +1754,13 @@ public sealed class ConversionViewModel : INotifyPropertyChanged AddFilesOptions? selected = null; var vm = new AddFilesOptionsViewModel( + _presetRowsForSetup(), + CurrentProfileNameForNewTasks(), options => { selected = options; + _defaultQueueProfile = options.Profile; + SyncDefaultProfileFromList(_presetRowsForSetup()); dialog.DialogResult = true; dialog.Close(); }, diff --git a/EmbyToolbox/Views/AddFilesOptionsDialog.xaml b/EmbyToolbox/Views/AddFilesOptionsDialog.xaml index cc40eaa..959577a 100644 --- a/EmbyToolbox/Views/AddFilesOptionsDialog.xaml +++ b/EmbyToolbox/Views/AddFilesOptionsDialog.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Параметры добавления" Width="520" - Height="230" + Height="300" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" Background="{DynamicResource Ui.Brush.Surface}"> @@ -14,11 +14,26 @@ - + + + + + + + + + + + - - + - - - - - - - - - -