Move conversion default profile to add options

This commit is contained in:
Emby Toolbox 2026-05-16 15:00:24 +05:00
parent 787716e221
commit 65eab83567
5 changed files with 57 additions and 33 deletions

View File

@ -2,5 +2,6 @@ namespace EmbyToolbox.Models;
public sealed class AddFilesOptions
{
public string Profile { get; init; } = "Emby";
public bool RemoveForeignAudioAndSubtitles { get; init; }
}

View File

@ -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<AddFilesOptions> onAdd, Action onCancel)
public AddFilesOptionsViewModel(
IReadOnlyList<ConversionProfilePresetRow> profiles,
string selectedProfileName,
Action<AddFilesOptions> onAdd,
Action onCancel)
{
_onAdd = onAdd;
_onCancel = onCancel;
Profiles = new ObservableCollection<ConversionProfilePresetRow>(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<ConversionProfilePresetRow> 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
});
}

View File

@ -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<ConversionQueueItem>();
@ -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();
},

View File

@ -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 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="Как обработать иностранные встроенные дорожки?"
<StackPanel Grid.Row="0"
Margin="0,0,0,12">
<TextBlock Text="Профиль для новых строк"
Style="{StaticResource UiTextCaption}"
Margin="0,0,0,6" />
<ComboBox Style="{StaticResource UiCombo}"
ItemsSource="{Binding Profiles}"
SelectedItem="{Binding SelectedProfile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Profile, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Как обработать иностранные встроенные дорожки?"
TextWrapping="Wrap"
Style="{StaticResource UiTextBody}"
Margin="0,0,0,12" />
Margin="0,14,0,0" />
</StackPanel>
<StackPanel Grid.Row="1">
<RadioButton GroupName="AddFilesOptions"

View File

@ -50,8 +50,7 @@
<Grid Grid.Row="0" Margin="0,0,0,12" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="8" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0"
Orientation="Horizontal"
@ -126,29 +125,6 @@
</StackPanel>
</Button>
</StackPanel>
<StackPanel Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center"
Margin="16,0,0,0">
<TextBlock VerticalAlignment="Center"
Margin="0,0,8,0"
Text="Профиль по умолчанию:"
Style="{StaticResource UiTextCaption}" />
<ComboBox Width="196"
Style="{StaticResource UiCombo}"
VerticalAlignment="Center"
HorizontalAlignment="Right"
IsEnabled="{Binding CanEditQueue}"
ItemsSource="{Binding DataContext.ConversionProfiles, RelativeSource={RelativeSource AncestorType=Window}}"
SelectedItem="{Binding SelectedDefaultProfile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Profile, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</Grid>
<Grid Grid.Row="1" MinHeight="0">