From d97cefd57bc9b9c2a944bc4148b87da6bdb633f8 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Mon, 9 Sep 2024 18:17:51 +0200 Subject: [PATCH] Add move all shot changes shortcuts - thx acetilo :) Work on #8795 --- LanguageBaseEnglish.xml | 2 ++ src/libse/Settings/Settings.cs | 14 ++++++++++++++ src/libse/Settings/Shortcuts.cs | 2 ++ src/ui/Forms/Main.cs | 22 ++++++++++++++++++++++ src/ui/Forms/Options/Settings.cs | 2 ++ src/ui/Logic/Language.cs | 2 ++ src/ui/Logic/LanguageDeserializer.cs | 6 ++++++ src/ui/Logic/LanguageStructure.cs | 2 ++ src/ui/Logic/MainShortcuts.cs | 4 ++++ 9 files changed, 56 insertions(+) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index 699b10626..b7a0591e3 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -2692,6 +2692,8 @@ can edit in same subtitle file (collaboration) Go to previous shot change Go to next shot change Toggle shot change + Move all shot changes one frame forward + Move all shot changes one frame back Remove/export shot changes Auto adjust start via volume/shot change One frame back diff --git a/src/libse/Settings/Settings.cs b/src/libse/Settings/Settings.cs index f191d55b3..483f8b5ef 100644 --- a/src/libse/Settings/Settings.cs +++ b/src/libse/Settings/Settings.cs @@ -8466,6 +8466,18 @@ namespace Nikse.SubtitleEdit.Core.Settings shortcuts.WaveformToggleShotChange = subNode.InnerText; } + subNode = node.SelectSingleNode("WaveformAllShotChangesOneFrameForward"); + if (subNode != null) + { + shortcuts.WaveformAllShotChangesOneFrameForward = subNode.InnerText; + } + + subNode = node.SelectSingleNode("WaveformAllShotChangesOneFrameBack"); + if (subNode != null) + { + shortcuts.WaveformAllShotChangesOneFrameBack = subNode.InnerText; + } + subNode = node.SelectSingleNode("WaveformListShotChanges"); if (subNode != null) { @@ -10222,6 +10234,8 @@ namespace Nikse.SubtitleEdit.Core.Settings textWriter.WriteElementString("WaveformGoToPreviousShotChange", shortcuts.WaveformGoToPreviousShotChange); textWriter.WriteElementString("WaveformGoToNextShotChange", shortcuts.WaveformGoToNextShotChange); textWriter.WriteElementString("WaveformToggleShotChange", shortcuts.WaveformToggleShotChange); + textWriter.WriteElementString("WaveformAllShotChangesOneFrameForward", shortcuts.WaveformAllShotChangesOneFrameForward); + textWriter.WriteElementString("WaveformAllShotChangesOneFrameBack", shortcuts.WaveformAllShotChangesOneFrameBack); textWriter.WriteElementString("WaveformListShotChanges", shortcuts.WaveformListShotChanges); textWriter.WriteElementString("WaveformGuessStart", shortcuts.WaveformGuessStart); textWriter.WriteElementString("Waveform100MsLeft", shortcuts.Waveform100MsLeft); diff --git a/src/libse/Settings/Shortcuts.cs b/src/libse/Settings/Shortcuts.cs index 184cd1d48..b3b543717 100644 --- a/src/libse/Settings/Shortcuts.cs +++ b/src/libse/Settings/Shortcuts.cs @@ -390,6 +390,8 @@ namespace Nikse.SubtitleEdit.Core.Settings public string WaveformGoToPreviousShotChange { get; set; } public string WaveformGoToNextShotChange { get; set; } public string WaveformToggleShotChange { get; set; } + public string WaveformAllShotChangesOneFrameForward { get; set; } + public string WaveformAllShotChangesOneFrameBack { get; set; } public string WaveformListShotChanges { get; set; } public string WaveformGuessStart { get; set; } public string Waveform100MsLeft { get; set; } diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index e65d0697a..b7a76dd26 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -18568,6 +18568,28 @@ namespace Nikse.SubtitleEdit.Forms e.SuppressKeyPress = true; } + else if (audioVisualizer.ShotChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformAllShotChangesOneFrameForward) + { + var frameMs = (double)Math.Round(1000.0 / CurrentFrameRate); + for (var i = 0; i < audioVisualizer.ShotChanges.Count; i++) + { + audioVisualizer.ShotChanges[i] += (frameMs / 1000.0); + } + + ShotChangeHelper.SaveShotChanges(_videoFileName, audioVisualizer.ShotChanges); + e.SuppressKeyPress = true; + } + else if (audioVisualizer.ShotChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformAllShotChangesOneFrameBack) + { + var frameMs = (double)Math.Round(1000.0 / CurrentFrameRate); + for (var i = 0; i < audioVisualizer.ShotChanges.Count; i++) + { + audioVisualizer.ShotChanges[i] -= (frameMs / 1000.0); + } + + ShotChangeHelper.SaveShotChanges(_videoFileName, audioVisualizer.ShotChanges); + e.SuppressKeyPress = true; + } else if (audioVisualizer.ShotChanges != null && mediaPlayer.IsPaused && e.KeyData == _shortcuts.WaveformGuessStart) { AutoGuessStartTime(_subtitleListViewIndex); diff --git a/src/ui/Forms/Options/Settings.cs b/src/ui/Forms/Options/Settings.cs index dadbc4366..161a16419 100644 --- a/src/ui/Forms/Options/Settings.cs +++ b/src/ui/Forms/Options/Settings.cs @@ -1927,6 +1927,8 @@ namespace Nikse.SubtitleEdit.Forms.Options AddNode(audioVisualizerNode, LanguageSettings.Current.Main.VideoControls.InsertNewSubtitleAtVideoPosition, nameof(Configuration.Settings.Shortcuts.MainWaveformInsertAtCurrentPosition)); AddNode(audioVisualizerNode, language.WaveformGoToPreviousShotChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToPreviousShotChange)); AddNode(audioVisualizerNode, language.WaveformGoToNextShotChange, nameof(Configuration.Settings.Shortcuts.WaveformGoToNextShotChange)); + AddNode(audioVisualizerNode, language.WaveformAllShotChangesOneFrameBack, nameof(Configuration.Settings.Shortcuts.WaveformAllShotChangesOneFrameBack)); + AddNode(audioVisualizerNode, language.WaveformAllShotChangesOneFrameForward, nameof(Configuration.Settings.Shortcuts.WaveformAllShotChangesOneFrameForward)); AddNode(audioVisualizerNode, language.WaveformToggleShotChange, nameof(Configuration.Settings.Shortcuts.WaveformToggleShotChange)); AddNode(audioVisualizerNode, language.WaveformRemoveOrExportShotChanges, nameof(Configuration.Settings.Shortcuts.WaveformListShotChanges), true); AddNode(audioVisualizerNode, language.WaveformGuessStart, nameof(Configuration.Settings.Shortcuts.WaveformGuessStart)); diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 665654afa..064db57d3 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -3062,6 +3062,8 @@ can edit in same subtitle file (collaboration)", WaveformGoToPreviousShotChange = "Go to previous shot change", WaveformGoToNextShotChange = "Go to next shot change", WaveformToggleShotChange = "Toggle shot change", + WaveformAllShotChangesOneFrameForward = "Move all shot changes one frame forward", + WaveformAllShotChangesOneFrameBack = "Move all shot changes one frame back", WaveformRemoveOrExportShotChanges = "Remove/export shot changes", WaveformGuessStart = "Auto adjust start via volume/shot change", GoBack1Frame = "One frame back", diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index 7c661a053..5362b4996 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -7372,6 +7372,12 @@ namespace Nikse.SubtitleEdit.Logic case "Settings/WaveformToggleShotChange": language.Settings.WaveformToggleShotChange = reader.Value; break; + case "Settings/WaveformAllShotChangesOneFrameForward": + language.Settings.WaveformAllShotChangesOneFrameForward = reader.Value; + break; + case "Settings/WaveformAllShotChangesOneFrameBack": + language.Settings.WaveformAllShotChangesOneFrameBack = reader.Value; + break; case "Settings/WaveformRemoveOrExportShotChanges": language.Settings.WaveformRemoveOrExportShotChanges = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index b4d3e7761..080c9c420 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -2870,6 +2870,8 @@ public string WaveformGoToPreviousShotChange { get; set; } public string WaveformGoToNextShotChange { get; set; } public string WaveformToggleShotChange { get; set; } + public string WaveformAllShotChangesOneFrameForward { get; set; } + public string WaveformAllShotChangesOneFrameBack { get; set; } public string WaveformRemoveOrExportShotChanges { get; set; } public string WaveformGuessStart { get; set; } public string GoBack1Frame { get; set; } diff --git a/src/ui/Logic/MainShortcuts.cs b/src/ui/Logic/MainShortcuts.cs index 1baffe36e..1363c9901 100644 --- a/src/ui/Logic/MainShortcuts.cs +++ b/src/ui/Logic/MainShortcuts.cs @@ -270,6 +270,8 @@ namespace Nikse.SubtitleEdit.Logic public Keys WaveformGoToPreviousShotChange { get; set; } public Keys WaveformGoToNextShotChange { get; set; } public Keys WaveformToggleShotChange { get; set; } + public Keys WaveformAllShotChangesOneFrameForward { get; set; } + public Keys WaveformAllShotChangesOneFrameBack { get; set; } public Keys WaveformListShotChanges { get; set; } public Keys WaveformGuessStart { get; set; } public Keys WaveformAudioToTextVosk { get; set; } @@ -549,6 +551,8 @@ namespace Nikse.SubtitleEdit.Logic WaveformSetParagraphAsNewSelection = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformSetParagraphAsSelection); WaveformGoToPreviousShotChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformGoToPreviousShotChange); WaveformGoToNextShotChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformGoToNextShotChange); + WaveformAllShotChangesOneFrameForward = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformAllShotChangesOneFrameForward); + WaveformAllShotChangesOneFrameBack = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformAllShotChangesOneFrameBack); WaveformToggleShotChange = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformToggleShotChange); WaveformListShotChanges = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformListShotChanges); WaveformGuessStart = UiUtil.GetKeys(Configuration.Settings.Shortcuts.WaveformGuessStart);