mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 12:44:46 +01:00
Remember last chosen video offset - thx OmrSi :)
Somewhat related to #5479 Also add a few presets
This commit is contained in:
parent
5375fc4da2
commit
687ce3e9d5
@ -1271,6 +1271,8 @@ $HorzAlign = Center
|
||||
public bool ShowProgress { get; set; }
|
||||
public bool ShowNegativeDurationInfoOnSave { get; set; }
|
||||
public bool ShowFormatRequiresUtf8Warning { get; set; }
|
||||
public long DefaultVideoOffsetInMs { get; set; }
|
||||
public string DefaultVideoOffsetInSecondsList { get; set; }
|
||||
public long CurrentVideoOffsetInMs { get; set; }
|
||||
public bool CurrentVideoIsSmpte { get; set; }
|
||||
public bool AutoSetVideoSmpteForTtml { get; set; }
|
||||
@ -1414,6 +1416,8 @@ $HorzAlign = Center
|
||||
ShowProgress = false;
|
||||
ShowNegativeDurationInfoOnSave = true;
|
||||
ShowFormatRequiresUtf8Warning = true;
|
||||
DefaultVideoOffsetInMs = 10 * 60 * 60 * 1000;
|
||||
DefaultVideoOffsetInSecondsList = "36000;3600";
|
||||
DarkThemeForeColor = Color.FromArgb(155, 155, 155);
|
||||
DarkThemeBackColor = Color.FromArgb(30, 30, 30);
|
||||
UseDarkTheme = false;
|
||||
@ -3830,6 +3834,18 @@ $HorzAlign = Center
|
||||
settings.General.ShowFormatRequiresUtf8Warning = Convert.ToBoolean(subNode.InnerText.Trim(), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("DefaultVideoOffsetInMs");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.General.DefaultVideoOffsetInMs = Convert.ToInt64(subNode.InnerText.Trim(), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("DefaultVideoOffsetInSecondsList");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.General.DefaultVideoOffsetInSecondsList = subNode.InnerText;
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("AutoSetVideoSmpteForTtml");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -8982,6 +8998,8 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("ShowProgress", settings.General.ShowProgress.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ShowNegativeDurationInfoOnSave", settings.General.ShowNegativeDurationInfoOnSave.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("ShowFormatRequiresUtf8Warning", settings.General.ShowFormatRequiresUtf8Warning.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("DefaultVideoOffsetInMs", settings.General.DefaultVideoOffsetInMs.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("DefaultVideoOffsetInSecondsList", settings.General.DefaultVideoOffsetInSecondsList);
|
||||
textWriter.WriteElementString("AutoSetVideoSmpteForTtml", settings.General.AutoSetVideoSmpteForTtml.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("AutoSetVideoSmpteForTtmlPrompt", settings.General.AutoSetVideoSmpteForTtmlPrompt.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("TitleBarAsterisk", settings.General.TitleBarAsterisk);
|
||||
|
@ -30354,7 +30354,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
using (var form = new SetVideoOffset())
|
||||
{
|
||||
form.VideoOffset = new TimeCode(10, 0, 0, 0);
|
||||
form.VideoOffset = TimeCode.FromSeconds(Configuration.Settings.General.DefaultVideoOffsetInMs / 1000.0);
|
||||
if (Configuration.Settings.General.CurrentVideoOffsetInMs != 0)
|
||||
{
|
||||
form.VideoOffset = new TimeCode(Configuration.Settings.General.CurrentVideoOffsetInMs);
|
||||
@ -30374,6 +30374,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Configuration.Settings.General.CurrentVideoOffsetInMs = (long)(Math.Round(form.VideoOffset.TotalSeconds * 1000.0));
|
||||
}
|
||||
|
||||
if (Configuration.Settings.General.CurrentVideoOffsetInMs > 0)
|
||||
{
|
||||
Configuration.Settings.General.DefaultVideoOffsetInMs = Configuration.Settings.General.CurrentVideoOffsetInMs;
|
||||
}
|
||||
|
||||
if (form.DoNotaddVideoOffsetToTimeCodes)
|
||||
{
|
||||
if (form.Reset)
|
||||
|
25
src/ui/Forms/SetVideoOffset.Designer.cs
generated
25
src/ui/Forms/SetVideoOffset.Designer.cs
generated
@ -30,7 +30,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
TimeCode timeCode1 = new TimeCode();
|
||||
this.components = new System.ComponentModel.Container();
|
||||
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.labelDescription = new System.Windows.Forms.Label();
|
||||
@ -38,6 +39,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.timeUpDownVideoPosition = new Nikse.SubtitleEdit.Controls.TimeUpDown();
|
||||
this.buttonReset = new System.Windows.Forms.Button();
|
||||
this.checkBoxKeepTimeCodes = new System.Windows.Forms.CheckBox();
|
||||
this.buttonPickOffset = new System.Windows.Forms.Button();
|
||||
this.contextMenuStripDefaultOffsets = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
@ -92,7 +95,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.timeUpDownVideoPosition.Location = new System.Drawing.Point(13, 39);
|
||||
this.timeUpDownVideoPosition.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.timeUpDownVideoPosition.Name = "timeUpDownVideoPosition";
|
||||
this.timeUpDownVideoPosition.Size = new System.Drawing.Size(96, 27);
|
||||
this.timeUpDownVideoPosition.Size = new System.Drawing.Size(111, 27);
|
||||
this.timeUpDownVideoPosition.TabIndex = 1;
|
||||
timeCode1.Hours = 0;
|
||||
timeCode1.Milliseconds = 0;
|
||||
@ -126,11 +129,27 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.checkBoxKeepTimeCodes.Text = "Keep existing time codes (do not add video offset)";
|
||||
this.checkBoxKeepTimeCodes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonPickOffset
|
||||
//
|
||||
this.buttonPickOffset.Location = new System.Drawing.Point(131, 42);
|
||||
this.buttonPickOffset.Name = "buttonPickOffset";
|
||||
this.buttonPickOffset.Size = new System.Drawing.Size(25, 23);
|
||||
this.buttonPickOffset.TabIndex = 7;
|
||||
this.buttonPickOffset.Text = "...";
|
||||
this.buttonPickOffset.UseVisualStyleBackColor = true;
|
||||
this.buttonPickOffset.Click += new System.EventHandler(this.buttonPickOffset_Click);
|
||||
//
|
||||
// contextMenuStripDefaultOffsets
|
||||
//
|
||||
this.contextMenuStripDefaultOffsets.Name = "contextMenuStripRes";
|
||||
this.contextMenuStripDefaultOffsets.Size = new System.Drawing.Size(61, 4);
|
||||
//
|
||||
// SetVideoOffset
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(473, 162);
|
||||
this.Controls.Add(this.buttonPickOffset);
|
||||
this.Controls.Add(this.checkBoxKeepTimeCodes);
|
||||
this.Controls.Add(this.buttonReset);
|
||||
this.Controls.Add(this.checkBoxFromCurrentPosition);
|
||||
@ -161,5 +180,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private System.Windows.Forms.CheckBox checkBoxFromCurrentPosition;
|
||||
private System.Windows.Forms.Button buttonReset;
|
||||
private System.Windows.Forms.CheckBox checkBoxKeepTimeCodes;
|
||||
private System.Windows.Forms.Button buttonPickOffset;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStripDefaultOffsets;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using Nikse.SubtitleEdit.Core.Common;
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
@ -37,9 +39,44 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonReset.Text = LanguageSettings.Current.SetVideoOffset.Reset;
|
||||
buttonOK.Text = LanguageSettings.Current.General.Ok;
|
||||
buttonCancel.Text = LanguageSettings.Current.General.Cancel;
|
||||
FillDefaultOffsets();
|
||||
UiUtil.FixLargeFonts(this, buttonOK);
|
||||
}
|
||||
|
||||
private void FillDefaultOffsets()
|
||||
{
|
||||
var secondsList = new List<long>();
|
||||
foreach (var ms in Configuration.Settings.General.DefaultVideoOffsetInSecondsList.Split(';'))
|
||||
{
|
||||
if (long.TryParse(ms, out var l))
|
||||
{
|
||||
secondsList.Add(l);
|
||||
}
|
||||
}
|
||||
|
||||
if (secondsList.Count == 0)
|
||||
{
|
||||
secondsList.Add(1 * 60 * 60);
|
||||
secondsList.Add(10 * 60 * 60);
|
||||
}
|
||||
|
||||
foreach (var secs in secondsList.OrderBy(p => p))
|
||||
{
|
||||
var displayText = TimeCode.FromSeconds(secs).ToDisplayString();
|
||||
var item = new ToolStripMenuItem() { Text = displayText, Tag = secs };
|
||||
item.Click += Item_Click;
|
||||
contextMenuStripDefaultOffsets.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void Item_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is ToolStripMenuItem item)
|
||||
{
|
||||
VideoOffset = TimeCode.FromSeconds((long)item.Tag);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
VideoOffset = timeUpDownVideoPosition.TimeCode;
|
||||
@ -65,5 +102,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
Configuration.Settings.Tools.VideoOffsetKeepTimeCodes = checkBoxKeepTimeCodes.Checked;
|
||||
}
|
||||
|
||||
private void buttonPickOffset_Click(object sender, EventArgs e)
|
||||
{
|
||||
var coordinates = buttonPickOffset.PointToClient(Cursor.Position);
|
||||
contextMenuStripDefaultOffsets.Show(buttonPickOffset, coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="contextMenuStripDefaultOffsets.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user