Move subtitle default option to add dialog
This commit is contained in:
parent
65eab83567
commit
642656971c
@ -3,5 +3,6 @@ namespace EmbyToolbox.Models;
|
||||
public sealed class AddFilesOptions
|
||||
{
|
||||
public string Profile { get; init; } = "Emby";
|
||||
public bool DisableSubtitleDefault { get; init; }
|
||||
public bool RemoveForeignAudioAndSubtitles { get; init; }
|
||||
}
|
||||
|
||||
@ -10,17 +10,20 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
||||
private readonly Action<AddFilesOptions> _onAdd;
|
||||
private readonly Action _onCancel;
|
||||
|
||||
private bool _disableSubtitleDefault;
|
||||
private bool _removeForeignAudioAndSubtitles;
|
||||
private ConversionProfilePresetRow? _selectedProfile;
|
||||
|
||||
public AddFilesOptionsViewModel(
|
||||
IReadOnlyList<ConversionProfilePresetRow> profiles,
|
||||
string selectedProfileName,
|
||||
bool disableSubtitleDefault,
|
||||
Action<AddFilesOptions> onAdd,
|
||||
Action onCancel)
|
||||
{
|
||||
_onAdd = onAdd;
|
||||
_onCancel = onCancel;
|
||||
_disableSubtitleDefault = disableSubtitleDefault;
|
||||
Profiles = new ObservableCollection<ConversionProfilePresetRow>(profiles);
|
||||
_selectedProfile = Profiles.FirstOrDefault(p => p.Profile.Equals(selectedProfileName, StringComparison.OrdinalIgnoreCase))
|
||||
?? Profiles.FirstOrDefault(p => p.Profile.Equals("Emby", StringComparison.OrdinalIgnoreCase))
|
||||
@ -29,46 +32,33 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
||||
CancelCommand = new RelayCommand(() => _onCancel());
|
||||
}
|
||||
|
||||
/// <summary>Взаимоисключающие опции: два свойства, чтобы не использовать TwoWay на одно поле с конвертером (переполнение стека в WPF).</summary>
|
||||
public bool OptionKeepAllTracks
|
||||
public bool DisableSubtitleDefault
|
||||
{
|
||||
get => !_removeForeignAudioAndSubtitles;
|
||||
get => _disableSubtitleDefault;
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
if (_disableSubtitleDefault == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_removeForeignAudioAndSubtitles)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_removeForeignAudioAndSubtitles = false;
|
||||
_disableSubtitleDefault = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(OptionRemoveForeignTracks));
|
||||
}
|
||||
}
|
||||
|
||||
public bool OptionRemoveForeignTracks
|
||||
public bool RemoveForeignAudioAndSubtitles
|
||||
{
|
||||
get => _removeForeignAudioAndSubtitles;
|
||||
set
|
||||
{
|
||||
if (!value)
|
||||
if (_removeForeignAudioAndSubtitles == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_removeForeignAudioAndSubtitles)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_removeForeignAudioAndSubtitles = true;
|
||||
_removeForeignAudioAndSubtitles = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(OptionKeepAllTracks));
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,6 +88,7 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
||||
new AddFilesOptions
|
||||
{
|
||||
Profile = string.IsNullOrWhiteSpace(_selectedProfile?.Profile) ? "Emby" : _selectedProfile.Profile,
|
||||
DisableSubtitleDefault = _disableSubtitleDefault,
|
||||
RemoveForeignAudioAndSubtitles = _removeForeignAudioAndSubtitles
|
||||
});
|
||||
}
|
||||
|
||||
@ -1632,7 +1632,7 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
||||
var cts = _analysisCts;
|
||||
var token = cts.Token;
|
||||
var autoRemoveForeignTracksForBatch = addOptions.RemoveForeignAudioAndSubtitles;
|
||||
var disableSubtitleDefaultForBatch = DisableSubtitleDefault;
|
||||
var disableSubtitleDefaultForBatch = addOptions.DisableSubtitleDefault;
|
||||
var app = Application.Current;
|
||||
try
|
||||
{
|
||||
@ -1756,10 +1756,12 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
||||
var vm = new AddFilesOptionsViewModel(
|
||||
_presetRowsForSetup(),
|
||||
CurrentProfileNameForNewTasks(),
|
||||
DisableSubtitleDefault,
|
||||
options =>
|
||||
{
|
||||
selected = options;
|
||||
_defaultQueueProfile = options.Profile;
|
||||
DisableSubtitleDefault = options.DisableSubtitleDefault;
|
||||
SyncDefaultProfileFromList(_presetRowsForSetup());
|
||||
dialog.DialogResult = true;
|
||||
dialog.Close();
|
||||
|
||||
@ -3,25 +3,40 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Параметры добавления"
|
||||
Width="520"
|
||||
Height="300"
|
||||
Height="230"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="{DynamicResource Ui.Brush.Surface}">
|
||||
<Grid Margin="14">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0"
|
||||
Margin="0,0,0,12">
|
||||
<TextBlock Text="Профиль для новых строк"
|
||||
<Grid Grid.Row="0"
|
||||
VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Text="Профиль"
|
||||
Style="{StaticResource UiTextCaption}"
|
||||
Margin="0,0,0,6" />
|
||||
<ComboBox Style="{StaticResource UiCombo}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,12" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource UiCombo}"
|
||||
ItemsSource="{Binding Profiles}"
|
||||
SelectedItem="{Binding SelectedProfile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
||||
SelectedItem="{Binding SelectedProfile, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="0,0,0,12">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Profile, Mode=OneWay}"
|
||||
@ -29,25 +44,32 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<TextBlock Text="Как обработать иностранные встроенные дорожки?"
|
||||
TextWrapping="Wrap"
|
||||
Style="{StaticResource UiTextBody}"
|
||||
Margin="0,14,0,0" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="1">
|
||||
<RadioButton GroupName="AddFilesOptions"
|
||||
Style="{DynamicResource UiRadio}"
|
||||
Content="Оставить все дорожки"
|
||||
IsChecked="{Binding OptionKeepAllTracks, Mode=TwoWay}"
|
||||
Margin="0,0,0,8" />
|
||||
<RadioButton GroupName="AddFilesOptions"
|
||||
Style="{DynamicResource UiRadio}"
|
||||
Content="Пометить иностранные аудио и субтитры на удаление"
|
||||
IsChecked="{Binding OptionRemoveForeignTracks, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Text="Отключать субтитры"
|
||||
Style="{StaticResource UiTextCaption}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,12" />
|
||||
<CheckBox Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding DisableSubtitleDefault, Mode=TwoWay}"
|
||||
Margin="0,0,0,12" />
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
|
||||
<TextBlock Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Text="Удалять иностранные дорожки"
|
||||
Style="{StaticResource UiTextCaption}"
|
||||
VerticalAlignment="Center"
|
||||
Margin="0,0,12,0" />
|
||||
<CheckBox Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding RemoveForeignAudioAndSubtitles, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
|
||||
<Button MinWidth="100"
|
||||
Margin="0,0,8,0"
|
||||
Style="{StaticResource UiButtonPrimary}"
|
||||
|
||||
@ -486,25 +486,6 @@
|
||||
</ToolTip>
|
||||
</CheckBox.ToolTip>
|
||||
</CheckBox>
|
||||
<CheckBox Margin="12,0,0,0"
|
||||
Height="24"
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center"
|
||||
IsEnabled="{Binding CanEditQueue}"
|
||||
IsChecked="{Binding DisableSubtitleDefault, Mode=TwoWay}">
|
||||
<CheckBox.Content>
|
||||
<TextBlock Text="Отключать субтитры"
|
||||
FontSize="12"
|
||||
LineHeight="16"
|
||||
LineStackingStrategy="BlockLineHeight" />
|
||||
</CheckBox.Content>
|
||||
<CheckBox.ToolTip>
|
||||
<ToolTip MaxWidth="360">
|
||||
<TextBlock TextWrapping="Wrap"
|
||||
Text="Если включено, у всех subtitle-дорожек Default будет выключен." />
|
||||
</ToolTip>
|
||||
</CheckBox.ToolTip>
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user