Added shortcut to merge two dialog lines - thx Carles :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1004 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-02-26 16:21:03 +00:00
parent 1945da1111
commit 8d9d01cea9
7 changed files with 94 additions and 40 deletions

View File

@ -1709,7 +1709,7 @@
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
this.changeCasingForSelectedLinesToolStripMenuItem});
this.contextMenuStripListview.Name = "contextMenuStripListview";
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 628);
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 650);
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
//
// setStylesForSelectedLinesToolStripMenuItem

View File

@ -118,6 +118,7 @@ namespace Nikse.SubtitleEdit.Forms
Keys _mainAdjustSelected100MsBack = Keys.None;
Keys _mainInsertAfter = Keys.None;
Keys _mainInsertBefore = Keys.None;
Keys _mainMergeDialogue = Keys.None;
Keys _mainGoToNext = Keys.None;
Keys _mainGoToPrevious = Keys.None;
Keys _mainListViewToggleDashes = Keys.None;
@ -1213,7 +1214,6 @@ namespace Nikse.SubtitleEdit.Forms
labelStartTime.Text = _languageGeneral.StartTime;
labelText.Text = _languageGeneral.Text;
toolStripLabelFrameRate.Text = _languageGeneral.FrameRate;
// buttonUndoListViewChanges.Text = _language.Controls.UndoChangesInEditPanel;
buttonPrevious.Text = _language.Controls.Previous;
buttonNext.Text = _language.Controls.Next;
buttonAutoBreak.Text = _language.Controls.AutoBreak;
@ -3675,8 +3675,9 @@ namespace Nikse.SubtitleEdit.Forms
_change = true;
_converted = true;
SetTitle();
if (googleTranslate.ScreenScrapingEncoding != null)
SetEncoding(googleTranslate.ScreenScrapingEncoding);
//if (googleTranslate.ScreenScrapingEncoding != null)
// SetEncoding(googleTranslate.ScreenScrapingEncoding);
SetEncoding(Encoding.UTF8);
}
_formPositionsAndSizes.SavePositionAndSize(googleTranslate);
}
@ -4498,7 +4499,7 @@ namespace Nikse.SubtitleEdit.Forms
else if (prev != null)
{
newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds;
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + 1200;
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + 2000;
if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds)
@ -4506,7 +4507,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (next != null)
{
newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1200;
newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2001;
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
}
else
@ -4575,7 +4576,7 @@ namespace Nikse.SubtitleEdit.Forms
addMilliseconds = 1;
newParagraph.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + addMilliseconds;
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + 1200;
newParagraph.EndTime.TotalMilliseconds = newParagraph.StartTime.TotalMilliseconds + 2000;
if (next != null && newParagraph.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
if (newParagraph.StartTime.TotalMilliseconds > newParagraph.EndTime.TotalMilliseconds)
@ -4583,7 +4584,7 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (next != null)
{
newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1200;
newParagraph.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 2000;
newParagraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
}
else
@ -4622,8 +4623,6 @@ namespace Nikse.SubtitleEdit.Forms
private void SubtitleListView1SelectedIndexChange()
{
//if (buttonUndoListViewChanges.Visible)
// buttonUndoListViewChanges.Enabled = false;
StopAutoDuration();
ShowLineInformationListView();
if (_subtitle.Paragraphs.Count > 0)
@ -5065,6 +5064,28 @@ namespace Nikse.SubtitleEdit.Forms
{
currentParagraph.Text = Utilities.AutoBreakLine(lines[0]);
newParagraph.Text = Utilities.AutoBreakLine(lines[1]);
if (lines[0].Length > 2 && lines[0][0] == '-' && lines[0][1] != '-' &&
lines[1].Length > 2 && lines[1][0] == '-' && lines[1][1] != '-')
{
currentParagraph.Text = currentParagraph.Text.TrimStart('-').Trim();
newParagraph.Text = newParagraph.Text.TrimStart('-').Trim();
}
}
else if (lines.Length == 2 && (lines[0].EndsWith(".</i>") || lines[0].EndsWith("!</i>") || lines[0].EndsWith("?</i>")))
{
currentParagraph.Text = Utilities.AutoBreakLine(lines[0]);
newParagraph.Text = Utilities.AutoBreakLine(lines[1]);
if (lines[0].Length > 5 && lines[0].StartsWith("<i>-") && lines[0][4] != '-' &&
lines[1].Length > 5 && lines[1].StartsWith("<i>-") && lines[1][4] != '-')
{
currentParagraph.Text = currentParagraph.Text.Remove(3, 1);
if (currentParagraph.Text[3] == ' ')
currentParagraph.Text = currentParagraph.Text.Remove(3, 1);
newParagraph.Text = newParagraph.Text.Remove(3, 1);
if (newParagraph.Text[3] == ' ')
newParagraph.Text = newParagraph.Text.Remove(3, 1);
}
}
else
{
@ -5252,12 +5273,12 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void MergeSelectedLines()
private void MergeSelectedLines(bool insertDash)
{
if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 1)
{
StringBuilder sb = new StringBuilder();
List<int> deleteIndices = new List<int>();
var sb = new StringBuilder();
var deleteIndices = new List<int>();
bool first = true;
int firstIndex = 0;
foreach (int index in SubtitleListview1.SelectedIndices)
@ -5266,7 +5287,20 @@ namespace Nikse.SubtitleEdit.Forms
firstIndex = index;
else
deleteIndices.Add(index);
sb.AppendLine(_subtitle.Paragraphs[index].Text);
if (insertDash)
{
string s = Utilities.UnbreakLine(_subtitle.Paragraphs[index].Text);
if (s.StartsWith("-") || s.StartsWith("<i>-"))
sb.AppendLine(s);
else if (s.StartsWith("<i>"))
sb.AppendLine(s.Insert(3, "- "));
else
sb.AppendLine("- " + s);
}
else
{
sb.AppendLine(_subtitle.Paragraphs[index].Text);
}
first = false;
}
@ -5297,13 +5331,28 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph original = Utilities.GetOriginalParagraph(firstIndex, currentParagraph, _subtitleAlternate.Paragraphs);
if (original != null)
{
StringBuilder originalTexts = new StringBuilder();
var originalTexts = new StringBuilder();
originalTexts.Append(original.Text + " ");
for (int i = 0; i < deleteIndices.Count; i++)
{
Paragraph originalNext = Utilities.GetOriginalParagraph(deleteIndices[i], _subtitle.Paragraphs[deleteIndices[i]], _subtitleAlternate.Paragraphs);
if (originalNext != null)
originalTexts.Append(originalNext.Text + " ");
{
if (insertDash)
{
string s = Utilities.UnbreakLine(originalNext.Text);
if (s.StartsWith("-") || s.StartsWith("<i>-"))
originalTexts.AppendLine(s);
else if (s.StartsWith("<i>"))
originalTexts.AppendLine(s.Insert(3, "- "));
else
originalTexts.AppendLine("- " + s);
}
else
{
originalTexts.Append(originalNext.Text + " ");
}
}
}
for (int i = deleteIndices.Count - 1; i >= 0; i--)
{
@ -5364,7 +5413,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (SubtitleListview1.SelectedItems.Count > 2)
{
MergeSelectedLines();
MergeSelectedLines(false);
return;
}
@ -5555,23 +5604,6 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void ButtonUndoListViewChangesClick(object sender, EventArgs e)
{
if (_subtitleListViewIndex >= 0 && _oldSelectedParagraph != null)
{
var p = new Paragraph(_oldSelectedParagraph);
_subtitle.Paragraphs[_subtitleListViewIndex] = p;
SubtitleListview1.SetText(_subtitleListViewIndex, p.Text);
SubtitleListview1.SetStartTime(_subtitleListViewIndex, p);
SubtitleListview1.SetDuration(_subtitleListViewIndex, p);
InitializeListViewEditBox(p);
// buttonUndoListViewChanges.Enabled = false;
}
}
private void InitializeListViewEditBoxAlternate(Paragraph p, int firstSelectedIndex)
{
if (_subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
@ -7074,6 +7106,12 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
textBoxListViewText.Focus();
}
else if (_mainMergeDialogue == e.KeyData && inListView)
{
MergeDialogues();
e.SuppressKeyPress = true;
textBoxListViewText.Focus();
}
else if (_mainListViewToggleDashes == e.KeyData && inListView)
{
ToggleDashes();
@ -7181,7 +7219,7 @@ namespace Nikse.SubtitleEdit.Forms
if (SubtitleListview1.SelectedItems.Count == 2)
MergeAfterToolStripMenuItemClick(null, null);
else
MergeSelectedLines();
MergeSelectedLines(false);
}
}
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.K)
@ -7192,7 +7230,7 @@ namespace Nikse.SubtitleEdit.Forms
if (SubtitleListview1.SelectedItems.Count == 2)
MergeAfterToolStripMenuItemClick(null, null);
else
MergeSelectedLines();
MergeSelectedLines(false);
}
}
else if (e.Modifiers == Keys.Control && e.KeyCode == Keys.U)
@ -7602,6 +7640,12 @@ namespace Nikse.SubtitleEdit.Forms
// put new entries above tabs
}
private void MergeDialogues()
{
if (SubtitleListview1.SelectedItems.Count == 2)
MergeSelectedLines(true);
}
private void ToggleDashes()
{
int index = FirstSelectedIndex;
@ -9872,6 +9916,7 @@ namespace Nikse.SubtitleEdit.Forms
_mainAdjustSelected100MsBack = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack);
_mainInsertAfter = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainInsertAfter);
_mainInsertBefore = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainInsertBefore);
_mainMergeDialogue = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainMergeDialogue);
_mainGoToNext = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainGoToNext);
_mainGoToPrevious = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainGoToPrevious);
_waveformVerticalZoom = Utilities.GetKeys(Configuration.Settings.Shortcuts.WaveformVerticalZoom);

View File

@ -574,9 +574,6 @@
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>208, 56</value>
</metadata>
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
@ -684,7 +681,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
CAAAAk1TRnQBSQFMAgEBAgEAAWABDwFgAQ8BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
CAAAAk1TRnQBSQFMAgEBAgEAAXABDwFwAQ8BEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@ -483,6 +483,8 @@ namespace Nikse.SubtitleEdit.Forms
ListViewNode.Nodes.Add(Configuration.Settings.Language.General.Italic + GetShortcutText(Configuration.Settings.Shortcuts.MainListViewItalic));
ListViewNode.Nodes.Add(Configuration.Settings.Language.Main.Menu.ContextMenu.InsertAfter + GetShortcutText(Configuration.Settings.Shortcuts.MainInsertAfter));
ListViewNode.Nodes.Add(Configuration.Settings.Language.Main.Menu.ContextMenu.InsertBefore + GetShortcutText(Configuration.Settings.Shortcuts.MainInsertBefore));
if (!string.IsNullOrEmpty(Configuration.Settings.Language.Settings.MergeDialogue)) // TODO: Remove in SE 3.3
ListViewNode.Nodes.Add(Configuration.Settings.Language.Settings.MergeDialogue + GetShortcutText(Configuration.Settings.Shortcuts.MainMergeDialogue));
if (!string.IsNullOrEmpty(Configuration.Settings.Language.Settings.GoToNext)) // TODO: Remove in SE 3.3
ListViewNode.Nodes.Add(Configuration.Settings.Language.Settings.GoToNext + GetShortcutText(Configuration.Settings.Shortcuts.MainGoToNext));
if (!string.IsNullOrEmpty(Configuration.Settings.Language.Settings.GoToPrevious)) // TODO: Remove in SE 3.3
@ -962,6 +964,8 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Shortcuts.MainInsertAfter = GetShortcut(node.Text);
else if (text == Configuration.Settings.Language.Main.Menu.ContextMenu.InsertBefore.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainInsertBefore = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.MergeDialogue != null && text == Configuration.Settings.Language.Settings.MergeDialogue.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainMergeDialogue = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.GoToNext != null && text == Configuration.Settings.Language.Settings.GoToNext.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainGoToNext = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.GoToPrevious != null && text == Configuration.Settings.Language.Settings.GoToPrevious.Replace("&", string.Empty))

