Added two new shortcuts for adjusting end time (and offsetting the rest) - thx Leon :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2415 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2014-01-23 16:17:28 +00:00
parent e19ca48df7
commit a0c084f8c8
5 changed files with 110 additions and 3 deletions

View File

@ -132,6 +132,8 @@ namespace Nikse.SubtitleEdit.Forms
Keys _mainCreateStartDownEndUp = Keys.None;
Keys _mainCreateSetEndAddNewAndGoToNew = Keys.None;
Keys _mainAdjustSetStartAndOffsetTheRest = Keys.None;
Keys _mainAdjustSetEndAndOffsetTheRest = Keys.None;
Keys _mainAdjustSetEndAndOffsetTheRestAndGoToNext = Keys.None;
Keys _mainAdjustSetEndAndGotoNext = Keys.None;
Keys _mainAdjustInsertViaEndAutoStartAndGoToNext = Keys.None;
Keys _mainAdjustSetStartAutoDurationAndGoToNext = Keys.None;
@ -10668,12 +10670,22 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (mediaPlayer.VideoPlayer != null)
{
if (_mainAdjustSetStartAndOffsetTheRest == e.KeyData) // ((e.Modifiers == Keys.Control && e.KeyCode == Keys.Space))
if (_mainAdjustSetStartAndOffsetTheRest == e.KeyData)
{
ButtonSetStartAndOffsetRestClick(null, null);
e.SuppressKeyPress = true;
}
else if (_mainAdjustSetEndAndGotoNext == e.KeyData) // e.Modifiers == Keys.Shift && e.KeyCode == Keys.Space)
else if (_mainAdjustSetEndAndOffsetTheRest == e.KeyData)
{
SetEndAndOffsetTheRest(false);
e.SuppressKeyPress = true;
}
else if (_mainAdjustSetEndAndOffsetTheRestAndGoToNext == e.KeyData)
{
SetEndAndOffsetTheRest(true);
e.SuppressKeyPress = true;
}
else if (_mainAdjustSetEndAndGotoNext == e.KeyData)
{
ButtonSetEndAndGoToNextClick(null, null);
e.SuppressKeyPress = true;
@ -10848,6 +10860,73 @@ namespace Nikse.SubtitleEdit.Forms
// put new entries above tabs
}
private void SetEndAndOffsetTheRest(bool goToNext)
{
if (SubtitleListview1.SelectedItems.Count == 1)
{
bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked;
checkBoxSyncListViewWithVideoWhilePlaying.Checked = false;
int index = SubtitleListview1.SelectedItems[0].Index;
double videoPosition = mediaPlayer.CurrentPosition;
var tc = new TimeCode(TimeSpan.FromSeconds(videoPosition));
double offset = tc.TotalMilliseconds - _subtitle.Paragraphs[index].EndTime.TotalMilliseconds;
if (_subtitle.Paragraphs[index].StartTime.TotalMilliseconds + 100 > tc.TotalMilliseconds || offset > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
return;
MakeHistoryForUndo(_language.BeforeSetEndTimeAndOffsetTheRest + " " + _subtitle.Paragraphs[index].Number.ToString() + " - " + tc.ToString());
numericUpDownDuration.ValueChanged -= NumericUpDownDurationValueChanged;
_subtitle.Paragraphs[index].EndTime.TotalSeconds = videoPosition;
SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index]);
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
numericUpDownDuration.Value = (decimal)_subtitle.Paragraphs[index].Duration.TotalSeconds;
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
for (int i = index + 1; i < SubtitleListview1.Items.Count; i++)
{
if (!_subtitle.Paragraphs[i].StartTime.IsMaxTime)
{
_subtitle.Paragraphs[i].StartTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitle.Paragraphs[i].StartTime.TotalMilliseconds + offset));
_subtitle.Paragraphs[i].EndTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitle.Paragraphs[i].EndTime.TotalMilliseconds + offset));
SubtitleListview1.SetDuration(i, _subtitle.Paragraphs[i]);
}
}
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
{
Paragraph original = Utilities.GetOriginalParagraph(index, _subtitle.Paragraphs[index], _subtitleAlternate.Paragraphs);
if (original != null)
{
index = _subtitleAlternate.GetIndex(original);
for (int i = index; i < _subtitleAlternate.Paragraphs.Count; i++)
{
if (!_subtitleAlternate.Paragraphs[i].StartTime.IsMaxTime)
{
_subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds + offset));
_subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds + offset));
}
}
}
}
if (IsFramesRelevant && CurrentFrameRate > 0)
{
_subtitle.CalculateFrameNumbersFromTimeCodesNoCheck(CurrentFrameRate);
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
ShowSource();
}
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
numericUpDownDuration.ValueChanged += NumericUpDownDurationValueChanged;
if (goToNext)
{
SubtitleListview1.SelectIndexAndEnsureVisible(index + 1);
}
}
}
private void MoveVideoSeconds(double seconds)
{
if (mediaPlayer.IsPaused && Configuration.Settings.General.MoveVideo100Or500MsPlaySmallSample)
@ -13957,6 +14036,8 @@ namespace Nikse.SubtitleEdit.Forms
_mainCreateStartDownEndUp = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainCreateStartDownEndUp);
_mainCreateSetEndAddNewAndGoToNew = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainCreateSetEndAddNewAndGoToNew);
_mainAdjustSetStartAndOffsetTheRest = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest);
_mainAdjustSetEndAndOffsetTheRest = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest);
_mainAdjustSetEndAndOffsetTheRestAndGoToNext = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext);
_mainAdjustSetEndAndGotoNext = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSetEndAndGotoNext);
_mainAdjustInsertViaEndAutoStartAndGoToNext = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustViaEndAutoStartAndGoToNext);
_mainAdjustSetStartAutoDurationAndGoToNext = Utilities.GetKeys(Configuration.Settings.Shortcuts.MainAdjustSetStartAutoDurationAndGoToNext);
@ -14795,7 +14876,7 @@ namespace Nikse.SubtitleEdit.Forms
string ext = Path.GetExtension(fileName).ToLower();
if (ext != ".wav")
{
if (audioVisualizer.WavePeaks == null && Utilities.GetMovieFileExtensions().Contains(ext))
if (audioVisualizer.WavePeaks == null && (Utilities.GetMovieFileExtensions().Contains(ext) || ext == ".mp3"))
{
_videoFileName = fileName;
AudioWaveForm_Click(null, null);

View File

@ -689,6 +689,10 @@ namespace Nikse.SubtitleEdit.Forms
adjustNode.Nodes.Add(Configuration.Settings.Language.Main.VideoControls.SetEndTime + GetShortcutText(Configuration.Settings.Shortcuts.MainAdjustSetEnd));
adjustNode.Nodes.Add(Configuration.Settings.Language.Settings.AdjustSelected100MsForward + GetShortcutText(Configuration.Settings.Shortcuts.MainAdjustSelected100MsForward));
adjustNode.Nodes.Add(Configuration.Settings.Language.Settings.AdjustSelected100MsBack + GetShortcutText(Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack));
if (!string.IsNullOrEmpty(Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRest))
adjustNode.Nodes.Add(Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRest + GetShortcutText(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest));
if (!string.IsNullOrEmpty(Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRestAndGoToNext))
adjustNode.Nodes.Add(Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRestAndGoToNext + GetShortcutText(Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext));
treeViewShortcuts.Nodes.Add(adjustNode);
var audioVisualizerNode = new TreeNode(Configuration.Settings.Language.Settings.WaveformAndSpectrogram);
@ -1399,6 +1403,10 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.Shortcuts.MainAdjustSelected100MsForward = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.AdjustSelected100MsBack != null && text == Configuration.Settings.Language.Settings.AdjustSelected100MsBack.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainAdjustSelected100MsBack = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRest != null && text == Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRest.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest = GetShortcut(node.Text);
else if (Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRestAndGoToNext != null && text == Configuration.Settings.Language.Settings.AdjustSetEndAndOffsetTheRestAndGoToNext.Replace("&", string.Empty))
Configuration.Settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext = GetShortcut(node.Text);
}
}

View File

@ -1043,6 +1043,7 @@ namespace Nikse.SubtitleEdit.Logic
TimeCodeImportedFromXY = "Time codes imported from {0}: {1}",
BeforeInsertSubtitleAtVideoPosition = "Before insert subtitle at video position",
BeforeSetStartTimeAndOffsetTheRest = "Before set start time and off-set the rest",
BeforeSetEndTimeAndOffsetTheRest = "Before set end time and off-set the rest",
BeforeSetEndAndVideoPosition = "Before set end time at video position and auto calculate start",
ContinueWithCurrentSpellCheck = "Continue with current spell check?",
CharactersPerSecond = "Chars/sec: {0:0.00}",
@ -1785,6 +1786,8 @@ can edit in same subtitle file (collaboration)",
AdjustSelected100MsForward = "Move selected lines 100 ms forward",
AdjustSelected100MsBack = "Move selected lines 100 ms back",
AdjustSetStartTimeKeepDuration = "Set start time, keep duration",
AdjustSetEndAndOffsetTheRest = "Set end, offset the rest",
AdjustSetEndAndOffsetTheRestAndGoToNext = "Set end, offset the rest and go to next",
MainCreateStartDownEndUp = "Create new at key-down, set end time at key-up",
MergeDialogue = "Merge dialogue (insert dashes)",
GoToNext = "Go to next line",

View File

@ -930,6 +930,7 @@
public string TimeCodeImportedFromXY { get; set; }
public string BeforeInsertSubtitleAtVideoPosition { get; set; }
public string BeforeSetStartTimeAndOffsetTheRest { get; set; }
public string BeforeSetEndTimeAndOffsetTheRest { get; set; }
public string BeforeSetEndAndVideoPosition { get; set; }
public string ContinueWithCurrentSpellCheck { get; set; }
public string CharactersPerSecond { get; set; }
@ -1680,6 +1681,8 @@
public string AdjustSelected100MsForward { get; set; }
public string AdjustSelected100MsBack { get; set; }
public string AdjustSetStartTimeKeepDuration { get; set; }
public string AdjustSetEndAndOffsetTheRest { get; set; }
public string AdjustSetEndAndOffsetTheRestAndGoToNext { get; set; }
public string MainCreateStartDownEndUp { get; set; }
public string MergeDialogue { get; set; }
public string GoToNext { get; set; }

View File

@ -773,6 +773,8 @@ namespace Nikse.SubtitleEdit.Logic
public string MainCreateSetEndAddNewAndGoToNew { get; set; }
public string MainCreateStartDownEndUp { get; set; }
public string MainAdjustSetStartAndOffsetTheRest { get; set; }
public string MainAdjustSetEndAndOffsetTheRest { get; set; }
public string MainAdjustSetEndAndOffsetTheRestAndGoToNext { get; set; }
public string MainAdjustSetEndAndGotoNext { get; set; }
public string MainAdjustViaEndAutoStartAndGoToNext { get; set; }
public string MainAdjustSetStartAutoDurationAndGoToNext { get; set; }
@ -869,6 +871,8 @@ namespace Nikse.SubtitleEdit.Logic
MainCreateSetEndAddNewAndGoToNew = string.Empty;
MainCreateStartDownEndUp = string.Empty;
MainAdjustSetStartAndOffsetTheRest = "Control+Space";
MainAdjustSetEndAndOffsetTheRest = string.Empty;
MainAdjustSetEndAndOffsetTheRestAndGoToNext = string.Empty;
MainAdjustSetEndAndGotoNext = string.Empty;
MainAdjustViaEndAutoStartAndGoToNext = string.Empty;
MainAdjustSetStartAutoDurationAndGoToNext = string.Empty;
@ -2222,6 +2226,12 @@ namespace Nikse.SubtitleEdit.Logic
subNode = node.SelectSingleNode("MainAdjustSetStartAndOffsetTheRest");
if (subNode != null)
settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest = subNode.InnerText;
subNode = node.SelectSingleNode("MainAdjustSetEndAndOffsetTheRest");
if (subNode != null)
settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest = subNode.InnerText;
subNode = node.SelectSingleNode("MainAdjustSetEndAndOffsetTheRestAndGoToNext");
if (subNode != null)
settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext = subNode.InnerText;
subNode = node.SelectSingleNode("MainAdjustSetEndAndGotoNext");
if (subNode != null)
settings.Shortcuts.MainAdjustSetEndAndGotoNext = subNode.InnerText;
@ -2822,6 +2832,8 @@ namespace Nikse.SubtitleEdit.Logic
textWriter.WriteElementString("MainCreateSetEndAddNewAndGoToNew", settings.Shortcuts.MainCreateSetEndAddNewAndGoToNew);
textWriter.WriteElementString("MainCreateStartDownEndUp", settings.Shortcuts.MainCreateStartDownEndUp);
textWriter.WriteElementString("MainAdjustSetStartAndOffsetTheRest", settings.Shortcuts.MainAdjustSetStartAndOffsetTheRest);
textWriter.WriteElementString("MainAdjustSetEndAndOffsetTheRest", settings.Shortcuts.MainAdjustSetEndAndOffsetTheRest);
textWriter.WriteElementString("MainAdjustSetEndAndOffsetTheRestAndGoToNext", settings.Shortcuts.MainAdjustSetEndAndOffsetTheRestAndGoToNext);
textWriter.WriteElementString("MainAdjustSetEndAndGotoNext", settings.Shortcuts.MainAdjustSetEndAndGotoNext);
textWriter.WriteElementString("MainAdjustViaEndAutoStartAndGoToNext", settings.Shortcuts.MainAdjustViaEndAutoStartAndGoToNext);
textWriter.WriteElementString("MainAdjustSetStartAutoDurationAndGoToNext", settings.Shortcuts.MainAdjustSetStartAutoDurationAndGoToNext);