Improve status message with errors in "Fix common errors" - thx Milenko :)

This commit is contained in:
Nikolaj Olsson 2019-11-24 10:00:38 +01:00
parent 94bff89ca1
commit c98a863109
8 changed files with 91 additions and 28 deletions

View File

@ -618,7 +618,9 @@ Note: Do check free disk space.</WaveFileMalformed>
<NothingToFix>Nothing to fix :)</NothingToFix>
<FixesFoundX>Fixes found: {0}</FixesFoundX>
<XFixesApplied>Fixes applied: {0}</XFixesApplied>
<NothingToFixBut>Nothing to fix but a few things could be improved - see log for details</NothingToFixBut>
<NothingFixableBut>Nothing could be fixed automatically. The subtitle contains errors - see log for details</NothingFixableBut>
<XFixedBut>{0} issue(s) fixed but the subtitle still contain errors - see log for details</XFixedBut>
<XCouldBeFixedBut>{0} issue(s) could be fixed but the subtitle will still contain errors - see log for details</XCouldBeFixedBut>
<UncheckedFixLowercaseIToUppercaseI>Unchecked "Fix alone lowercase 'i' to 'I' (English)"</UncheckedFixLowercaseIToUppercaseI>
<XIsChangedToUppercase>{0} i's changed to uppercase</XIsChangedToUppercase>
<FixFirstLetterToUppercaseAfterParagraph>Fix first letter to uppercase after paragraph</FixFirstLetterToUppercaseAfterParagraph>
@ -1514,6 +1516,7 @@ Continue?</SubtitleAppendPrompt>
<PromptInsertSubtitleOverlap>Insert subtitle at waveform position will cause overlap!
Continue anyway?</PromptInsertSubtitleOverlap>
<SubtitleContainsNegativeDurationsX>Subtitle contains negative duration in line(s): {0}</SubtitleContainsNegativeDurationsX>
<SetPlayRateX>Set play rate (speed) to {0}%</SetPlayRateX>
<ErrorLoadIdx>Cannot read/edit .idx files. Idx files are a part of an idx/sub file pair (also called VobSub), and Subtitle Edit can open the .sub file.</ErrorLoadIdx>
<ErrorLoadRar>This file seems to be a compressed .rar file. Subtitle Edit cannot open compressed files.</ErrorLoadRar>

View File

@ -814,7 +814,9 @@ namespace Nikse.SubtitleEdit.Core
NothingToFix = "Nothing to fix :)",
FixesFoundX = "Fixes found: {0}",
XFixesApplied = "Fixes applied: {0}",
NothingToFixBut = "Nothing to fix but a few things could be improved - see log for details",
NothingFixableBut = "Nothing could be fixed automatically. The subtitle contains errors - see log for details",
XFixedBut = "{0} issue(s) fixed but the subtitle still contain errors - see log for details",
XCouldBeFixedBut = "{0} issue(s) could be fixed but the subtitle will still contain errors - see log for details",
UncheckedFixLowercaseIToUppercaseI = "Unchecked \"Fix alone lowercase 'i' to 'I' (English)\"",
XIsChangedToUppercase = "{0} i's changed to uppercase",
FixFirstLetterToUppercaseAfterParagraph = "Fix first letter to uppercase after paragraph",
@ -1410,6 +1412,7 @@ namespace Nikse.SubtitleEdit.Core
PromptInsertSubtitleOverlap = "Insert subtitle at waveform position will cause overlap!" + Environment.NewLine +
Environment.NewLine +
"Continue anyway?",
SubtitleContainsNegativeDurationsX = "Subtitle contains negative duration in line(s): {0}",
SetPlayRateX = "Set play rate (speed) to {0}%",
ErrorLoadIdx = "Cannot read/edit .idx files. Idx files are a part of an idx/sub file pair (also called VobSub), and Subtitle Edit can open the .sub file.",
ErrorLoadRar = "This file seems to be a compressed .rar file. Subtitle Edit cannot open compressed files.",

View File

@ -1621,8 +1621,14 @@ namespace Nikse.SubtitleEdit.Core
case "FixCommonErrors/XFixesApplied":
language.FixCommonErrors.XFixesApplied = reader.Value;
break;
case "FixCommonErrors/NothingToFixBut":
language.FixCommonErrors.NothingToFixBut = reader.Value;
case "FixCommonErrors/NothingFixableBut":
language.FixCommonErrors.NothingFixableBut = reader.Value;
break;
case "FixCommonErrors/XFixedBut":
language.FixCommonErrors.XFixedBut = reader.Value;
break;
case "FixCommonErrors/XCouldBeFixedBut":
language.FixCommonErrors.XCouldBeFixedBut = reader.Value;
break;
case "FixCommonErrors/UncheckedFixLowercaseIToUppercaseI":
language.FixCommonErrors.UncheckedFixLowercaseIToUppercaseI = reader.Value;
@ -3220,6 +3226,9 @@ namespace Nikse.SubtitleEdit.Core
case "Main/PromptInsertSubtitleOverlap":
language.Main.PromptInsertSubtitleOverlap = reader.Value;
break;
case "Main/SubtitleContainsNegativeDurationsX":
language.Main.SubtitleContainsNegativeDurationsX = reader.Value;
break;
case "Main/SetPlayRateX":
language.Main.SetPlayRateX = reader.Value;
break;

View File

@ -686,7 +686,9 @@
public string NothingToFix { get; set; }
public string FixesFoundX { get; set; }
public string XFixesApplied { get; set; }
public string NothingToFixBut { get; set; }
public string NothingFixableBut { get; set; }
public string XFixedBut { get; set; }
public string XCouldBeFixedBut { get; set; }
public string UncheckedFixLowercaseIToUppercaseI { get; set; }
public string XIsChangedToUppercase { get; set; }
public string FixFirstLetterToUppercaseAfterParagraph { get; set; }
@ -1270,6 +1272,7 @@
public string XPercentCompleted { get; set; }
public string NextX { get; set; }
public string PromptInsertSubtitleOverlap { get; set; }
public string SubtitleContainsNegativeDurationsX { get; set; }
public string SetPlayRateX { get; set; }
public string ErrorLoadIdx { get; set; }
public string ErrorLoadRar { get; set; }

View File

