mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-28 23:12:34 +01:00
Add options to only beautify time codes of selected lines
This commit is contained in:
parent
822caa7de5
commit
20a251bb3b
@ -276,7 +276,7 @@ namespace Nikse.SubtitleEdit.Forms.BeautifyTimeCodes
|
||||
buttonOK.Enabled = false;
|
||||
|
||||
// Actual processing
|
||||
FixedSubtitle = new Subtitle(_subtitle);
|
||||
FixedSubtitle = new Subtitle(_subtitle, false);
|
||||
|
||||
TimeCodesBeautifier timeCodesBeautifier = new TimeCodesBeautifier(
|
||||
FixedSubtitle,
|
||||
|
10
src/ui/Forms/Main.Designer.cs
generated
10
src/ui/Forms/Main.Designer.cs
generated
@ -344,6 +344,7 @@
|
||||
this.changeCasingForSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fixCommonErrorsInSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.visualSyncSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.showSelectedLinesEarlierlaterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemTranslateSelected = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.genericTranslateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -3142,6 +3143,7 @@
|
||||
this.changeCasingForSelectedLinesToolStripMenuItem,
|
||||
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
|
||||
this.visualSyncSelectedLinesToolStripMenuItem,
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem,
|
||||
this.showSelectedLinesEarlierlaterToolStripMenuItem,
|
||||
this.toolStripMenuItemTranslateSelected,
|
||||
this.toolStripMenuItemUnbreakLines,
|
||||
@ -3181,6 +3183,13 @@
|
||||
this.visualSyncSelectedLinesToolStripMenuItem.Text = "Visual sync selected lines...";
|
||||
this.visualSyncSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.VisualSyncSelectedLinesToolStripMenuItemClick);
|
||||
//
|
||||
// beautifyTimeCodesOfSelectedLinesToolStripMenuItem
|
||||
//
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem.Name = "beautifyTimeCodesOfSelectedLinesToolStripMenuItem";
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem.Size = new System.Drawing.Size(275, 22);
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem.Text = "Beautify time codes of selected lines...";
|
||||
this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem.Click += new System.EventHandler(this.beautifyTimeCodesOfSelectedLinesToolStripMenuItem_Click);
|
||||
//
|
||||
// showSelectedLinesEarlierlaterToolStripMenuItem
|
||||
//
|
||||
this.showSelectedLinesEarlierlaterToolStripMenuItem.Name = "showSelectedLinesEarlierlaterToolStripMenuItem";
|
||||
@ -6378,5 +6387,6 @@
|
||||
private Nikse.SubtitleEdit.Controls.NikseUpDown numericUpDownLayer;
|
||||
private System.Windows.Forms.Label labelLayer;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemWebVttStyle;
|
||||
private System.Windows.Forms.ToolStripMenuItem beautifyTimeCodesOfSelectedLinesToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1913,6 +1913,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
karaokeEffectToolStripMenuItem.Text = _language.Menu.ContextMenu.KaraokeEffect;
|
||||
showSelectedLinesEarlierlaterToolStripMenuItem.Text = _language.Menu.ContextMenu.ShowSelectedLinesEarlierLater;
|
||||
visualSyncSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.VisualSyncSelectedLines;
|
||||
beautifyTimeCodesOfSelectedLinesToolStripMenuItem.Text = _language.Menu.ContextMenu.BeautifyTimeCodesOfSelectedLines;
|
||||
toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = _language.Menu.ContextMenu.GoogleAndMicrosoftTranslateSelectedLine;
|
||||
toolStripMenuItemSelectedLines.Text = _language.Menu.ContextMenu.SelectedLines;
|
||||
|
||||
@ -34482,40 +34483,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
private void toolStripMenuItemBeautifyTimeCodes_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsSubtitleLoaded)
|
||||
{
|
||||
DisplaySubtitleNotLoadedMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
using (var form = new BeautifyTimeCodes.BeautifyTimeCodes(_subtitle, _videoInfo, _videoFileName, audioVisualizer.ShotChanges))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
|
||||
if (form.ShotChangesInSeconds.Count > 0)
|
||||
{
|
||||
audioVisualizer.ShotChanges = form.ShotChangesInSeconds;
|
||||
}
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
int index = FirstSelectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeBeautifyTimeCodes);
|
||||
SaveSubtitleListviewIndices();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
_subtitle.Paragraphs.AddRange(form.FixedSubtitle.Paragraphs);
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
|
||||
RestoreSubtitleListviewIndices();
|
||||
}
|
||||
}
|
||||
{
|
||||
BeautifyTimeCodes(SubtitleListview1.GetSelectedIndices().Length > 1);
|
||||
}
|
||||
|
||||
private void toolStripButtonBeautifyTimeCodes_Click(object sender, EventArgs e)
|
||||
@ -35442,5 +35411,101 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
RefreshSelectedParagraph();
|
||||
}
|
||||
|
||||
private void beautifyTimeCodesOfSelectedLinesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
BeautifyTimeCodes(true);
|
||||
}
|
||||
|
||||
private void BeautifyTimeCodes(bool onlySelectedLines)
|
||||
{
|
||||
if (!IsSubtitleLoaded)
|
||||
{
|
||||
DisplaySubtitleNotLoadedMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (onlySelectedLines)
|
||||
{
|
||||
var selectedIndices = SubtitleListview1.GetSelectedIndices();
|
||||
var selectedLines = new Subtitle();
|
||||
foreach (int index in selectedIndices)
|
||||
{
|
||||
selectedLines.Paragraphs.Add(_subtitle.Paragraphs[index]);
|
||||
}
|
||||
|
||||
using (var form = new BeautifyTimeCodes.BeautifyTimeCodes(selectedLines, _videoInfo, _videoFileName, audioVisualizer.ShotChanges))
|
||||
{
|
||||
form.Text = string.Format(LanguageSettings.Current.BeautifyTimeCodes.TitleSelectedLines, selectedIndices.Length);
|
||||
|
||||
var result = form.ShowDialog(this);
|
||||
|
||||
if (form.ShotChangesInSeconds.Count > 0)
|
||||
{
|
||||
audioVisualizer.ShotChanges = form.ShotChangesInSeconds;
|
||||
}
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
int index = FirstSelectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeBeautifyTimeCodesSelectedLines);
|
||||
SaveSubtitleListviewIndices();
|
||||
|
||||
foreach (int idx in selectedIndices)
|
||||
{
|
||||
var pOld = _subtitle.Paragraphs[idx];
|
||||
var p = form.FixedSubtitle.GetParagraphOrDefaultById(pOld.Id);
|
||||
if (p != null)
|
||||
{
|
||||
_subtitle.Paragraphs[idx] = p;
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
|
||||
RestoreSubtitleListviewIndices();
|
||||
|
||||
ShowStatus(_language.BeautifiedTimeCodesSelectedLines);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var form = new BeautifyTimeCodes.BeautifyTimeCodes(_subtitle, _videoInfo, _videoFileName, audioVisualizer.ShotChanges))
|
||||
{
|
||||
var result = form.ShowDialog(this);
|
||||
|
||||
if (form.ShotChangesInSeconds.Count > 0)
|
||||
{
|
||||
audioVisualizer.ShotChanges = form.ShotChangesInSeconds;
|
||||
}
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
int index = FirstSelectedIndex;
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeBeautifyTimeCodes);
|
||||
SaveSubtitleListviewIndices();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
_subtitle.Paragraphs.AddRange(form.FixedSubtitle.Paragraphs);
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleOriginal);
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(index, true);
|
||||
RestoreSubtitleListviewIndices();
|
||||
|
||||
ShowStatus(_language.BeautifiedTimeCodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -539,6 +539,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
BeautifyTimeCodes = new LanguageStructure.BeautifyTimeCodes
|
||||
{
|
||||
Title = "Beautify time codes",
|
||||
TitleSelectedLines = "Beautify time codes ({0} selected lines)",
|
||||
GroupTimeCodes = "Time codes",
|
||||
AlignTimeCodes = "Align time codes to frame time codes",
|
||||
ExtractExactTimeCodes = "Use ffprobe to extract exact frame time codes",
|
||||
@ -1615,7 +1616,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
BeforeRenumbering = "Before renumbering",
|
||||
RenumberedStartingFromX = "Renumbered starting from: {0}",
|
||||
BeforeBeautifyTimeCodes = "Before beautifying time codes",
|
||||
BeforeBeautifyTimeCodesSelectedLines = "Before beautifying time codes of selected lines",
|
||||
BeautifiedTimeCodes = "Time codes beautified",
|
||||
BeautifiedTimeCodesSelectedLines = "Time codes of selected lines beautified",
|
||||
BeforeRemovalOfTextingForHearingImpaired = "Before removal of texting for hearing impaired",
|
||||
TextingForHearingImpairedRemovedOneLine = "Texting for hearing impaired removed: One line",
|
||||
TextingForHearingImpairedRemovedXLines = "Texting for hearing impaired removed: {0} lines",
|
||||
@ -2128,6 +2131,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
KaraokeEffect = "Karaoke effect...",
|
||||
ShowSelectedLinesEarlierLater = "Show selected lines earlier/later...",
|
||||
VisualSyncSelectedLines = "Visual sync selected lines...",
|
||||
BeautifyTimeCodesOfSelectedLines = "Beautify time codes of selected lines...",
|
||||
GoogleAndMicrosoftTranslateSelectedLine = "Google/Microsoft translate original line",
|
||||
SelectedLines = "Selected lines",
|
||||
TranslateSelectedLines = "Translate selected lines...",
|
||||
|
@ -392,6 +392,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public class BeautifyTimeCodes
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string TitleSelectedLines { get; set; }
|
||||
public string GroupTimeCodes { get; set; }
|
||||
public string AlignTimeCodes { get; set; }
|
||||
public string ExtractExactTimeCodes { get; set; }
|
||||
@ -1439,7 +1440,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string BeforeRenumbering { get; set; }
|
||||
public string RenumberedStartingFromX { get; set; }
|
||||
public string BeforeBeautifyTimeCodes { get; set; }
|
||||
public string BeforeBeautifyTimeCodesSelectedLines { get; set; }
|
||||
public string BeautifiedTimeCodes { get; set; }
|
||||
public string BeautifiedTimeCodesSelectedLines { get; set; }
|
||||
public string BeforeRemovalOfTextingForHearingImpaired { get; set; }
|
||||
public string TextingForHearingImpairedRemovedOneLine { get; set; }
|
||||
public string TextingForHearingImpairedRemovedXLines { get; set; }
|
||||
@ -1941,6 +1944,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public string KaraokeEffect { get; set; }
|
||||
public string ShowSelectedLinesEarlierLater { get; set; }
|
||||
public string VisualSyncSelectedLines { get; set; }
|
||||
public string BeautifyTimeCodesOfSelectedLines { get; set; }
|
||||
public string GoogleAndMicrosoftTranslateSelectedLine { get; set; }
|
||||
public string SelectedLines { get; set; }
|
||||
public string TranslateSelectedLines { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user