mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 05:02:36 +01:00
Improve history from "Remove text for HI" - thx ivandrofly :)
Fix #2588
This commit is contained in:
parent
d244d25304
commit
fef94a60ee
@ -5474,8 +5474,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
internal void ReloadFromSubtitle(Subtitle subtitle)
|
||||
internal void ReloadFromSubtitle(Subtitle subtitle, string messageForUndo)
|
||||
{
|
||||
MakeHistoryForUndo(messageForUndo);
|
||||
_subtitle.Paragraphs.Clear();
|
||||
_subtitle.Paragraphs.AddRange(subtitle.Paragraphs);
|
||||
_subtitleListViewIndex = -1;
|
||||
@ -5496,18 +5497,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ReloadFromSourceView();
|
||||
using (var removeTextFromHearImpaired = new FormRemoveTextForHearImpaired(this))
|
||||
{
|
||||
MakeHistoryForUndo(_language.BeforeRemovalOfTextingForHearingImpaired);
|
||||
removeTextFromHearImpaired.Initialize(_subtitle);
|
||||
if (removeTextFromHearImpaired.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
int count = removeTextFromHearImpaired.RemoveTextFromHearImpaired();
|
||||
if (count > 0)
|
||||
{
|
||||
if (count == 1)
|
||||
ShowStatus(_language.TextingForHearingImpairedRemovedOneLine);
|
||||
else
|
||||
ShowStatus(string.Format(_language.TextingForHearingImpairedRemovedXLines, count));
|
||||
}
|
||||
int count = removeTextFromHearImpaired.TotalFixes;
|
||||
if (count == 1)
|
||||
ShowStatus(_language.TextingForHearingImpairedRemovedOneLine);
|
||||
else if (count >= 1)
|
||||
ShowStatus(string.Format(_language.TextingForHearingImpairedRemovedXLines, count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public sealed partial class FormRemoveTextForHearImpaired : PositionAndSizeForm
|
||||
{
|
||||
public Subtitle Subtitle;
|
||||
public int TotalFixes { get; private set; }
|
||||
private readonly LanguageStructure.RemoveTextFromHearImpaired _language;
|
||||
private readonly RemoveTextForHI _removeTextForHiLib;
|
||||
private Dictionary<Paragraph, string> _fixes;
|
||||
private int _removeCount;
|
||||
private readonly Main _mainForm;
|
||||
private readonly List<Paragraph> _unchecked = new List<Paragraph>();
|
||||
|
||||
@ -149,21 +149,34 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void ButtonOkClick(object sender, EventArgs e)
|
||||
{
|
||||
if (Subtitle != null)
|
||||
{
|
||||
RemoveTextFromHearImpaired();
|
||||
Subtitle.Renumber();
|
||||
if (_mainForm != null)
|
||||
{
|
||||
_mainForm.ReloadFromSubtitle(Subtitle);
|
||||
}
|
||||
}
|
||||
ApplyChanges();
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void buttonApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
ApplyChanges();
|
||||
GeneratePreview();
|
||||
}
|
||||
|
||||
private void ApplyChanges()
|
||||
{
|
||||
if (Subtitle == null)
|
||||
return;
|
||||
int fixes = RemoveTextFromHearImpaired();
|
||||
Subtitle.Renumber();
|
||||
if (_mainForm != null && fixes > 0)
|
||||
{
|
||||
TotalFixes += fixes;
|
||||
_mainForm.ReloadFromSubtitle(new Subtitle(Subtitle), Configuration.Settings.Language.Main.BeforeRemovalOfTextingForHearingImpaired);
|
||||
}
|
||||
}
|
||||
|
||||
public int RemoveTextFromHearImpaired()
|
||||
{
|
||||
_unchecked.Clear();
|
||||
int fixes = 0;
|
||||
|
||||
for (int i = listViewFixes.Items.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var item = listViewFixes.Items[i];
|
||||
@ -179,14 +192,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
p.Text = newText;
|
||||
}
|
||||
_removeCount++;
|
||||
fixes++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_unchecked.Add(p);
|
||||
}
|
||||
}
|
||||
return _removeCount;
|
||||
return fixes;
|
||||
}
|
||||
|
||||
private void CheckBoxRemoveTextBetweenCheckedChanged(object sender, EventArgs e)
|
||||
@ -310,19 +323,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonApply_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Subtitle == null)
|
||||
return;
|
||||
RemoveTextFromHearImpaired();
|
||||
Subtitle.Renumber();
|
||||
if (_mainForm != null)
|
||||
{
|
||||
_mainForm.ReloadFromSubtitle(Subtitle);
|
||||
}
|
||||
GeneratePreview();
|
||||
}
|
||||
|
||||
private void listViewFixes_ItemChecked(object sender, ItemCheckedEventArgs e)
|
||||
{
|
||||
var p = e.Item.Tag as Paragraph;
|
||||
|
Loading…
Reference in New Issue
Block a user