From 74a19bb4d85cb1cac49b0dbed207831f91cd7ed4 Mon Sep 17 00:00:00 2001 From: niksedk Date: Sat, 14 Oct 2023 18:32:45 +0200 Subject: [PATCH] SUP editor: Add option 'Select unforced lines' - thx manuelrn :) Fix #7510 --- LanguageBaseEnglish.xml | 1 + src/ui/Forms/BinaryEdit/BinEdit.Designer.cs | 55 ++++++++++++--------- src/ui/Forms/BinaryEdit/BinEdit.cs | 31 +++++++++++- src/ui/Logic/Language.cs | 1 + src/ui/Logic/LanguageDeserializer.cs | 3 ++ src/ui/Logic/LanguageStructure.cs | 1 + 6 files changed, 68 insertions(+), 24 deletions(-) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index f34ee0fbe..1060ff1ad 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -489,6 +489,7 @@ We leverage the intrinsic rhythm of the image. Bottom align selected lines (keep horizontal position) Toggle "Forced" for selected lines Select forced lines + Select non-forced lines Size: {0}x{1} Set aspect ratio 1:1 Adjust brightness diff --git a/src/ui/Forms/BinaryEdit/BinEdit.Designer.cs b/src/ui/Forms/BinaryEdit/BinEdit.Designer.cs index 0222d34a0..e5cea5053 100644 --- a/src/ui/Forms/BinaryEdit/BinEdit.Designer.cs +++ b/src/ui/Forms/BinaryEdit/BinEdit.Designer.cs @@ -30,8 +30,8 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit 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(); + Nikse.SubtitleEdit.Core.Common.TimeCode timeCode3 = new Nikse.SubtitleEdit.Core.Common.TimeCode(); + Nikse.SubtitleEdit.Core.Common.TimeCode timeCode4 = new Nikse.SubtitleEdit.Core.Common.TimeCode(); this.groupBoxCurrent = new System.Windows.Forms.GroupBox(); this.labelSyntaxError = new Nikse.SubtitleEdit.Controls.NikseLabel(); this.buttonSetText = new System.Windows.Forms.Button(); @@ -131,6 +131,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.columnHeaderDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeaderText = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.timerSyntaxColor = new System.Windows.Forms.Timer(this.components); + this.toolStripMenuItemSelectNonForced = new System.Windows.Forms.ToolStripMenuItem(); this.groupBoxCurrent.SuspendLayout(); this.groupBoxVideoInfo.SuspendLayout(); this.contextMenuStripListView.SuspendLayout(); @@ -350,14 +351,14 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.timeUpDownEndTime.Size = new System.Drawing.Size(111, 23); this.timeUpDownEndTime.TabIndex = 3; this.timeUpDownEndTime.TabStop = false; - 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.timeUpDownEndTime.TimeCode = timeCode1; + timeCode3.Hours = 0; + timeCode3.Milliseconds = 0; + timeCode3.Minutes = 0; + timeCode3.Seconds = 0; + timeCode3.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode3.TotalMilliseconds = 0D; + timeCode3.TotalSeconds = 0D; + this.timeUpDownEndTime.TimeCode = timeCode3; this.timeUpDownEndTime.UseVideoOffset = false; // // timeUpDownStartTime @@ -382,14 +383,14 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.timeUpDownStartTime.Size = new System.Drawing.Size(111, 23); this.timeUpDownStartTime.TabIndex = 1; this.timeUpDownStartTime.TabStop = false; - 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.timeUpDownStartTime.TimeCode = timeCode2; + timeCode4.Hours = 0; + timeCode4.Milliseconds = 0; + timeCode4.Minutes = 0; + timeCode4.Seconds = 0; + timeCode4.TimeSpan = System.TimeSpan.Parse("00:00:00"); + timeCode4.TotalMilliseconds = 0D; + timeCode4.TotalSeconds = 0D; + this.timeUpDownStartTime.TimeCode = timeCode4; this.timeUpDownStartTime.UseVideoOffset = false; // // label1 @@ -447,6 +448,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.comboBoxFrameRate.Size = new System.Drawing.Size(74, 21); this.comboBoxFrameRate.TabIndex = 5; this.comboBoxFrameRate.TabStop = false; + this.comboBoxFrameRate.UsePopupWindow = false; this.comboBoxFrameRate.SelectedIndexChanged += new System.EventHandler(this.comboBoxFrameRate_SelectedIndexChanged); this.comboBoxFrameRate.SelectedValueChanged += new System.EventHandler(this.comboBoxFrameRate_SelectedValueChanged); // @@ -557,6 +559,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.bottomAlignSelectedLinesToolStripMenuItem, this.toolStripSeparator9, this.toggleforcedForSelectedLinesToolStripMenuItem, + this.toolStripMenuItemSelectNonForced, this.selectOnlyForcedLinesToolStripMenuItem, this.toolStripSeparator7, this.resizeImagesForSelectedLinesToolStripMenuItem, @@ -570,7 +573,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.toolStripSeparatorInsertSub, this.insertSubtitleAfterThisLineToolStripMenuItem}); this.contextMenuStripListView.Name = "contextMenuStripListView"; - this.contextMenuStripListView.Size = new System.Drawing.Size(377, 408); + this.contextMenuStripListView.Size = new System.Drawing.Size(377, 452); this.contextMenuStripListView.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStripListView_Opening); // // deleteToolStripMenuItem @@ -924,21 +927,21 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit // adjustAllTimesToolStripMenuItem // this.adjustAllTimesToolStripMenuItem.Name = "adjustAllTimesToolStripMenuItem"; - this.adjustAllTimesToolStripMenuItem.Size = new System.Drawing.Size(172, 22); + this.adjustAllTimesToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.adjustAllTimesToolStripMenuItem.Text = "Adjust all times"; this.adjustAllTimesToolStripMenuItem.Click += new System.EventHandler(this.adjustAllTimesToolStripMenuItem_Click); // // changeFrameRateToolStripMenuItem // this.changeFrameRateToolStripMenuItem.Name = "changeFrameRateToolStripMenuItem"; - this.changeFrameRateToolStripMenuItem.Size = new System.Drawing.Size(172, 22); + this.changeFrameRateToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.changeFrameRateToolStripMenuItem.Text = "Change frame rate"; this.changeFrameRateToolStripMenuItem.Click += new System.EventHandler(this.changeFrameRateToolStripMenuItem_Click); // // changeSpeedToolStripMenuItem // this.changeSpeedToolStripMenuItem.Name = "changeSpeedToolStripMenuItem"; - this.changeSpeedToolStripMenuItem.Size = new System.Drawing.Size(172, 22); + this.changeSpeedToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.changeSpeedToolStripMenuItem.Text = "Change speed"; this.changeSpeedToolStripMenuItem.Click += new System.EventHandler(this.changeSpeedToolStripMenuItem_Click); // @@ -1136,6 +1139,13 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit this.timerSyntaxColor.Interval = 250; this.timerSyntaxColor.Tick += new System.EventHandler(this.timerSyntaxColor_Tick); // + // toolStripMenuItemSelectNonForced + // + this.toolStripMenuItemSelectNonForced.Name = "toolStripMenuItemSelectNonForced"; + this.toolStripMenuItemSelectNonForced.Size = new System.Drawing.Size(376, 22); + this.toolStripMenuItemSelectNonForced.Text = "Select only non-forced lines"; + this.toolStripMenuItemSelectNonForced.Click += new System.EventHandler(this.toolStripMenuItemSelectNonForced_Click); + // // BinEdit // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1277,5 +1287,6 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit private Nikse.SubtitleEdit.Controls.NikseLabel labelSyntaxError; private System.Windows.Forms.ToolStripSeparator toolStripSeparator11; private System.Windows.Forms.ToolStripMenuItem saveImageAsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSelectNonForced; } } \ No newline at end of file diff --git a/src/ui/Forms/BinaryEdit/BinEdit.cs b/src/ui/Forms/BinaryEdit/BinEdit.cs index 941d2ebd1..5020e0285 100644 --- a/src/ui/Forms/BinaryEdit/BinEdit.cs +++ b/src/ui/Forms/BinaryEdit/BinEdit.cs @@ -325,6 +325,7 @@ namespace Nikse.SubtitleEdit.Forms.BinaryEdit bottomAlignSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.BottomAlignSelectedLines; toggleforcedForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ToggleForcedSelectedLines; selectOnlyForcedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.SelectForcedLines; + toolStripMenuItemSelectNonForced.Text = LanguageSettings.Current.BinEdit.SelectNonForcedLines; resizeImagesForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ResizeBitmapsForSelectedLines; colorSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ChangeColorForSelectedLines; changeBrightnessForSelectedLinesToolStripMenuItem.Text = LanguageSettings.Current.BinEdit.ChangeBrightnessForSelectedLines; @@ -2655,6 +2656,7 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + insertSubtitleAfterThisLineToolStripMenuItem.Visible = selectedCount == 1 && subtitleListView1.SelectedItems[0].Index == subtitleListView1.Items.Count - 1; selectOnlyForcedLinesToolStripMenuItem.Visible = _extra.Any(p => p.IsForced); + toolStripMenuItemSelectNonForced.Visible = _extra.Any(p => p.IsForced); quickOCRTextsforOverviewOnlyToolStripMenuItem.Visible = File.Exists(_nOcrFileName); } @@ -3949,8 +3951,8 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + subtitleListView1.SelectedIndexChanged -= subtitleListView1_SelectedIndexChanged; subtitleListView1.SelectedIndices.Clear(); System.Collections.IList list = subtitleListView1.Items; - bool first = true; - for (int i = 0; i < list.Count; i++) + var first = true; + for (var i = 0; i < list.Count; i++) { var item = (ListViewItem)list[i]; if (_extra[i].IsForced) @@ -4113,5 +4115,30 @@ $DROP=[DROPVALUE]" + Environment.NewLine + Environment.NewLine + bmp.Dispose(); } } + + private void toolStripMenuItemSelectNonForced_Click(object sender, EventArgs e) + { + subtitleListView1.BeginUpdate(); + subtitleListView1.SelectedIndexChanged -= subtitleListView1_SelectedIndexChanged; + subtitleListView1.SelectedIndices.Clear(); + System.Collections.IList list = subtitleListView1.Items; + var first = true; + for (var i = 0; i < list.Count; i++) + { + var item = (ListViewItem)list[i]; + if (!_extra[i].IsForced) + { + item.Selected = true; + if (first) + { + SelectIndexAndEnsureVisible(i); + first = false; + } + } + } + subtitleListView1.SelectedIndexChanged += subtitleListView1_SelectedIndexChanged; + subtitleListView1.EndUpdate(); + subtitleListView1_SelectedIndexChanged(null, null); + } } } diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 68c95b09c..497ad005b 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -679,6 +679,7 @@ namespace Nikse.SubtitleEdit.Logic BottomAlignSelectedLines = "Bottom align selected lines (keep horizontal position)", ToggleForcedSelectedLines = "Toggle \"Forced\" for selected lines", SelectForcedLines = "Select forced lines", + SelectNonForcedLines = "Select non-forced lines", SizeXY = "Size: {0}x{1}", SetAspectRatio11 = "Set aspect ratio 1:1", ChangeBrightnessTitle = "Adjust brightness", diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index 7b6075903..f4451dff6 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -1297,6 +1297,9 @@ namespace Nikse.SubtitleEdit.Logic case "BinEdit/SelectForcedLines": language.BinEdit.SelectForcedLines = reader.Value; break; + case "BinEdit/SelectNonForcedLines": + language.BinEdit.SelectNonForcedLines = reader.Value; + break; case "BinEdit/SizeXY": language.BinEdit.SizeXY = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 23a963146..752d8f7ef 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -502,6 +502,7 @@ public string BottomAlignSelectedLines { get; set; } public string ToggleForcedSelectedLines { get; set; } public string SelectForcedLines { get; set; } + public string SelectNonForcedLines { get; set; } public string SizeXY { get; set; } public string SetAspectRatio11 { get; set; } public string ChangeBrightnessTitle { get; set; }