View File

@ -1279,6 +1279,7 @@ can edit in same subtitle file (collaboration)",
AdjustSelected100MsForward = "Move selected lines 100 ms forward",
AdjustSelected100MsBack = "Move selected lines 100 ms back",
AdjustSetStartTimeOnly = "Set start time, keep end time",
MergeDialogue = "Merge dialogue (insert dashes)",
GoToNext = "Go to next line",
GoToPrevious = "Go to previous line",
ToggleDialogueDashes = "Toogle dialogue dashes",

View File

@ -1208,6 +1208,7 @@
public string AdjustSelected100MsForward { get; set; }
public string AdjustSelected100MsBack { get; set; }
public string AdjustSetStartTimeOnly { get; set; }
public string MergeDialogue { get; set; }
public string GoToNext { get; set; }
public string GoToPrevious { get; set; }
public string ToggleDialogueDashes { get; set; }

View File

@ -497,6 +497,7 @@ namespace Nikse.SubtitleEdit.Logic
public string MainAdjustSelected100MsBack { get; set; }
public string MainInsertAfter { get; set; }
public string MainInsertBefore { get; set; }
public string MainMergeDialogue { get; set; }
public string MainGoToNext { get; set; }
public string MainGoToPrevious { get; set; }
public string WaveformVerticalZoom { get; set; }
@ -545,6 +546,7 @@ namespace Nikse.SubtitleEdit.Logic
MainAdjustSelected100MsBack = string.Empty;
MainInsertAfter = "Alt+Ins";
MainInsertBefore = "Control+Shift+Ins";
MainMergeDialogue = string.Empty;
WaveformVerticalZoom = string.Empty;
WaveformPlaySelection = string.Empty;
WaveformSearchSilenceForward = string.Empty;
@ -1399,6 +1401,9 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("MainInsertBefore");
if (subNode != null)
settings.Shortcuts.MainInsertBefore = subNode.InnerText;
subNode = node.SelectSingleNode("MainMergeDialogue");
if (subNode != null)
settings.Shortcuts.MainMergeDialogue = subNode.InnerText;
subNode = node.SelectSingleNode("MainGoToNext");
if (subNode != null)
settings.Shortcuts.MainGoToNext = subNode.InnerText;
@ -1757,6 +1762,7 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("MainAdjustSelected100MsBack", settings.Shortcuts.MainAdjustSelected100MsBack);
textWriter.WriteElementString("MainInsertAfter", settings.Shortcuts.MainInsertAfter);
textWriter.WriteElementString("MainInsertBefore", settings.Shortcuts.MainInsertBefore);
textWriter.WriteElementString("MainMergeDialogue", settings.Shortcuts.MainMergeDialogue);
textWriter.WriteElementString("MainGoToNext", settings.Shortcuts.MainGoToNext);
textWriter.WriteElementString("MainGoToPrevious", settings.Shortcuts.MainGoToPrevious);
textWriter.WriteElementString("WaveformVerticalZoom", settings.Shortcuts.WaveformVerticalZoom);