From a2fd1bd46d791f0fb85651955965aa124cb01f8f Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 20 Aug 2010 19:15:16 +0000 Subject: [PATCH] WinGui: - Added new audio/subs option: "Use Preferred Language for Audio and Subtitles" and "Add Closed Captions when available" Thanks to Shatian for the Patch! git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3485 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/AudioPanel.cs | 2 +- win/C#/Controls/Subtitles.cs | 56 ++++++++++++++---------- win/C#/Properties/Settings.Designer.cs | 20 +++++++-- win/C#/Properties/Settings.settings | 7 ++- win/C#/app.config | 7 ++- win/C#/frmOptions.Designer.cs | 33 +++++++++++++- win/C#/frmOptions.cs | 59 +++++++++++++++++++------- win/C#/frmOptions.resx | 3 ++ 8 files changed, 139 insertions(+), 48 deletions(-) diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs index 6d4b00804..cca75d41a 100644 --- a/win/C#/Controls/AudioPanel.cs +++ b/win/C#/Controls/AudioPanel.cs @@ -174,7 +174,7 @@ namespace Handbrake.Controls drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 2 ? 1 : 0; else { - if (Properties.Settings.Default.DubAudio) // "Dub Foreign language audio" + if (Properties.Settings.Default.DubMode > 1) // "Dub Foreign language audio" { int i = 0; foreach (object item in drp_audioTrack.Items) diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs index e923598e7..e5acf0789 100644 --- a/win/C#/Controls/Subtitles.cs +++ b/win/C#/Controls/Subtitles.cs @@ -195,7 +195,7 @@ namespace Handbrake.Controls srtFile = drp_subtitleTracks.SelectedItem.ToString(); srtLangVal = srt_lang.SelectedItem.ToString(); srtCode = srt_charcode.SelectedItem.ToString(); - srtOffsetMs = (int) srt_offset.Value; + srtOffsetMs = (int)srt_offset.Value; if (defaultSub == "Yes") SetNoSrtDefault(); } else @@ -210,14 +210,14 @@ namespace Handbrake.Controls SubtitleInfo track = new SubtitleInfo { - Track = trackName, - Forced = forcedVal, - Burned = burnedVal, - Default = defaultSub, - SrtLang = srtLangVal, - SrtCharCode = srtCode, - SrtOffset = srtOffsetMs, - SrtPath = srtPath, + Track = trackName, + Forced = forcedVal, + Burned = burnedVal, + Default = defaultSub, + SrtLang = srtLangVal, + SrtCharCode = srtCode, + SrtOffset = srtOffsetMs, + SrtPath = srtPath, SrtFileName = srtFile }; @@ -286,7 +286,7 @@ namespace Handbrake.Controls int c = 0; if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text.ToLower().Contains(".srt")) - // We have an SRT + // We have an SRT { foreach (var item in drp_subtitleTracks.Items) { @@ -388,7 +388,7 @@ namespace Handbrake.Controls lv_subList.Select(); subList[lv_subList.SelectedIndices[0]].Forced = check_forced.Checked ? "Yes" : "No"; - // Update SubList List + // Update SubList List } /// @@ -411,7 +411,7 @@ namespace Handbrake.Controls lv_subList.Select(); subList[lv_subList.SelectedIndices[0]].Burned = check_burned.Checked ? "Yes" : "No"; - // Update SubList List + // Update SubList List } /// @@ -437,7 +437,7 @@ namespace Handbrake.Controls lv_subList.Select(); subList[lv_subList.SelectedIndices[0]].Default = check_default.Checked ? "Yes" : "No"; - // Update SubList List + // Update SubList List } /// @@ -458,8 +458,8 @@ namespace Handbrake.Controls lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[6].Text = srt_offset.Value.ToString(); lv_subList.Select(); - subList[lv_subList.SelectedIndices[0]].SrtOffset = (int) srt_offset.Value; - // Update SubList List + subList[lv_subList.SelectedIndices[0]].SrtOffset = (int)srt_offset.Value; + // Update SubList List } /// @@ -479,7 +479,7 @@ namespace Handbrake.Controls lv_subList.Select(); subList[lv_subList.SelectedIndices[0]].SrtCharCode = srt_charcode.SelectedItem.ToString(); - // Update SubList List + // Update SubList List } /// @@ -499,7 +499,7 @@ namespace Handbrake.Controls lv_subList.Select(); subList[lv_subList.SelectedIndices[0]].SrtLang = srt_lang.SelectedItem.ToString(); - // Update SubList List + // Update SubList List } /* Right Click Menu */ @@ -693,18 +693,28 @@ namespace Handbrake.Controls // Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options if (Properties.Settings.Default.NativeLanguage != "Any") { - if (!Properties.Settings.Default.DubAudio) // We need to add a subtitle track if this is false. + if (Properties.Settings.Default.DubMode != 1) // We need to add a subtitle track if this is false. { - int i = 0; foreach (object item in drp_subtitleTracks.Items) { if (item.ToString().Contains(Properties.Settings.Default.NativeLanguage)) - drp_subtitleTracks.SelectedIndex = i; - - i++; + { + drp_subtitleTracks.SelectedItem = item; + BtnAddSubTrackClick(this, new EventArgs()); + } } - BtnAddSubTrackClick(this, new EventArgs()); + if (drp_subtitleTracks.SelectedIndex == 0 && Properties.Settings.Default.useClosedCaption) + { + foreach (object item in drp_subtitleTracks.Items) + { + if (item.ToString().Contains("Closed")) + { + drp_subtitleTracks.SelectedItem = item; + BtnAddSubTrackClick(this, new EventArgs()); + } + } + } } } } diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs index 3ff94a01d..55a189161 100644 --- a/win/C#/Properties/Settings.Designer.cs +++ b/win/C#/Properties/Settings.Designer.cs @@ -372,13 +372,13 @@ namespace Handbrake.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] - public bool DubAudio { + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int DubMode { get { - return ((bool)(this["DubAudio"])); + return ((int)(this["DubMode"])); } set { - this["DubAudio"] = value; + this["DubMode"] = value; } } @@ -524,5 +524,17 @@ namespace Handbrake.Properties { this["preventSleep"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool useClosedCaption { + get { + return ((bool)(this["useClosedCaption"])); + } + set { + this["useClosedCaption"] = value; + } + } } } diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings index e4a9fb5b3..d5c5582e6 100644 --- a/win/C#/Properties/Settings.settings +++ b/win/C#/Properties/Settings.settings @@ -89,8 +89,8 @@ Any - - False + + 0 @@ -128,5 +128,8 @@ False + + False + \ No newline at end of file diff --git a/win/C#/app.config b/win/C#/app.config index 40db8364b..48080a840 100644 --- a/win/C#/app.config +++ b/win/C#/app.config @@ -95,8 +95,8 @@ Any - - False + + 0 @@ -134,6 +134,9 @@ False + + False + diff --git a/win/C#/frmOptions.Designer.cs b/win/C#/frmOptions.Designer.cs index 4de8a9c74..de9bb6fb1 100644 --- a/win/C#/frmOptions.Designer.cs +++ b/win/C#/frmOptions.Designer.cs @@ -135,6 +135,8 @@ namespace Handbrake this.openFile_vlc = new System.Windows.Forms.OpenFileDialog(); this.panel1 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); + this.check_AddCCTracks = new System.Windows.Forms.CheckBox(); + this.radio_preferredAudioAndSubs = new System.Windows.Forms.RadioButton(); this.tab_options.SuspendLayout(); this.tab_general.SuspendLayout(); this.tab_picture.SuspendLayout(); @@ -531,6 +533,8 @@ namespace Handbrake // // tab_audio_sub // + this.tab_audio_sub.Controls.Add(this.radio_preferredAudioAndSubs); + this.tab_audio_sub.Controls.Add(this.check_AddCCTracks); this.tab_audio_sub.Controls.Add(this.label31); this.tab_audio_sub.Controls.Add(this.label15); this.tab_audio_sub.Controls.Add(this.radio_foreignAndSubs); @@ -1416,7 +1420,7 @@ namespace Handbrake this.panel1.Controls.Add(this.pictureBox2); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(615, 65); this.panel1.TabIndex = 62; @@ -1432,6 +1436,31 @@ namespace Handbrake this.panel2.Size = new System.Drawing.Size(615, 10); this.panel2.TabIndex = 59; // + // check_AddCCTracks + // + this.check_AddCCTracks.AutoSize = true; + this.check_AddCCTracks.Location = new System.Drawing.Point(200, 131); + this.check_AddCCTracks.Name = "check_AddCCTracks"; + 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"); + this.check_AddCCTracks.UseVisualStyleBackColor = true; + this.check_AddCCTracks.CheckedChanged += new System.EventHandler(this.check_AddCCTracks_CheckedChanged); + // + // radio_preferredAudioAndSubs + // + this.radio_preferredAudioAndSubs.AutoSize = true; + this.radio_preferredAudioAndSubs.Location = new System.Drawing.Point(200, 99); + this.radio_preferredAudioAndSubs.Name = "radio_preferredAudioAndSubs"; + this.radio_preferredAudioAndSubs.Size = new System.Drawing.Size(254, 17); + this.radio_preferredAudioAndSubs.TabIndex = 93; + this.radio_preferredAudioAndSubs.TabStop = true; + this.radio_preferredAudioAndSubs.Text = "Use Preferred Language for Audio and Subtitles"; + this.ToolTip.SetToolTip(this.radio_preferredAudioAndSubs, "Use Preferred Language for Audio and Subtitle."); + this.radio_preferredAudioAndSubs.UseVisualStyleBackColor = true; + this.radio_preferredAudioAndSubs.CheckedChanged += new System.EventHandler(this.radio_preferredAudioAndSubs_CheckedChanged); + // // frmOptions // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -1574,5 +1603,7 @@ namespace Handbrake private System.Windows.Forms.Label label11; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel2; + private System.Windows.Forms.RadioButton radio_preferredAudioAndSubs; + private System.Windows.Forms.CheckBox check_AddCCTracks; } } \ No newline at end of file diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index ac7e6924b..8885bc179 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -14,6 +14,7 @@ namespace Handbrake using HandBrake.ApplicationServices; using Handbrake.Functions; + using Handbrake.Model; using Handbrake.Properties; /// @@ -106,10 +107,18 @@ namespace Handbrake drop_preferredLang.SelectedItem = Properties.Settings.Default.NativeLanguage; - if (Properties.Settings.Default.DubAudio) - radio_dub.Checked = true; - else - radio_foreignAndSubs.Checked = true; + switch (Settings.Default.DubMode) + { + case 1: + radio_dub.Checked = true; + break; + case 2: + radio_foreignAndSubs.Checked = true; + break; + case 3: + radio_preferredAudioAndSubs.Checked = true; + break; + } // ############################# // CLI @@ -118,7 +127,7 @@ namespace Handbrake // Priority level for encodes drp_Priority.Text = Properties.Settings.Default.processPriority; - check_preventSleep.Checked = Properties.Settings.Default.preventSleep; + check_preventSleep.Checked = Properties.Settings.Default.preventSleep; // Log Verbosity Level cb_logVerboseLvl.SelectedIndex = Properties.Settings.Default.verboseLevel; @@ -302,13 +311,24 @@ namespace Handbrake private void radio_dub_CheckedChanged(object sender, EventArgs e) { if (radio_dub.Checked) - Properties.Settings.Default.DubAudio = true; + Properties.Settings.Default.DubMode = 1; } private void radio_foreignAndSubs_CheckedChanged(object sender, EventArgs e) { if (radio_foreignAndSubs.Checked) - Properties.Settings.Default.DubAudio = false; + Properties.Settings.Default.DubMode = 2; + } + + private void radio_preferredAudioAndSubs_CheckedChanged(object sender, EventArgs e) + { + if (radio_preferredAudioAndSubs.Checked) + Properties.Settings.Default.DubMode = 3; + } + + private void check_AddCCTracks_CheckedChanged(object sender, EventArgs e) + { + Settings.Default.useClosedCaption = check_AddCCTracks.Checked; } #endregion @@ -365,12 +385,12 @@ namespace Handbrake private void btn_clearLogs_Click(object sender, EventArgs e) { - DialogResult result = MessageBox.Show("Are you sure you wish to clear the log file directory?", "Clear Logs", + DialogResult result = MessageBox.Show("Are you sure you wish to clear the log file directory?", "Clear Logs", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Main.ClearLogs(); - MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK, + MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } } @@ -448,7 +468,6 @@ namespace Handbrake #endregion - private void btn_close_Click(object sender, EventArgs e) { Properties.Settings.Default.Save(); // Small hack for Vista. Seems to work fine on XP without this @@ -462,11 +481,21 @@ namespace Handbrake /// private static void UpdateApplicationServicesSettings() { - string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version); - Init.SetupSettings(versionId, Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav, - Settings.Default.growlEncode, Settings.Default.growlQueue, - Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath, - Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep); + string versionId = String.Format( + "Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version); + Init.SetupSettings( + versionId, + Program.InstanceId, + Settings.Default.CompletionOption, + Settings.Default.noDvdNav, + Settings.Default.growlEncode, + Settings.Default.growlQueue, + Settings.Default.processPriority, + Settings.Default.saveLogPath, + Settings.Default.saveLogToSpecifiedPath, + Settings.Default.saveLogWithVideo, + Settings.Default.showCliForInGuiEncodeStatus, + Settings.Default.preventSleep); } } } \ No newline at end of file diff --git a/win/C#/frmOptions.resx b/win/C#/frmOptions.resx index 8a1811c83..3a950bf99 100644 --- a/win/C#/frmOptions.resx +++ b/win/C#/frmOptions.resx @@ -120,6 +120,9 @@ 132, 18 + + 132, 18 + Use .m4v instead of .mp4 for MP4 files -- 2.40.0