@ -783,6 +783,7 @@ $HorzAlign = Center
public bool AutoSave { get; set; }
public string PreviewAssaText { get; set; }
public bool ShowProgress { get; set; }
public bool ShowNegativeDurationInfoOnSave { get; set; }
public long CurrentVideoOffsetInMs { get; set; }
public bool UseDarkTheme { get; set; }
public bool ShowBetaStuff { get; set; }
@ -2497,6 +2498,12 @@ $HorzAlign = Center
settings.General.ShowProgress = Convert.ToBoolean(subNode.InnerText.Trim());
}
subNode = node.SelectSingleNode("ShowNegativeDurationInfoOnSave");
if (subNode != null)
{
settings.General.ShowNegativeDurationInfoOnSave = Convert.ToBoolean(subNode.InnerText.Trim());
}
subNode = node.SelectSingleNode("UseDarkTheme");
if (subNode != null)
{
@ -6094,6 +6101,7 @@ $HorzAlign = Center
textWriter.WriteElementString("AutoSave", settings.General.AutoSave.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("PreviewAssaText", settings.General.PreviewAssaText);
textWriter.WriteElementString("ShowProgress", settings.General.ShowProgress.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ShowNegativeDurationInfoOnSave", settings.General.ShowNegativeDurationInfoOnSave.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("UseDarkTheme", settings.General.UseDarkTheme.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("ShowBetaStuff", settings.General.ShowBetaStuff.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("NewEmptyDefaultMs", settings.General.NewEmptyDefaultMs.ToString(CultureInfo.InvariantCulture));

View File

@ -682,7 +682,7 @@ namespace Nikse.SubtitleEdit.Forms
this.textBoxFixedIssues.Name = "textBoxFixedIssues";
this.textBoxFixedIssues.ReadOnly = true;
this.textBoxFixedIssues.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.textBoxFixedIssues.Size = new System.Drawing.Size(796, 466);
this.textBoxFixedIssues.Size = new System.Drawing.Size(796, 499);
this.textBoxFixedIssues.TabIndex = 5;
this.textBoxFixedIssues.WordWrap = false;
//

View File

@ -528,9 +528,9 @@ namespace Nikse.SubtitleEdit.Forms
public void ShowStatus(string message)
{
message = message.Replace(Environment.NewLine, " ");
if (message.Length > 83)
if (message.Length > 103)
{
message = message.Substring(0, 80) + "...";
message = message.Substring(0, 100) + "...";
}
labelStatus.Text = message;
@ -661,7 +661,7 @@ namespace Nikse.SubtitleEdit.Forms
{
Cursor = Cursors.WaitCursor;
Next();
ShowAvailableFixesStatus();
ShowAvailableFixesStatus(false);
}
Cursor = Cursors.Default;
}
@ -1368,19 +1368,7 @@ namespace Nikse.SubtitleEdit.Forms
RunSelectedActions();
FixedSubtitle = new Subtitle(Subtitle, false);
subtitleListView1.Fill(FixedSubtitle);
if (_totalFixes == 0 && _totalErrors == 0)
{
ShowStatus(_language.NothingToFix);
}
else if (_totalFixes > 0)
{
ShowStatus(string.Format(_language.XFixesApplied, _totalFixes));
}
else if (_totalErrors > 0)
{
ShowStatus(_language.NothingToFixBut);
}
ShowAvailableFixesStatus(true);
RefreshFixes();
if (listViewFixes.Items.Count == 0)
{
@ -1406,14 +1394,13 @@ namespace Nikse.SubtitleEdit.Forms
ShowStatus(_language.Analysing);
_totalFixes = 0;
RefreshFixes();
ShowAvailableFixesStatus();
ShowAvailableFixesStatus(false);
Cursor = Cursors.Default;
}
private void ShowAvailableFixesStatus()
private void ShowAvailableFixesStatus(bool applied)
{
labelStatus.ForeColor = DefaultForeColor;
if (_totalFixes == 0 && _totalErrors == 0)
{
ShowStatus(_language.NothingToFix);
@ -1424,11 +1411,27 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (_totalFixes > 0)
{
ShowStatus(string.Format(_language.FixesFoundX, _totalFixes));
if (_totalErrors > 0)
{
labelStatus.ForeColor = Color.Red;
if (applied)
{
ShowStatus(string.Format(_language.XFixedBut, _totalFixes));
}
else
{
ShowStatus(string.Format(_language.XCouldBeFixedBut, _totalFixes));
}
}
else
{
ShowStatus(string.Format(_language.XFixesApplied, _totalFixes));
}
}
else if (_totalErrors > 0)
{
ShowStatus(_language.NothingToFixBut);
labelStatus.ForeColor = Color.Red;
ShowStatus(_language.NothingFixableBut);
}
TopMost = true;

View File

@ -4702,6 +4702,40 @@ namespace Nikse.SubtitleEdit.Forms
{
ShowStatus(s);
}
if (Configuration.Settings.General.ShowNegativeDurationInfoOnSave)
{
var sb = new StringBuilder();
for (var index = 0; index < _subtitle.Paragraphs.Count; index++)
{
var p = _subtitle.Paragraphs[index];
if (p.Duration.TotalMilliseconds < 0)
{
if (sb.Length < 20)
{
if (sb.Length > 0)
{
sb.Append(", ");
}
sb.Append((index + 1).ToString(CultureInfo.InvariantCulture));
}
else
{
sb.Append("...");
break;
}
}
}
if (sb.Length > 0)
{
using (var form = new DialogDoNotShowAgain(Title, string.Format(_language.SubtitleContainsNegativeDurationsX, sb.ToString())))
{
form.ShowDialog(this);
Configuration.Settings.General.ShowNegativeDurationInfoOnSave = !form.DoNoDisplayAgain;
}
}
}
}
private void ToolStripButtonSaveAsClick(object sender, EventArgs e)