diff options
author | sr55 <sr55.hb@outlook.com> | 2019-08-03 20:17:02 +0100 |
---|---|---|
committer | sr55 <sr55.hb@outlook.com> | 2019-08-12 18:41:56 +0100 |
commit | 8d44138c667004478818749914355cd794cbb561 (patch) | |
tree | f04263fd1305146e1191f2d28860211a28545948 /win | |
parent | d5cfa90ad9ac1f822ee2a7bf27416ca2ec44ff65 (diff) |
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
Diffstat (limited to 'win')
10 files changed, 68 insertions, 28 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/Json/Encode/SubtitleTrack.cs b/win/CS/HandBrake.Interop/Interop/Json/Encode/SubtitleTrack.cs index 9c4456e9b..53f2a404d 100644 --- a/win/CS/HandBrake.Interop/Interop/Json/Encode/SubtitleTrack.cs +++ b/win/CS/HandBrake.Interop/Interop/Json/Encode/SubtitleTrack.cs @@ -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> diff --git a/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceAudioTrack.cs b/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceAudioTrack.cs index e0d9bafd8..b373ae5c7 100644 --- a/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceAudioTrack.cs +++ b/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceAudioTrack.cs @@ -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 diff --git a/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceSubtitleTrack.cs b/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceSubtitleTrack.cs index eaeda2a69..d506af086 100644 --- a/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceSubtitleTrack.cs +++ b/win/CS/HandBrake.Interop/Interop/Json/Scan/SourceSubtitleTrack.cs @@ -1,5 +1,5 @@ // -------------------------------------------------------------------------------------------------------------------- -// <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> diff --git a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs index 72948a332..f5de098ac 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskFactory.cs @@ -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 { diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs index bab9d242a..f81d281d2 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs @@ -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(); } } diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs index 79ea7a8b6..c607d8de0 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/SubtitleTrack.cs @@ -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> diff --git a/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs b/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs index 7dad9406e..dc787b5c9 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Factories/TitleFactory.cs @@ -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++; } diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs index d71be495b..705db4b7a 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Audio.cs @@ -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> diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs index 2bfc1c125..1fade0311 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Subtitle.cs @@ -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> diff --git a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml index 1270cb258..d0e3e7fb2 100644 --- a/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml +++ b/win/CS/HandBrakeWPF/Views/SubtitlesView.xaml @@ -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 -->
|