Test option related to #6813

This commit is contained in:
niksedk 2023-04-16 21:26:10 +02:00
parent 6b7e00b8f2
commit 31d4098b8e
3 changed files with 95 additions and 54 deletions

View File

@ -222,6 +222,7 @@ namespace Nikse.SubtitleEdit.Core.Common
public bool BatchConvertSortBy { get; set; }
public string BatchConvertSortByChoice { get; set; }
public bool BatchConvertOffsetTimeCodes { get; set; }
public bool BatchConvertScanFolderIncludeVideo { get; set; }
public string BatchConvertLanguage { get; set; }
public string BatchConvertFormat { get; set; }
public string BatchConvertAssStyles { get; set; }
@ -5143,6 +5144,12 @@ $HorzAlign = Center
settings.Tools.BatchConvertOffsetTimeCodes = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("BatchConvertScanFolderIncludeVideo");
if (subNode != null)
{
settings.Tools.BatchConvertScanFolderIncludeVideo = Convert.ToBoolean(subNode.InnerText, CultureInfo.InvariantCulture);
}
subNode = node.SelectSingleNode("BatchConvertLanguage");
if (subNode != null)
{
@ -10536,6 +10543,7 @@ $HorzAlign = Center
textWriter.WriteElementString("BatchConvertSortByChoice", settings.Tools.BatchConvertSortByChoice);
textWriter.WriteElementString("BatchConvertChangeFrameRate", settings.Tools.BatchConvertChangeFrameRate.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertOffsetTimeCodes", settings.Tools.BatchConvertOffsetTimeCodes.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertScanFolderIncludeVideo", settings.Tools.BatchConvertScanFolderIncludeVideo.ToString(CultureInfo.InvariantCulture));
textWriter.WriteElementString("BatchConvertLanguage", settings.Tools.BatchConvertLanguage);
textWriter.WriteElementString("BatchConvertFormat", settings.Tools.BatchConvertFormat);
textWriter.WriteElementString("BatchConvertAssStyles", settings.Tools.BatchConvertAssStyles);

View File

@ -31,7 +31,7 @@ namespace Nikse.SubtitleEdit.Forms
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode1 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
Nikse.SubtitleEdit.Core.Common.TimeCode timeCode2 = new Nikse.SubtitleEdit.Core.Common.TimeCode();
this.buttonConvert = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxConvertOptions = new System.Windows.Forms.GroupBox();
@ -42,6 +42,7 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripMenuItemSelectAll = new System.Windows.Forms.ToolStripMenuItem();
this.inverseSelectionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxChangeCasing = new System.Windows.Forms.GroupBox();
this.checkBoxProperCaseOnlyUpper = new System.Windows.Forms.CheckBox();
this.radioButtonProperCase = new System.Windows.Forms.RadioButton();
this.checkBoxOnlyAllUpper = new System.Windows.Forms.CheckBox();
this.checkBoxFixNames = new System.Windows.Forms.CheckBox();
@ -172,7 +173,7 @@ namespace Nikse.SubtitleEdit.Forms
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.labelStatus = new System.Windows.Forms.Label();
this.labelError = new System.Windows.Forms.Label();
this.checkBoxProperCaseOnlyUpper = new System.Windows.Forms.CheckBox();
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBoxConvertOptions.SuspendLayout();
this.contextMenuStripOptions.SuspendLayout();
this.groupBoxChangeCasing.SuspendLayout();
@ -330,6 +331,16 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxChangeCasing.TabStop = false;
this.groupBoxChangeCasing.Text = "Change casing to";
//
// checkBoxProperCaseOnlyUpper
//
this.checkBoxProperCaseOnlyUpper.AutoSize = true;
this.checkBoxProperCaseOnlyUpper.Location = new System.Drawing.Point(29, 176);
this.checkBoxProperCaseOnlyUpper.Name = "checkBoxProperCaseOnlyUpper";
this.checkBoxProperCaseOnlyUpper.Size = new System.Drawing.Size(182, 17);
this.checkBoxProperCaseOnlyUpper.TabIndex = 16;
this.checkBoxProperCaseOnlyUpper.Text = "Only change all upper case lines.";
this.checkBoxProperCaseOnlyUpper.UseVisualStyleBackColor = true;
//
// radioButtonProperCase
//
this.radioButtonProperCase.AutoSize = true;
@ -1146,14 +1157,14 @@ namespace Nikse.SubtitleEdit.Forms
this.timeUpDownAdjust.Name = "timeUpDownAdjust";
this.timeUpDownAdjust.Size = new System.Drawing.Size(113, 27);
this.timeUpDownAdjust.TabIndex = 1;
timeCode1.Hours = 0;
timeCode1.Milliseconds = 0;
timeCode1.Minutes = 0;
timeCode1.Seconds = 0;
timeCode1.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode1.TotalMilliseconds = 0D;
timeCode1.TotalSeconds = 0D;
this.timeUpDownAdjust.TimeCode = timeCode1;
timeCode2.Hours = 0;
timeCode2.Milliseconds = 0;
timeCode2.Minutes = 0;
timeCode2.Seconds = 0;
timeCode2.TimeSpan = System.TimeSpan.Parse("00:00:00");
timeCode2.TotalMilliseconds = 0D;
timeCode2.TotalSeconds = 0D;
this.timeUpDownAdjust.TimeCode = timeCode2;
this.timeUpDownAdjust.UseVideoOffset = false;
//
// labelHourMinSecMilliSecond
@ -1694,9 +1705,10 @@ namespace Nikse.SubtitleEdit.Forms
this.openContainingFolderToolStripMenuItem,
this.toolStripSeparator1,
this.convertMkvSettingsToolStripMenuItem,
this.toolStripMenuItemOcrEngine});
this.toolStripMenuItemOcrEngine,
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem});
this.contextMenuStripFiles.Name = "contextMenuStripStyles";
this.contextMenuStripFiles.Size = new System.Drawing.Size(400, 148);
this.contextMenuStripFiles.Size = new System.Drawing.Size(400, 192);
this.contextMenuStripFiles.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripFilesOpening);
//
// addFilesToolStripMenuItem
@ -1800,15 +1812,12 @@ namespace Nikse.SubtitleEdit.Forms
this.labelError.TabIndex = 10;
this.labelError.Text = "labelError";
//
// checkBoxProperCaseOnlyUpper
// alsoScanVideoFilesInSearchFolderslowToolStripMenuItem
//
this.checkBoxProperCaseOnlyUpper.AutoSize = true;
this.checkBoxProperCaseOnlyUpper.Location = new System.Drawing.Point(29, 176);
this.checkBoxProperCaseOnlyUpper.Name = "checkBoxProperCaseOnlyUpper";
this.checkBoxProperCaseOnlyUpper.Size = new System.Drawing.Size(182, 17);
this.checkBoxProperCaseOnlyUpper.TabIndex = 16;
this.checkBoxProperCaseOnlyUpper.Text = "Only change all upper case lines.";
this.checkBoxProperCaseOnlyUpper.UseVisualStyleBackColor = true;
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Name = "alsoScanVideoFilesInSearchFolderslowToolStripMenuItem";
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Size = new System.Drawing.Size(399, 22);
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Text = "Also scan video files in \"Search folder\" (slow)";
this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Click += new System.EventHandler(this.alsoScanVideoFilesInSearchFolderslowToolStripMenuItem_Click);
//
// BatchConvert
//
@ -2033,5 +2042,6 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.CheckBox checkBoxFixNames;
private System.Windows.Forms.RadioButton radioButtonProperCase;
private System.Windows.Forms.CheckBox checkBoxProperCaseOnlyUpper;
private System.Windows.Forms.ToolStripMenuItem alsoScanVideoFilesInSearchFolderslowToolStripMenuItem;
}
}

