Compare commits
2 Commits
787716e221
...
642656971c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
642656971c | ||
|
|
65eab83567 |
@ -2,5 +2,7 @@ namespace EmbyToolbox.Models;
|
|||||||
|
|
||||||
public sealed class AddFilesOptions
|
public sealed class AddFilesOptions
|
||||||
{
|
{
|
||||||
|
public string Profile { get; init; } = "Emby";
|
||||||
|
public bool DisableSubtitleDefault { get; init; }
|
||||||
public bool RemoveForeignAudioAndSubtitles { get; init; }
|
public bool RemoveForeignAudioAndSubtitles { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using EmbyToolbox.Models;
|
using EmbyToolbox.Models;
|
||||||
|
|
||||||
@ -9,56 +10,72 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
|||||||
private readonly Action<AddFilesOptions> _onAdd;
|
private readonly Action<AddFilesOptions> _onAdd;
|
||||||
private readonly Action _onCancel;
|
private readonly Action _onCancel;
|
||||||
|
|
||||||
|
private bool _disableSubtitleDefault;
|
||||||
private bool _removeForeignAudioAndSubtitles;
|
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;
|
_onAdd = onAdd;
|
||||||
_onCancel = onCancel;
|
_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);
|
AddCommand = new RelayCommand(ExecuteAdd);
|
||||||
CancelCommand = new RelayCommand(() => _onCancel());
|
CancelCommand = new RelayCommand(() => _onCancel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Взаимоисключающие опции: два свойства, чтобы не использовать TwoWay на одно поле с конвертером (переполнение стека в WPF).</summary>
|
public bool DisableSubtitleDefault
|
||||||
public bool OptionKeepAllTracks
|
|
||||||
{
|
{
|
||||||
get => !_removeForeignAudioAndSubtitles;
|
get => _disableSubtitleDefault;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!value)
|
if (_disableSubtitleDefault == value)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_removeForeignAudioAndSubtitles)
|
_disableSubtitleDefault = value;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_removeForeignAudioAndSubtitles = false;
|
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(OptionRemoveForeignTracks));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OptionRemoveForeignTracks
|
public bool RemoveForeignAudioAndSubtitles
|
||||||
{
|
{
|
||||||
get => _removeForeignAudioAndSubtitles;
|
get => _removeForeignAudioAndSubtitles;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (!value)
|
if (_removeForeignAudioAndSubtitles == value)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_removeForeignAudioAndSubtitles)
|
_removeForeignAudioAndSubtitles = value;
|
||||||
{
|
OnPropertyChanged();
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_removeForeignAudioAndSubtitles = true;
|
public ObservableCollection<ConversionProfilePresetRow> Profiles { get; }
|
||||||
|
|
||||||
|
public ConversionProfilePresetRow? SelectedProfile
|
||||||
|
{
|
||||||
|
get => _selectedProfile;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(_selectedProfile, value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_selectedProfile = value;
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
OnPropertyChanged(nameof(OptionKeepAllTracks));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +87,8 @@ public sealed class AddFilesOptionsViewModel : INotifyPropertyChanged
|
|||||||
_onAdd(
|
_onAdd(
|
||||||
new AddFilesOptions
|
new AddFilesOptions
|
||||||
{
|
{
|
||||||
|
Profile = string.IsNullOrWhiteSpace(_selectedProfile?.Profile) ? "Emby" : _selectedProfile.Profile,
|
||||||
|
DisableSubtitleDefault = _disableSubtitleDefault,
|
||||||
RemoveForeignAudioAndSubtitles = _removeForeignAudioAndSubtitles
|
RemoveForeignAudioAndSubtitles = _removeForeignAudioAndSubtitles
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1539,7 +1539,7 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = CurrentProfileNameForNewTasks();
|
var profile = string.IsNullOrWhiteSpace(addOptions.Profile) ? "Emby" : addOptions.Profile.Trim();
|
||||||
var added = 0;
|
var added = 0;
|
||||||
var dups = 0;
|
var dups = 0;
|
||||||
var newBatch = new List<ConversionQueueItem>();
|
var newBatch = new List<ConversionQueueItem>();
|
||||||
@ -1632,7 +1632,7 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
|||||||
var cts = _analysisCts;
|
var cts = _analysisCts;
|
||||||
var token = cts.Token;
|
var token = cts.Token;
|
||||||
var autoRemoveForeignTracksForBatch = addOptions.RemoveForeignAudioAndSubtitles;
|
var autoRemoveForeignTracksForBatch = addOptions.RemoveForeignAudioAndSubtitles;
|
||||||
var disableSubtitleDefaultForBatch = DisableSubtitleDefault;
|
var disableSubtitleDefaultForBatch = addOptions.DisableSubtitleDefault;
|
||||||
var app = Application.Current;
|
var app = Application.Current;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1754,9 +1754,15 @@ public sealed class ConversionViewModel : INotifyPropertyChanged
|
|||||||
|
|
||||||
AddFilesOptions? selected = null;
|
AddFilesOptions? selected = null;
|
||||||
var vm = new AddFilesOptionsViewModel(
|
var vm = new AddFilesOptionsViewModel(
|
||||||
|
_presetRowsForSetup(),
|
||||||
|
CurrentProfileNameForNewTasks(),
|
||||||
|
DisableSubtitleDefault,
|
||||||
options =>
|
options =>
|
||||||
{
|
{
|
||||||
selected = options;
|
selected = options;
|
||||||
|
_defaultQueueProfile = options.Profile;
|
||||||
|
DisableSubtitleDefault = options.DisableSubtitleDefault;
|
||||||
|
SyncDefaultProfileFromList(_presetRowsForSetup());
|
||||||
dialog.DialogResult = true;
|
dialog.DialogResult = true;
|
||||||
dialog.Close();
|
dialog.Close();
|
||||||
},
|
},
|
||||||
|
|||||||
@ -9,30 +9,67 @@
|
|||||||
Background="{DynamicResource Ui.Brush.Surface}">
|
Background="{DynamicResource Ui.Brush.Surface}">
|
||||||
<Grid Margin="14">
|
<Grid Margin="14">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<TextBlock Grid.Row="0"
|
<Grid Grid.Row="0"
|
||||||
Text="Как обработать иностранные встроенные дорожки?"
|
VerticalAlignment="Top">
|
||||||
TextWrapping="Wrap"
|
<Grid.ColumnDefinitions>
|
||||||
Style="{StaticResource UiTextBody}"
|
<ColumnDefinition Width="Auto" />
|
||||||
Margin="0,0,0,12" />
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<StackPanel Grid.Row="1">
|
<TextBlock Grid.Row="0"
|
||||||
<RadioButton GroupName="AddFilesOptions"
|
Grid.Column="0"
|
||||||
Style="{DynamicResource UiRadio}"
|
Text="Профиль"
|
||||||
Content="Оставить все дорожки"
|
Style="{StaticResource UiTextCaption}"
|
||||||
IsChecked="{Binding OptionKeepAllTracks, Mode=TwoWay}"
|
VerticalAlignment="Center"
|
||||||
Margin="0,0,0,8" />
|
Margin="0,0,12,12" />
|
||||||
<RadioButton GroupName="AddFilesOptions"
|
<ComboBox Grid.Row="0"
|
||||||
Style="{DynamicResource UiRadio}"
|
Grid.Column="1"
|
||||||
Content="Пометить иностранные аудио и субтитры на удаление"
|
Style="{StaticResource UiCombo}"
|
||||||
IsChecked="{Binding OptionRemoveForeignTracks, Mode=TwoWay}" />
|
ItemsSource="{Binding Profiles}"
|
||||||
</StackPanel>
|
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"
|
<Button MinWidth="100"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Style="{StaticResource UiButtonPrimary}"
|
Style="{StaticResource UiButtonPrimary}"
|
||||||
|
|||||||
@ -50,8 +50,7 @@
|
|||||||
<Grid Grid.Row="0" Margin="0,0,0,12" VerticalAlignment="Center">
|
<Grid Grid.Row="0" Margin="0,0,0,12" VerticalAlignment="Center">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*" MinWidth="8" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<StackPanel Grid.Column="0"
|
<StackPanel Grid.Column="0"
|
||||||
Orientation="Horizontal"
|
Orientation="Horizontal"
|
||||||
@ -126,29 +125,6 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</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 Grid.Row="1" MinHeight="0">
|
<Grid Grid.Row="1" MinHeight="0">
|
||||||
@ -510,25 +486,6 @@
|
|||||||
</ToolTip>
|
</ToolTip>
|
||||||
</CheckBox.ToolTip>
|
</CheckBox.ToolTip>
|
||||||
</CheckBox>
|
</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>
|
</StackPanel>
|
||||||
<StackPanel Grid.Column="1"
|
<StackPanel Grid.Column="1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user