From 284592b1e91c392bcb80e249a62cd031afd42ff6 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Sat, 16 Dec 2023 12:00:46 +0100 Subject: [PATCH] Improve err handling a little --- Changelog.txt | 4 +- Dictionaries/fr_NoBreakAfterList.xml | 7 +++ .../BeautifyTimeCodesProfileSimple.cs | 49 ++++++++++++++----- 3 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 Dictionaries/fr_NoBreakAfterList.xml diff --git a/Changelog.txt b/Changelog.txt index 6206cccd1..526f5aad7 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3,7 +3,7 @@ 4.0.3 (xth December 2023) BETA * NEW: - * Add ".opus" audio file extension - thx vivadavid + * Add ".opus" / ".adts" audio file extensions - thx vivadavid/Lyubomir71 * Add two TSV subtitle formats - thx Purfview * Add Arabic translation - thx Yahya * Add new json subtitle format - thx Lucretia @@ -27,6 +27,8 @@ * Re-add Whisper Const-me large model v2 * Audio-to-text: Improve error msg if no write access to video source folder * Add delay in seconds to translate via ChatGPT + * Toggle music symbols, now toggles via first text - thx Leon + * Use source video folder when saving hard-sub video - thx Leon * FIXED: * Fix for BDSUP cmd line convert - thx Jack1789 * Do not count HTML tags in SCC in save/load - thx cs127 diff --git a/Dictionaries/fr_NoBreakAfterList.xml b/Dictionaries/fr_NoBreakAfterList.xml new file mode 100644 index 000000000..3baa9ca20 --- /dev/null +++ b/Dictionaries/fr_NoBreakAfterList.xml @@ -0,0 +1,7 @@ + + Dr + Dr. + Mr. + Mrs. + Ms. + \ No newline at end of file diff --git a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs index 7a9032c24..e9284ffcd 100644 --- a/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs +++ b/src/ui/Forms/BeautifyTimeCodes/BeautifyTimeCodesProfileSimple.cs @@ -1,9 +1,9 @@ using Nikse.SubtitleEdit.Core.Common; +using Nikse.SubtitleEdit.Core.Forms; +using Nikse.SubtitleEdit.Core.SubtitleFormats; using Nikse.SubtitleEdit.Logic; using System; using System.Windows.Forms; -using Nikse.SubtitleEdit.Core.Forms; -using Nikse.SubtitleEdit.Core.SubtitleFormats; namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes { @@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes UiUtil.PreInitialize(this); InitializeComponent(); UiUtil.FixFonts(this); - + var language = LanguageSettings.Current.BeautifyTimeCodesProfile; Text = language.CreateSimpleTitle; labelInstructions.Text = language.CreateSimpleInstruction; @@ -84,9 +84,18 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes DialogResult = DialogResult.None; return; } - + // Save settings - var gap = Convert.ToInt32(numericUpDownGap.Value); + int gap; + try + { + gap = Convert.ToInt32(numericUpDownGap.Value); + } + catch (Exception exception) + { + throw new Exception($"Unable to set gap from numericUpDownGap.Value to Int32: numericUpDownGap.Value = '{numericUpDownGap.Value}'", exception); + } + var inCuesGap = comboBoxInCues.SelectedIndex; var outCuesGap = comboBoxOutCues.SelectedIndex; if (comboBoxOutCues.SelectedIndex == comboBoxOutCues.Items.Count - 1) @@ -94,10 +103,28 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes outCuesGap = gap; } - var redZone = Convert.ToInt32(numericUpDownOffset.Value); - var greenZone = Convert.ToInt32(numericUpDownSafeZone.Value); + int redZone; + try + { + redZone = Convert.ToInt32(numericUpDownOffset.Value); + } + catch (Exception exception) + { + throw new Exception($"Unable to set redZone from numericUpDownOffset.Value to Int32: numericUpDownOffset.Value = '{numericUpDownOffset.Value}'", exception); + } - Configuration.Settings.BeautifyTimeCodes.Profile.Gap = Convert.ToInt32(numericUpDownGap.Value); + int greenZone; + try + { + greenZone = Convert.ToInt32(numericUpDownSafeZone.Value); + } + catch (Exception exception) + { + throw new Exception($"Unable to set greenZone from numericUpDownSafeZone.Value to Int32: numericUpDownSafeZone.Value = '{numericUpDownSafeZone.Value}'", exception); + } + + + Configuration.Settings.BeautifyTimeCodes.Profile.Gap = gap; Configuration.Settings.BeautifyTimeCodes.Profile.InCuesGap = inCuesGap; Configuration.Settings.BeautifyTimeCodes.Profile.InCuesLeftGreenZone = greenZone; @@ -132,7 +159,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs); - throw; + throw new Exception($"Unable to calculate treadConnectedMs from gap '{gap}' and frame rate {_frameRate}", exception); } try @@ -145,7 +172,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: Gap is " + gap); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: FrameRate is " + _frameRate); SeLogger.Error("BeautifyTimeCodesProfileSimple.buttonOK_Click: treadConnectedMs is " + treadConnectedMs); - throw; + throw new Exception($"Unable to set ConnectedSubtitlesTreatConnected from treadConnectedMs '{treadConnectedMs}'", exception); } Configuration.Settings.BeautifyTimeCodes.Profile.ChainingGeneralUseZones = false; @@ -175,7 +202,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes private void numericUpDownGap_ValueChanged(object sender, EventArgs e) { - int gapFrames = Convert.ToInt32(numericUpDownGap.Value); + var gapFrames = Convert.ToInt32(numericUpDownGap.Value); double gapMs = SubtitleFormat.FramesToMilliseconds(gapFrames, _frameRate); labelGapHint.Text = string.Format(LanguageSettings.Current.BeautifyTimeCodesProfile.GapInMsFormat, Math.Round(gapMs), Math.Round(_frameRate, 3));