View File

@ -640,6 +640,7 @@ namespace Nikse.SubtitleEdit.Forms
}
SetMkvLanguageMenuItem();
alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Checked = Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo;
}
private void SetMkvLanguageMenuItem()
@ -3172,7 +3173,9 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private static readonly HashSet<string> SearchExtBlackList = new HashSet<string>
private HashSet<string> GetSearchExtBlackList()
{
var result = new HashSet<string>
{
".png",
".jpg",
@ -3186,9 +3189,6 @@ namespace Nikse.SubtitleEdit.Forms
".mpls",
".wav",
".mp3",
".avi",
".mpeg",
".mpg",
".tar",
".docx",
".pptx",
@ -3201,18 +3201,26 @@ namespace Nikse.SubtitleEdit.Forms
".rar",
".7z",
".zip",
".tar"
".tar",
".avi",
".mpeg",
".mpg",
};
return result;
}
private void ScanFiles(IEnumerable<string> fileNames)
{
var searchExtBlackList = GetSearchExtBlackList();
foreach (var fileName in fileNames)
{
labelStatus.Text = fileName;
try
{
var ext = Path.GetExtension(fileName).ToLowerInvariant();
if (!SearchExtBlackList.Contains(ext))
if (!searchExtBlackList.Contains(ext))
{
labelStatus.Refresh();
var fi = new FileInfo(fileName);
@ -3230,15 +3238,24 @@ namespace Nikse.SubtitleEdit.Forms
}
else if (ext == ".mkv")
{
// skip for now
if (Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo)
{
AddFromSearch(fileName, fi, "Matroska");
}
}
else if (ext == ".mks")
{
// skip for now
if (Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo)
{
AddFromSearch(fileName, fi, "Matroska");
}
}
else if (ext == ".mp4")
{
// skip for now
if (Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo)
{
AddFromSearch(fileName, fi, "MP4");
}
}
else
{
@ -3699,5 +3716,11 @@ namespace Nikse.SubtitleEdit.Forms
nOCRToolStripMenuItem.Checked = true;
tesseractToolStripMenuItem.Checked = false;
}
private void alsoScanVideoFilesInSearchFolderslowToolStripMenuItem_Click(object sender, EventArgs e)
{
Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo = !Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo;
alsoScanVideoFilesInSearchFolderslowToolStripMenuItem.Checked = Configuration.Settings.Tools.BatchConvertScanFolderIncludeVideo;
}
}
}