Add toggle preview on video (mpv only for now)

Fix #3226
This commit is contained in:
Nikolaj Olsson 2021-01-07 12:41:29 +01:00
parent 7048a95089
commit b27811c3da
8 changed files with 39 additions and 4 deletions

View File

@ -2384,6 +2384,8 @@ Continue?</RestoreDefaultSettingsMsg>
<TreatINQuoteAsING>Treat word ending " in' " as " ing " (English only)</TreatINQuoteAsING>
<RememberUseAlwaysList>Remember "Use always" list</RememberUseAlwaysList>
<LiveSpellCheck>Live spell check</LiveSpellCheck>
<LiveSpellCheckLanguage>Live spell check - Working with language [{0}]</LiveSpellCheckLanguage>
<NoDictionaryForLiveSpellCheck>Live spell check - You don't have dictionaries for this language [{0}]</NoDictionaryForLiveSpellCheck>
<ImageText>Image text</ImageText>
<SpellCheckCompleted>Spell check completed</SpellCheckCompleted>
<SpellCheckAborted>Spell check aborted</SpellCheckAborted>

View File

@ -1811,6 +1811,7 @@ $HorzAlign = Center
public string GeneralDuplicateLine { get; set; }
public string GeneralToggleView { get; set; }
public string GeneralToggleMode { get; set; }
public string GeneralTogglePreviewOnVideo { get; set; }
public string GeneralHelp { get; set; }
public string MainFileNew { get; set; }
public string MainFileOpen { get; set; }
@ -6386,6 +6387,12 @@ $HorzAlign = Center
shortcuts.GeneralToggleMode = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralTogglePreviewOnVideo");
if (subNode != null)
{
shortcuts.GeneralTogglePreviewOnVideo = subNode.InnerText;
}
subNode = node.SelectSingleNode("GeneralHelp");
if (subNode != null)
{
@ -8551,6 +8558,7 @@ $HorzAlign = Center
textWriter.WriteElementString("GeneralDuplicateLine", shortcuts.GeneralDuplicateLine);
textWriter.WriteElementString("GeneralToggleView", shortcuts.GeneralToggleView);
textWriter.WriteElementString("GeneralToggleMode", shortcuts.GeneralToggleMode);
textWriter.WriteElementString("GeneralTogglePreviewOnVideo", shortcuts.GeneralTogglePreviewOnVideo);
textWriter.WriteElementString("GeneralHelp", shortcuts.GeneralHelp);
textWriter.WriteElementString("MainFileNew", shortcuts.MainFileNew);
textWriter.WriteElementString("MainFileOpen", shortcuts.MainFileOpen);

View File

@ -14464,6 +14464,22 @@ namespace Nikse.SubtitleEdit.Forms
e.SuppressKeyPress = true;
}
else if (_shortcuts.MainGeneralTogglePreviewOnVideo == e.KeyData)
{
Configuration.Settings.General.MpvHandlesPreviewText = !Configuration.Settings.General.MpvHandlesPreviewText;
if (mediaPlayer.VideoPlayer is LibMpvDynamic libMpv)
{
if (!Configuration.Settings.General.MpvHandlesPreviewText)
{
libMpv.RemoveSubtitle();
}
mediaPlayer.VideoPlayer = mediaPlayer.VideoPlayer;
mediaPlayer.SetSubtitleText(string.Empty, null, _subtitle);
ShowSubtitle();
}
e.SuppressKeyPress = true;
}
else if (_shortcuts.MainGeneralFileSaveAll == e.KeyData)
{
SaveAll();

View File

@ -1,8 +1,7 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Common;
using Nikse.SubtitleEdit.Core.Dictionaries;
using Nikse.SubtitleEdit.Core.Enums;
using Nikse.SubtitleEdit.Core.Translate;
using Nikse.SubtitleEdit.Core.Translate.Service;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.VideoPlayers;
using System;
@ -17,7 +16,6 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core.Translate.Service;
namespace Nikse.SubtitleEdit.Forms.Options
{
@ -1169,6 +1167,7 @@ namespace Nikse.SubtitleEdit.Forms.Options
AddNode(generalNode, language.DuplicateLine, nameof(Configuration.Settings.Shortcuts.GeneralDuplicateLine));
AddNode(generalNode, language.ToggleView, nameof(Configuration.Settings.Shortcuts.GeneralToggleView));
AddNode(generalNode, language.ToggleMode, nameof(Configuration.Settings.Shortcuts.GeneralToggleMode));
AddNode(generalNode, language.TogglePreviewOnVideo, nameof(Configuration.Settings.Shortcuts.GeneralTogglePreviewOnVideo));
AddNode(generalNode, language.Help, nameof(Configuration.Settings.Shortcuts.GeneralHelp), true);
if (generalNode.Nodes.Count > 0)
{

View File

@ -2231,6 +2231,7 @@ can edit in same subtitle file (collaboration)",
ChooseProfile = "Choose profile",
DuplicateLine = "Duplicate line",
ToggleView = "Toggle list/source view",
TogglePreviewOnVideo = "Toogle preview on video",
ToggleMode = "Toggle translate/create/adjust mode",
Help = "Help",
FontInUi = "UI Font",

View File

@ -6523,6 +6523,12 @@ namespace Nikse.SubtitleEdit.Logic
case "SpellCheck/LiveSpellCheck":
language.SpellCheck.LiveSpellCheck = reader.Value;
break;
case "SpellCheck/LiveSpellCheckLanguage":
language.SpellCheck.LiveSpellCheckLanguage = reader.Value;
break;
case "SpellCheck/NoDictionaryForLiveSpellCheck":
language.SpellCheck.NoDictionaryForLiveSpellCheck = reader.Value;
break;
case "SpellCheck/ImageText":
language.SpellCheck.ImageText = reader.Value;
break;

View File

@ -2088,6 +2088,7 @@
public string DuplicateLine { get; set; }
public string ToggleView { get; set; }
public string ToggleMode { get; set; }
public string TogglePreviewOnVideo { get; set; }
public string Help { get; set; }
public string FontInUi { get; set; }
public string ShowFrameRate { get; set; }

View File

@ -78,6 +78,7 @@ namespace Nikse.SubtitleEdit.Logic
public Keys MainGeneralDuplicateLine { get; set; }
public Keys MainGeneralToggleView { get; set; }
public Keys MainGeneralToggleMode { get; set; }
public Keys MainGeneralTogglePreviewOnVideo { get; set; }
public Keys MainTextBoxSplitAtCursor { get; set; }
public Keys MainTextBoxSplitAtCursorAndVideoPos { get; set; }
public Keys MainTextBoxSplitSelectedLineBilingual { get; set; }
@ -260,6 +261,7 @@ namespace Nikse.SubtitleEdit.Logic
MainGeneralDuplicateLine = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralDuplicateLine);
MainGeneralToggleView = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralToggleView);
MainGeneralToggleMode = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralToggleMode);
MainGeneralTogglePreviewOnVideo = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralTogglePreviewOnVideo);
MainVideoFullscreen = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFullscreen);
MainVideoSlower = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoSlower);
MainVideoFaster = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainVideoFaster);