Compare commits
2 Commits
787716e221
...
642656971c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
642656971c | ||
|
|
65eab83567 |
@ -2,5 +2,7 @@ namespace EmbyToolbox.Models;
|
||||
|
||||
public sealed class AddFilesOptions
|
||||
{
|
||||
public string Profile { get; init; } = "Emby";
|
||||
public bool DisableSubtitleDefault { get; init; }
|
||||
public bool RemoveForeignAudioAndSubtitles { get; init; }
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using EmbyToolbox.Models;
|
||||
|
||||
@ -9,56 +10,72 @@ 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(Action<AddFilesOptions> onAdd, Action onCancel)
|
||||
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))
|
||||
?? Profiles.FirstOrDefault();
|
||||
AddCommand = new RelayCommand(ExecuteAdd);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<ConversionProfilePresetRow> Profiles { get; }
|
||||
|
||||
public ConversionProfilePresetRow? SelectedProfile
|
||||
{
|
||||
get => _selectedProfile;
|
||||
set
|
||||
{
|
||||
if (ReferenceEquals(_selectedProfile, value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_selectedProfile = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(OptionKeepAllTracks));
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,6 +87,8 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
||||
_onAdd(
|
||||
new AddFilesOptions
|
||||
{
|
||||
Profile = string.IsNullOrWhiteSpace(_selectedProfile?.Profile) ? "Emby" : _selectedProfile.Profile,
|
||||
DisableSubtitleDefault = _disableSubtitleDefault,
|
||||
RemoveForeignAudioAndSubtitles = _removeForeignAudioAndSubtitles
|
||||
});
|
||||
}
|
||||
|
||||
@ -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>();
|
||||
@ -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
|
||||
{
|
||||
@ -1754,9 +1754,15 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
||||
|
||||
AddFilesOptions? selected = null;
|
||||
var vm = new AddFilesOptionsViewModel(
|
||||
_presetRowsForSetup(),
|
||||
CurrentProfileNameForNewTasks(),
|
||||
DisableSubtitleDefault,
|
||||
options =>
|
||||
{
|
||||
selected = options;
|
||||
_defaultQueueProfile = options.Profile;
|
||||
DisableSubtitleDefault = options.DisableSubtitleDefault;
|
||||
SyncDefaultProfileFromList(_presetRowsForSetup());
|
||||
dialog.DialogResult = true;
|
||||
dialog.Close();
|
||||
},
|
||||
|
||||
@ -9,30 +9,67 @@
|
||||
Background="{DynamicResource Ui.Brush.Surface}">
|
||||
<Grid Margin="14">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="Как обработать иностранные встроенные дорожки?"
|
||||
TextWrapping="Wrap"
|
||||
Style="{StaticResource UiTextBody}"
|
||||
Margin="0,0,0,12" />
|
||||
<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>
|
||||
|
||||
<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="0"
|
||||
Grid.Column="0"
|
||||
Text="Профиль"
|
||||
Style="{StaticResource UiTextCaption}"
|
||||
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}"
|
||||
Margin="0,0,0,12">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Profile, Mode=OneWay}"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
|
||||
<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" />
|
||||
|
||||
<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}"
|
||||
|
||||
@ -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">
|
||||
@ -510,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