Add shortcuts for moving between chapters

This commit is contained in:
OmrSi 2020-10-16 15:49:15 +03:00
parent b1232085bc
commit 9ebbde7c9d
8 changed files with 65 additions and 0 deletions

View File

@ -2207,6 +2207,8 @@ can edit in same subtitle file (collaboration)</Information>
<PlayCurrent>Play current subtitle</PlayCurrent>
<WaveformGoToPrevSubtitle>Go to previous subtitle (from video position)</WaveformGoToPrevSubtitle>
<WaveformGoToNextSubtitle>Go to next subtitle (from video position)</WaveformGoToNextSubtitle>
<WaveformGoToPrevChapter>Go to previous chapter</WaveformGoToPrevChapter>
<WaveformGoToNextChapter>Go to next chapter</WaveformGoToNextChapter>
<WaveformSelectNextSubtitle>Select next subtitle (from video position, keep video pos)</WaveformSelectNextSubtitle>
<TogglePlayPause>Toggle play/pause</TogglePlayPause>
<Pause>Pause</Pause>

View File

@ -2489,6 +2489,8 @@ can edit in same subtitle file (collaboration)",
WaveformFocusListView = "Focus list view",
WaveformGoToPrevSubtitle = "Go to previous subtitle (from video position)",
WaveformGoToNextSubtitle = "Go to next subtitle (from video position)",
WaveformGoToPrevChapter = "Go to previous chapter",
WaveformGoToNextChapter = "Go to next chapter",
WaveformSelectNextSubtitle = "Select next subtitle (from video position, keep video pos)",
WaveformGoToPreviousSceneChange = "Go to previous scene change",
WaveformGoToNextSceneChange = "Go to next scene change",

View File

@ -6043,6 +6043,12 @@ namespace Nikse.SubtitleEdit.Core
case "Settings/WaveformGoToNextSubtitle":
language.Settings.WaveformGoToNextSubtitle = reader.Value;
break;
case "Settings/WaveformGoToPrevChapter":
language.Settings.WaveformGoToPrevChapter = reader.Value;
break;
case "Settings/WaveformGoToNextChapter":
language.Settings.WaveformGoToNextChapter = reader.Value;
break;
case "Settings/WaveformSelectNextSubtitle":
language.Settings.WaveformSelectNextSubtitle = reader.Value;
break;

View File

@ -2374,6 +2374,8 @@
public string WaveformGoToPrevSubtitle { get; set; }
public string WaveformGoToNextSubtitle { get; set; }
public string WaveformGoToPrevChapter { get; set; }
public string WaveformGoToNextChapter { get; set; }
public string WaveformSelectNextSubtitle { get; set; }
public string TogglePlayPause { get; set; }
public string Pause { get; set; }

View File

@ -1847,6 +1847,8 @@ $HorzAlign = Center
public string MainVideoPlayCurrent { get; set; }
public string MainVideoGoToPrevSubtitle { get; set; }
public string MainVideoGoToNextSubtitle { get; set; }
public string MainVideoGoToPrevChapter { get; set; }
public string MainVideoGoToNextChapter { get; set; }
public string MainVideoSelectNextSubtitle { get; set; }
public string MainVideoFullscreen { get; set; }
public string MainVideoSlower { get; set; }
@ -6627,6 +6629,18 @@ $HorzAlign = Center
shortcuts.MainVideoGoToNextSubtitle = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoGoToPrevChapter");
if (subNode != null)
{
shortcuts.MainVideoGoToPrevChapter = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoGoToNextChapter");
if (subNode != null)
{
shortcuts.MainVideoGoToNextChapter = subNode.InnerText;
}
subNode = node.SelectSingleNode("MainVideoSelectNextSubtitle");
if (subNode != null)
{
@ -8302,6 +8316,8 @@ $HorzAlign = Center
textWriter.WriteElementString("MainVideoPlayCurrent", shortcuts.MainVideoPlayCurrent);
textWriter.WriteElementString("MainVideoGoToPrevSubtitle", shortcuts.MainVideoGoToPrevSubtitle);
textWriter.WriteElementString("MainVideoGoToNextSubtitle", shortcuts.MainVideoGoToNextSubtitle);
textWriter.WriteElementString("MainVideoGoToPrevChapter", shortcuts.MainVideoGoToPrevChapter);
textWriter.WriteElementString("MainVideoGoToNextChapter", shortcuts.MainVideoGoToNextChapter);
textWriter.WriteElementString("MainVideoSelectNextSubtitle", shortcuts.MainVideoSelectNextSubtitle);
textWriter.WriteElementString("MainVideoFullscreen", shortcuts.MainVideoFullscreen);
textWriter.WriteElementString("MainVideoSlower", shortcuts.MainVideoSlower);

View File

@ -14703,6 +14703,34 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
}
else if (mediaPlayer.Chapters != null && e.KeyData == _shortcuts.VideoGoToPrevChapter)
{
var cp = mediaPlayer.CurrentPosition - 0.01;
foreach (var chapter in mediaPlayer.Chapters.Reverse<double>())
{
if (chapter < cp)
{
mediaPlayer.CurrentPosition = chapter;
break;
}
}
e.SuppressKeyPress = true;
}
else if (mediaPlayer.Chapters != null && e.KeyData == _shortcuts.VideoGoToNextChapter)
{
var cp = mediaPlayer.CurrentPosition + 0.01;
foreach (var chapter in mediaPlayer.Chapters)
{
if (chapter > cp)
{
mediaPlayer.CurrentPosition = chapter;
break;
}
}
e.SuppressKeyPress = true;
}
else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToPreviousSceneChange)
{
var cp = mediaPlayer.CurrentPosition - 0.01;

View File

@ -1225,6 +1225,11 @@ namespace Nikse.SubtitleEdit.Forms
AddNode(videoNode, language.PlayCurrent, nameof(Configuration.Settings.Shortcuts.MainVideoPlayCurrent));
AddNode(videoNode, language.WaveformGoToPrevSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevSubtitle));
AddNode(videoNode, language.WaveformGoToNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextSubtitle));
if (Configuration.Settings.General.ShowChapters)
{
AddNode(videoNode, language.WaveformGoToPrevChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToPrevChapter));
AddNode(videoNode, language.WaveformGoToNextChapter, nameof(Configuration.Settings.Shortcuts.MainVideoGoToNextChapter));
}
AddNode(videoNode, language.WaveformSelectNextSubtitle, nameof(Configuration.Settings.Shortcuts.MainVideoSelectNextSubtitle));
AddNode(videoNode, language.Fullscreen, nameof(Configuration.Settings.Shortcuts.MainVideoFullscreen));
AddNode(videoNode, language.PlayRateSlower, nameof(Configuration.Settings.Shortcuts.MainVideoSlower));

View File

@ -52,6 +52,8 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainVideoPlayCurrent { get; set; }
public Keys VideoGoToPrevSubtitle { get; set; }
public Keys VideoGoToNextSubtitle { get; set; }
public Keys VideoGoToPrevChapter { get; set; }
public Keys VideoGoToNextChapter { get; set; }
public Keys VideoSelectNextSubtitle { get; set; }
public Keys VideoPlayFirstSelected { get; set; }
public Keys MainVideoFullscreen { get; set; }
@ -225,6 +227,8 @@ namespace Nikse.SubtitleEdit.Logic
MainVideoPlayCurrent = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoPlayCurrent);
VideoGoToPrevSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoGoToPrevSubtitle);
VideoGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoGoToNextSubtitle);
VideoGoToPrevChapter = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoGoToPrevChapter);
VideoGoToNextChapter = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoGoToNextChapter);
VideoSelectNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoSelectNextSubtitle);
VideoPlayFirstSelected = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralPlayFirstSelected);
MainGoToPreviousSubtitleAndFocusVideo = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPreviousSubtitleAndFocusVideo);