summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-08-07 12:54:52 +0000
committersr55 <[email protected]>2011-08-07 12:54:52 +0000
commitc24d8ddd65e9549b26e813681cac60365c1c5175 (patch)
tree4b38197660b58eb35b7e7e3854e08f796901e30a
parentc193472743940be0d0fab597328a95fc4724d0fa (diff)
WinGui: Refactored the Automatic Audio Selection so that it is more intuitive. Now, it will use your preferred language for the preset tracks, then add either all additional tracks, or all additional tracks for your selected additional languages. This should avoid any confusion as to why the previous setup as overriding presets.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4157 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/CS/Controls/AudioPanel.cs118
-rw-r--r--win/CS/frmOptions.Designer.cs42
-rw-r--r--win/CS/frmOptions.resx3
3 files changed, 89 insertions, 74 deletions
diff --git a/win/CS/Controls/AudioPanel.cs b/win/CS/Controls/AudioPanel.cs
index 3e912579b..f97af0605 100644
--- a/win/CS/Controls/AudioPanel.cs
+++ b/win/CS/Controls/AudioPanel.cs
@@ -184,10 +184,13 @@ namespace Handbrake.Controls
/// <param name="preset">A preset</param>
public void SetTrackListAfterTitleChange(Title selectedTitle, Preset preset)
{
+ // Reset
+ this.AudioTracks.Clear();
+ this.ScannedTracks.Clear();
+
if (selectedTitle.AudioTracks.Count == 0)
{
- this.AudioTracks.Clear();
- this.ScannedTracks.Clear();
+
this.ScannedTracks.Add(AudioHelper.NoneFound);
this.drp_audioTrack.Refresh();
drp_audioTrack.SelectedIndex = 0;
@@ -195,7 +198,7 @@ namespace Handbrake.Controls
}
// Setup the Audio track source dropdown with the new audio tracks.
- this.ScannedTracks.Clear();
+ // this.ScannedTracks.Clear();
this.drp_audioTrack.SelectedItem = null;
this.ScannedTracks = new BindingList<Audio>(selectedTitle.AudioTracks.ToList());
drp_audioTrack.DataSource = this.ScannedTracks;
@@ -432,6 +435,12 @@ namespace Handbrake.Controls
foundTrack = true;
continue;
}
+
+ if (Properties.Settings.Default.addOnlyOneAudioPerLanguage && currentTrack.TrackDisplay.Contains(sourceTrack.Language))
+ {
+ foundTrack = true;
+ continue;
+ }
}
if (foundTrack)
@@ -575,8 +584,7 @@ namespace Handbrake.Controls
return;
}
- // If the Native Language is not set. Just set Track information in each output track.
- // Presets have control over audio selected
+ // Handle Preferred Language
if (Properties.Settings.Default.NativeLanguage == "Any")
{
drp_audioTrack.SelectedIndex = 0;
@@ -589,27 +597,36 @@ namespace Handbrake.Controls
}
return;
+ }
+ else
+ {
+ foreach (Audio item in drp_audioTrack.Items)
+ {
+ if (item.Language.Contains(Properties.Settings.Default.NativeLanguage))
+ {
+ drp_audioTrack.SelectedItem = item;
+ break;
+ }
+ }
+
+ foreach (AudioTrack track in this.audioTracks)
+ {
+ if (this.drp_audioTrack.SelectedItem != null)
+ {
+ track.ScannedTrack = this.drp_audioTrack.SelectedItem as Audio;
+ }
+ }
}
- // Remove all old Audiotracks before adding new ones.
- this.AudioTracks.Clear();
-
// Array with the Index numbers of the prefered and additional languages.
// This allows to have for each language the order in which they appear in the DVD list.
Dictionary<String, ArrayList> languageIndex = new Dictionary<String, ArrayList>();
- // This is used to keep the Prefered Language in the front and the other languages in order.
- ArrayList languageOrder = new ArrayList();
-
- // New DUB Settings
+ // Now add any additional Langauges tracks on top of the presets tracks.
int mode = Properties.Settings.Default.DubModeAudio;
-
- // Native Language is not 'Any', so initialising the Language Dictionary
- if (mode >= 3)
+ ArrayList languageOrder = new ArrayList(); // This is used to keep the Prefered Language in the front and the other languages in order. TODO this is no longer required, refactor this.
+ if (mode > 0)
{
- languageIndex.Add(Properties.Settings.Default.NativeLanguage, new ArrayList());
- languageOrder.Add(Properties.Settings.Default.NativeLanguage);
-
foreach (string item in Properties.Settings.Default.SelectedLanguages)
{
if (!languageIndex.ContainsKey(item))
@@ -640,22 +657,20 @@ namespace Handbrake.Controls
i++;
}
- // If there are no selected languages found, the first available will be taken.
+ // There are no additional Languages, so we don't need to continue processing.
if (!elementFound)
- mode = 2;
+ {
+ // return;
+ }
}
switch (mode)
{
- case 1: // Adding all audio tracks
+ case 1: // Adding all remaining audio tracks
this.mnu_AddAll_Click(this, EventArgs.Empty);
break;
- case 2: // Adding only the first Audio Track
- drp_audioTrack.SelectedIndex = 0;
- if (drp_audioTrack.SelectedItem != null)
- this.AddAudioTrack_Click(this, EventArgs.Empty);
- break;
- case 3:
+ case 2: // Add Langauges tracks for the additional languages selected, in-order.
+ audioList.ClearSelection();
foreach (string item in languageOrder)
{
if (languageIndex[item].Count > 0)
@@ -665,31 +680,21 @@ namespace Handbrake.Controls
drp_audioTrack.SelectedIndex = i;
if (drp_audioTrack.SelectedItem != null)
{
- this.AddAudioTrack_Click(this, EventArgs.Empty);
- audioList.ClearSelection();
+ Audio track = drp_audioTrack.SelectedItem as Audio;
+ if (track != null)
+ {
+ if (!TrackExists(track))
+ {
+ this.AddAudioTrack_Click(this, EventArgs.Empty);
+ audioList.ClearSelection();
+ }
+ }
}
}
}
}
break;
- case 4:
- if (languageIndex[(string)languageOrder[0]].Count > 0)
- {
- foreach (int i in languageIndex[(string)languageOrder[0]])
- {
- drp_audioTrack.SelectedIndex = i;
- if (drp_audioTrack.SelectedItem != null)
- {
- this.AddAudioTrack_Click(this, EventArgs.Empty);
- audioList.ClearSelection();
- }
- }
- }
- break;
}
-
- // Revert the selection back tio the first item.
- drp_audioTrack.SelectedIndex = 0;
}
/// <summary>
@@ -919,6 +924,27 @@ namespace Handbrake.Controls
}
}
+ /// <summary>
+ /// Check if a track already exists
+ /// </summary>
+ /// <param name="sourceTrack">
+ /// The source track.
+ /// </param>
+ /// <returns>
+ /// True if it does
+ /// </returns>
+ private bool TrackExists(Audio sourceTrack)
+ {
+ foreach (AudioTrack currentTrack in this.AudioTracks)
+ {
+ if (currentTrack.Track.HasValue && currentTrack.Track.Value == sourceTrack.TrackNumber)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
#endregion
private void btn_AdvancedAudio_Click(object sender, EventArgs e)
diff --git a/win/CS/frmOptions.Designer.cs b/win/CS/frmOptions.Designer.cs
index 05cee599d..1feabd3f8 100644
--- a/win/CS/frmOptions.Designer.cs
+++ b/win/CS/frmOptions.Designer.cs
@@ -165,7 +165,6 @@ namespace Handbrake
this.label37 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
- this.label48 = new System.Windows.Forms.Label();
this.tab_options.SuspendLayout();
this.tab_general.SuspendLayout();
this.tab_outputFiles.SuspendLayout();
@@ -627,7 +626,6 @@ namespace Handbrake
//
// tab_audio_sub
//
- this.tab_audio_sub.Controls.Add(this.label48);
this.tab_audio_sub.Controls.Add(this.label39);
this.tab_audio_sub.Controls.Add(this.audioSelectionPanel);
this.tab_audio_sub.Controls.Add(this.label45);
@@ -646,7 +644,7 @@ namespace Handbrake
// label39
//
this.label39.AutoSize = true;
- this.label39.Location = new System.Drawing.Point(16, 82);
+ this.label39.Location = new System.Drawing.Point(6, 68);
this.label39.Name = "label39";
this.label39.Size = new System.Drawing.Size(92, 13);
this.label39.TabIndex = 109;
@@ -663,7 +661,7 @@ namespace Handbrake
this.audioSelectionPanel.Controls.Add(this.label47);
this.audioSelectionPanel.Controls.Add(this.button_removeLanguage);
this.audioSelectionPanel.Controls.Add(this.button_clearLanguage);
- this.audioSelectionPanel.Location = new System.Drawing.Point(125, 79);
+ this.audioSelectionPanel.Location = new System.Drawing.Point(125, 68);
this.audioSelectionPanel.Name = "audioSelectionPanel";
this.audioSelectionPanel.Size = new System.Drawing.Size(381, 166);
this.audioSelectionPanel.TabIndex = 108;
@@ -764,11 +762,11 @@ namespace Handbrake
//
this.label45.AutoSize = true;
this.label45.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.label45.Location = new System.Drawing.Point(253, 57);
+ this.label45.Location = new System.Drawing.Point(249, 37);
this.label45.Name = "label45";
- this.label45.Size = new System.Drawing.Size(84, 11);
+ this.label45.Size = new System.Drawing.Size(107, 11);
this.label45.TabIndex = 107;
- this.label45.Text = "(Primary language)";
+ this.label45.Text = "Primary Audio Language";
//
// groupBox2
//
@@ -785,7 +783,7 @@ namespace Handbrake
this.groupBox2.Size = new System.Drawing.Size(537, 106);
this.groupBox2.TabIndex = 106;
this.groupBox2.TabStop = false;
- this.groupBox2.Text = "Add Automatically";
+ this.groupBox2.Text = "Add Additional Tracks";
//
// label44
//
@@ -817,7 +815,7 @@ namespace Handbrake
"Prefered Only"});
this.cb_subtitleMode.Location = new System.Drawing.Point(79, 52);
this.cb_subtitleMode.Name = "cb_subtitleMode";
- this.cb_subtitleMode.Size = new System.Drawing.Size(132, 21);
+ this.cb_subtitleMode.Size = new System.Drawing.Size(147, 21);
this.cb_subtitleMode.TabIndex = 107;
this.ToolTip.SetToolTip(this.cb_subtitleMode, resources.GetString("cb_subtitleMode.ToolTip"));
this.cb_subtitleMode.SelectedIndexChanged += new System.EventHandler(this.cb_subtitleMode_SelectedIndexChanged);
@@ -828,13 +826,11 @@ namespace Handbrake
this.cb_audioMode.FormattingEnabled = true;
this.cb_audioMode.Items.AddRange(new object[] {
"None",
- "All",
- "First",
- "Selected",
- "Prefered Only"});
+ "All Remaining Tracks",
+ "All for Selected Languages"});
this.cb_audioMode.Location = new System.Drawing.Point(79, 25);
this.cb_audioMode.Name = "cb_audioMode";
- this.cb_audioMode.Size = new System.Drawing.Size(132, 21);
+ this.cb_audioMode.Size = new System.Drawing.Size(147, 21);
this.cb_audioMode.TabIndex = 106;
this.ToolTip.SetToolTip(this.cb_audioMode, resources.GetString("cb_audioMode.ToolTip"));
this.cb_audioMode.SelectedIndexChanged += new System.EventHandler(this.cb_audioMode_SelectedIndexChanged);
@@ -854,7 +850,7 @@ namespace Handbrake
// check_AddOnlyOneAudioPerLanguage
//
this.check_AddOnlyOneAudioPerLanguage.AutoSize = true;
- this.check_AddOnlyOneAudioPerLanguage.Location = new System.Drawing.Point(221, 27);
+ this.check_AddOnlyOneAudioPerLanguage.Location = new System.Drawing.Point(232, 27);
this.check_AddOnlyOneAudioPerLanguage.Name = "check_AddOnlyOneAudioPerLanguage";
this.check_AddOnlyOneAudioPerLanguage.Size = new System.Drawing.Size(192, 17);
this.check_AddOnlyOneAudioPerLanguage.TabIndex = 93;
@@ -868,7 +864,7 @@ namespace Handbrake
this.check_AddCCTracks.AutoSize = true;
this.check_AddCCTracks.Location = new System.Drawing.Point(79, 79);
this.check_AddCCTracks.Name = "check_AddCCTracks";
- this.check_AddCCTracks.Size = new System.Drawing.Size(198, 17);
+ this.check_AddCCTracks.Size = new System.Drawing.Size(199, 17);
this.check_AddCCTracks.TabIndex = 92;
this.check_AddCCTracks.Text = "Add Closed Captions when available";
this.ToolTip.SetToolTip(this.check_AddCCTracks, "Add any CC tracks if they exist regardless of language settings");
@@ -902,7 +898,7 @@ namespace Handbrake
// label15
//
this.label15.AutoSize = true;
- this.label15.Location = new System.Drawing.Point(16, 52);
+ this.label15.Location = new System.Drawing.Point(6, 35);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(107, 13);
this.label15.TabIndex = 88;
@@ -912,7 +908,7 @@ namespace Handbrake
//
this.drop_preferredLang.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.drop_preferredLang.FormattingEnabled = true;
- this.drop_preferredLang.Location = new System.Drawing.Point(129, 52);
+ this.drop_preferredLang.Location = new System.Drawing.Point(125, 32);
this.drop_preferredLang.Name = "drop_preferredLang";
this.drop_preferredLang.Size = new System.Drawing.Size(118, 21);
this.drop_preferredLang.TabIndex = 87;
@@ -1783,15 +1779,6 @@ namespace Handbrake
this.pictureBox2.TabIndex = 60;
this.pictureBox2.TabStop = false;
//
- // label48
- //
- this.label48.AutoSize = true;
- this.label48.Location = new System.Drawing.Point(16, 28);
- this.label48.Name = "label48";
- this.label48.Size = new System.Drawing.Size(296, 13);
- this.label48.TabIndex = 110;
- this.label48.Text = "Note: These settings will override settings stored in presets.";
- //
// frmOptions
//
this.AcceptButton = this.btn_close;
@@ -1970,6 +1957,5 @@ namespace Handbrake
private System.Windows.Forms.Label label39;
private System.Windows.Forms.NumericUpDown ud_minTitleLength;
private System.Windows.Forms.Label label40;
- private System.Windows.Forms.Label label48;
}
} \ No newline at end of file
diff --git a/win/CS/frmOptions.resx b/win/CS/frmOptions.resx
index 104647c5f..fd66b7b5e 100644
--- a/win/CS/frmOptions.resx
+++ b/win/CS/frmOptions.resx
@@ -120,6 +120,9 @@
<metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 18</value>
</metadata>
+ <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>132, 18</value>
+ </metadata>
<data name="cb_mp4FileMode.ToolTip" xml:space="preserve">
<value>The default file extension for MP4 Files.
Automatic - This will use M4v when AC3 Audio, SRT Subtitles or Chapters are present, otherwise MP4.