Commit 8d44138c authored by sr55's avatar sr55

WinGui: Add Support for Subtitle Track Naming. Auto-populate the Track name...

WinGui: Add Support for Subtitle Track Naming.  Auto-populate the Track name for both Audio/Subtitles if the source track has it available and we support reading it from that type of source file.  #855 #2213
parent d5cfa90a
......@@ -44,6 +44,8 @@ namespace HandBrake.Interop.Interop.Json.Encode
/// </summary>
public int Track { get; set; }
public string Name { get; set; }
/// <summary>
/// Gets or sets the srt.
/// </summary>
......
......@@ -58,5 +58,7 @@ namespace HandBrake.Interop.Interop.Json.Scan
public int ChannelCount { get; set; }
public AudioAttributes Attributes { get; set; }
public string Name { get; set; }
}
}
\ No newline at end of file
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SourceSubtitleTrack.cs" company="HandBrake Project (http://handbrake.fr)">
// <copyright file="SourceSubtitleTrack.cs" company="HandBrake Project (https://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
......@@ -36,6 +36,8 @@ namespace HandBrake.Interop.Interop.Json.Scan
public string SourceName { get; set; }
public string Name { get; set; }
/// <summary>
/// Gets or sets subtitle attribute information.
/// </summary>
......
......@@ -220,7 +220,8 @@ namespace HandBrakeWPF.Services.Encode.Factories
Default = item.Default,
Forced = item.Forced,
ID = item.SourceTrack.TrackNumber,
Track = (item.SourceTrack.TrackNumber - 1)
Track = (item.SourceTrack.TrackNumber - 1),
Name = item.Name
};
subtitle.SubtitleList.Add(track);
......@@ -234,6 +235,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
Default = item.Default,
Offset = item.SrtOffset,
Burn = item.Burned,
Name = item.Name,
Import =
new SubImport
{
......
......@@ -59,6 +59,11 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.ScannedTrack = new Audio();
this.TrackName = string.Empty;
if (!string.IsNullOrEmpty(this.scannedTrack?.Name))
{
this.TrackName = this.scannedTrack.Name;
}
// Setup Backing Properties
this.EncoderRateType = HandBrakeWPF.Services.Encode.Model.Models.AudioEncoderRateType.Bitrate;
this.SetupLimits();
......@@ -86,9 +91,15 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
{
this.scannedTrack = track.ScannedTrack ?? new Audio();
}
this.TrackName = track.TrackName;
this.Quality = track.Quality;
if (!string.IsNullOrEmpty(this.scannedTrack?.Name))
{
this.TrackName = this.scannedTrack.Name;
}
// Setup Backing Properties
this.encoderRateType = track.EncoderRateType;
this.SetupLimits();
......@@ -137,6 +148,11 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.encoderRateType = track.EncoderRateType;
this.quality = track.Quality;
this.bitrate = track.Bitrate;
if (!string.IsNullOrEmpty(this.scannedTrack?.Name))
{
this.TrackName = this.scannedTrack.Name;
}
this.SetupLimits();
}
......@@ -413,6 +429,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.NotifyOfPropertyChange(() => this.ScannedTrack);
this.NotifyOfPropertyChange(() => this.TrackReference);
this.TrackName = !string.IsNullOrEmpty(this.scannedTrack?.Name) ? this.scannedTrack.Name : null;
this.GetDefaultMixdownIfNull();
}
}
......
......@@ -51,6 +51,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
private string srtLang;
private string name;
#endregion
#region Constructors and Destructors
......@@ -82,6 +84,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
this.SrtPath = subtitle.SrtPath;
this.SubtitleType = subtitle.SubtitleType;
this.SourceTrack = subtitle.SourceTrack;
this.Name = subtitle.Name;
}
#endregion
......@@ -187,6 +190,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
{
this.Forced = false;
}
this.Name = !string.IsNullOrEmpty(this.sourceTrack.Name) ? this.sourceTrack.Name : string.Empty;
}
}
......@@ -255,6 +260,17 @@ namespace HandBrakeWPF.Services.Encode.Model.Models
[Obsolete("Use SourceTrack Instead")]
public string Track { get; set; }
public string Name
{
get => this.name;
set
{
if (value == this.name) return;
this.name = value;
this.NotifyOfPropertyChange(() => this.Name);
}
}
#endregion
/// <summary>
......
......@@ -56,7 +56,7 @@ namespace HandBrakeWPF.Services.Scan.Factories
int currentAudioTrack = 1;
foreach (SourceAudioTrack track in title.AudioList)
{
converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, track.Codec, track.SampleRate, track.BitRate, track.ChannelLayout));
converted.AudioTracks.Add(new Audio(currentAudioTrack, track.Language, track.LanguageCode, track.Description, track.Codec, track.SampleRate, track.BitRate, track.ChannelLayout, track.Name));
currentAudioTrack++;
}
......@@ -96,7 +96,7 @@ namespace HandBrakeWPF.Services.Scan.Factories
bool canBurn = HBFunctions.hb_subtitle_can_burn(track.Source) > 0;
bool canSetForcedOnly = HBFunctions.hb_subtitle_can_force(track.Source) > 0;
converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly));
converted.Subtitles.Add(new Subtitle(track.Source, currentSubtitleTrack, track.Language, track.LanguageCode, convertedType, canBurn, canSetForcedOnly, track.Name));
currentSubtitleTrack++;
}
......
......@@ -51,9 +51,10 @@ namespace HandBrakeWPF.Services.Scan.Model
/// <param name="channelLayout">
/// The channel Layout.
/// </param>
public Audio(int trackNumber, string language, string languageCode, string description, int codec, int sampleRate, int bitrate, long channelLayout)
public Audio(int trackNumber, string language, string languageCode, string description, int codec, int sampleRate, int bitrate, long channelLayout, string name)
{
this.ChannelLayout = channelLayout;
this.Name = name;
this.TrackNumber = trackNumber;
this.Language = language;
this.LanguageCode = languageCode;
......@@ -108,6 +109,8 @@ namespace HandBrakeWPF.Services.Scan.Model
/// </summary>
public long ChannelLayout { get; set; }
public string Name { get; set; }
/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
......
......@@ -37,28 +37,7 @@ namespace HandBrakeWPF.Services.Scan.Model
/// <summary>
/// Initializes a new instance of the <see cref="Subtitle"/> class.
/// </summary>
/// <param name="sourceId">
/// The source Id.
/// </param>
/// <param name="trackNumber">
/// The track number.
/// </param>
/// <param name="language">
/// The language.
/// </param>
/// <param name="languageCode">
/// The language code.
/// </param>
/// <param name="subtitleType">
/// The subtitle type.
/// </param>
/// <param name="canBurn">
/// The can Burn.
/// </param>
/// <param name="canForce">
/// The can Force.
/// </param>
public Subtitle(int sourceId, int trackNumber, string language, string languageCode, SubtitleType subtitleType, bool canBurn, bool canForce)
public Subtitle(int sourceId, int trackNumber, string language, string languageCode, SubtitleType subtitleType, bool canBurn, bool canForce, string name)
{
this.SourceId = sourceId;
this.TrackNumber = trackNumber;
......@@ -67,6 +46,7 @@ namespace HandBrakeWPF.Services.Scan.Model
this.SubtitleType = subtitleType;
this.CanBurnIn = canBurn;
this.CanForce = canForce;
this.Name = name;
}
/// <summary>
......@@ -101,6 +81,7 @@ namespace HandBrakeWPF.Services.Scan.Model
{
return this.LanguageCode.Replace("iso639-2: ", string.Empty).Trim();
}
return string.Empty;
}
}
......@@ -122,6 +103,8 @@ namespace HandBrakeWPF.Services.Scan.Model
/// </summary>
public SubtitleType SubtitleType { get; set; }
public string Name { get; set; }
/// <summary>
/// Gets Subtitle Type
/// </summary>
......
......@@ -155,6 +155,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
......@@ -194,7 +195,12 @@
</cal:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</CheckBox>
</CheckBox>
<StackPanel Orientation="Horizontal" Grid.Column="6" Margin="5,0,0,0">
<TextBlock Text="Name: " FontWeight="Bold" Margin="0,0,5,0" VerticalAlignment="Center" />
<TextBox x:Name="TrackName" Text="{Binding Name}" Grid.Column="10" Width="120" />
</StackPanel>
</Grid>
<!-- SRT Subtitle Settings -->
......@@ -212,6 +218,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
......@@ -259,6 +266,11 @@
</i:Interaction.Triggers>
</CheckBox>
<StackPanel Orientation="Horizontal" Grid.Column="10" Margin="5,0,0,0">
<TextBlock Text="Name: " FontWeight="Bold" Margin="0,0,5,0" />
<TextBox x:Name="TrackNameSrt" Text="{Binding Name}" Grid.Column="10" Width="120" />
</StackPanel>
</Grid>
<!-- Delete -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment