From 4b57f16583bea7d74faf9e692e632a1181b554b6 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Wed, 18 Mar 2020 08:45:01 +0100 Subject: [PATCH] Add new shortcut "Select next subtitle (from video position, keep video pos)" - thx OmrSi :) --- LanguageMaster.xml | 1 + libse/Language.cs | 1 + libse/LanguageDeserializer.cs | 3 +++ libse/LanguageStructure.cs | 2 +- libse/Settings.cs | 8 ++++++++ src/Forms/Main.cs | 16 ++++++++++++++++ src/Forms/Settings.cs | 1 + src/Logic/MainShortcuts.cs | 2 ++ 8 files changed, 33 insertions(+), 1 deletion(-) diff --git a/LanguageMaster.xml b/LanguageMaster.xml index 30b52a6d9..370fddb42 100644 --- a/LanguageMaster.xml +++ b/LanguageMaster.xml @@ -2040,6 +2040,7 @@ can edit in same subtitle file (collaboration) Play current subtitle Go to previous subtitle (from video position) Go to next subtitle (from video position) + Select next subtitle (from video position, keep video pos) Toggle play/pause Pause Fullscreen diff --git a/libse/Language.cs b/libse/Language.cs index 0608abf82..00346dfd4 100644 --- a/libse/Language.cs +++ b/libse/Language.cs @@ -2314,6 +2314,7 @@ 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)", + WaveformSelectNextSubtitle = "Select next subtitle (from video position, keep video pos)", WaveformGoToPreviousSceneChange = "Go to previous scene change", WaveformGoToNextSceneChange = "Go to next scene change", WaveformToggleSceneChange = "Toggle scene change", diff --git a/libse/LanguageDeserializer.cs b/libse/LanguageDeserializer.cs index 118a4e09f..502658850 100644 --- a/libse/LanguageDeserializer.cs +++ b/libse/LanguageDeserializer.cs @@ -5542,6 +5542,9 @@ namespace Nikse.SubtitleEdit.Core case "Settings/WaveformGoToNextSubtitle": language.Settings.WaveformGoToNextSubtitle = reader.Value; break; + case "Settings/WaveformSelectNextSubtitle": + language.Settings.WaveformSelectNextSubtitle = reader.Value; + break; case "Settings/TogglePlayPause": language.Settings.TogglePlayPause = reader.Value; break; diff --git a/libse/LanguageStructure.cs b/libse/LanguageStructure.cs index fbd01147b..dac344fe0 100644 --- a/libse/LanguageStructure.cs +++ b/libse/LanguageStructure.cs @@ -2206,7 +2206,7 @@ public string WaveformGoToPrevSubtitle { get; set; } public string WaveformGoToNextSubtitle { get; set; } - + public string WaveformSelectNextSubtitle { get; set; } public string TogglePlayPause { get; set; } public string Pause { get; set; } public string Fullscreen { get; set; } diff --git a/libse/Settings.cs b/libse/Settings.cs index c623cf171..c68b03a96 100644 --- a/libse/Settings.cs +++ b/libse/Settings.cs @@ -1465,6 +1465,7 @@ $HorzAlign = Center public string MainVideoPlayCurrent { get; set; } public string MainVideoGoToPrevSubtitle { get; set; } public string MainVideoGoToNextSubtitle { get; set; } + public string MainVideoSelectNextSubtitle { get; set; } public string MainVideoFullscreen { get; set; } public string MainVideoSlower { get; set; } public string MainVideoFaster { get; set; } @@ -5540,6 +5541,12 @@ $HorzAlign = Center settings.Shortcuts.MainVideoGoToNextSubtitle = subNode.InnerText; } + subNode = node.SelectSingleNode("MainVideoSelectNextSubtitle"); + if (subNode != null) + { + settings.Shortcuts.MainVideoSelectNextSubtitle = subNode.InnerText; + } + subNode = node.SelectSingleNode("MainVideoFullscreen"); if (subNode != null) { @@ -7058,6 +7065,7 @@ $HorzAlign = Center textWriter.WriteElementString("MainVideoPlayCurrent", settings.Shortcuts.MainVideoPlayCurrent); textWriter.WriteElementString("MainVideoGoToPrevSubtitle", settings.Shortcuts.MainVideoGoToPrevSubtitle); textWriter.WriteElementString("MainVideoGoToNextSubtitle", settings.Shortcuts.MainVideoGoToNextSubtitle); + textWriter.WriteElementString("MainVideoSelectNextSubtitle", settings.Shortcuts.MainVideoSelectNextSubtitle); textWriter.WriteElementString("MainVideoFullscreen", settings.Shortcuts.MainVideoFullscreen); textWriter.WriteElementString("MainVideoSlower", settings.Shortcuts.MainVideoSlower); textWriter.WriteElementString("MainVideoFaster", settings.Shortcuts.MainVideoFaster); diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index e00e0ecae..eff3fa9cc 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -14188,6 +14188,22 @@ namespace Nikse.SubtitleEdit.Forms e.SuppressKeyPress = true; } + else if (e.KeyData == _shortcuts.VideoSelectNextSubtitle) + { + var cp = mediaPlayer.CurrentPosition * TimeCode.BaseUnit; + foreach (var p in _subtitle.Paragraphs) + { + if (p.StartTime.TotalMilliseconds > cp) + { + SubtitleListview1.SelectNone(); + SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Selected = true; + SubtitleListview1.Items[_subtitle.Paragraphs.IndexOf(p)].Focused = true; + break; + } + } + + e.SuppressKeyPress = true; + } else if (audioVisualizer.SceneChanges != null && e.KeyData == _shortcuts.WaveformGoToPreviousSceneChange) { var cp = mediaPlayer.CurrentPosition - 0.01; diff --git a/src/Forms/Settings.cs b/src/Forms/Settings.cs index 076ec1b84..a103ba2e6 100644 --- a/src/Forms/Settings.cs +++ b/src/Forms/Settings.cs @@ -1120,6 +1120,7 @@ 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)); + 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)); AddNode(videoNode, language.PlayRateFaster, nameof(Configuration.Settings.Shortcuts.MainVideoFaster)); diff --git a/src/Logic/MainShortcuts.cs b/src/Logic/MainShortcuts.cs index 3cfd98f59..ef2b7fd5c 100644 --- a/src/Logic/MainShortcuts.cs +++ b/src/Logic/MainShortcuts.cs @@ -47,6 +47,7 @@ namespace Nikse.SubtitleEdit.Logic public Keys MainVideoPlayCurrent { get; set; } public Keys VideoGoToPrevSubtitle { get; set; } public Keys VideoGoToNextSubtitle { get; set; } + public Keys VideoSelectNextSubtitle { get; set; } public Keys VideoPlayFirstSelected { get; set; } public Keys MainVideoFullscreen { get; set; } public Keys MainVideoSlower { get; set; } @@ -186,6 +187,7 @@ 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); + VideoSelectNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoSelectNextSubtitle); VideoPlayFirstSelected = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralPlayFirstSelected); MainGoToPreviousSubtitleAndFocusVideo = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToPreviousSubtitleAndFocusVideo); MainGoToNextSubtitleAndFocusVideo = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitleAndFocusVideo);