From 90381af1d3757d661d0f6ea3e5eb919c1914709d Mon Sep 17 00:00:00 2001 From: niksedk Date: Tue, 18 Apr 2023 06:25:28 +0200 Subject: [PATCH] Only disable "Search in" when no original - OmrSi :) Related to #6832 --- src/ui/Forms/Main.cs | 7 +++++++ src/ui/Forms/Ocr/VobSubOcr.cs | 5 +++++ src/ui/Forms/ReplaceDialog.Designer.cs | 1 + src/ui/Forms/ReplaceDialog.cs | 15 +++++++++++---- src/ui/Logic/IFindAndReplace.cs | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/ui/Forms/Main.cs b/src/ui/Forms/Main.cs index c10589467..a91bde623 100644 --- a/src/ui/Forms/Main.cs +++ b/src/ui/Forms/Main.cs @@ -6775,6 +6775,13 @@ namespace Nikse.SubtitleEdit.Forms Focus(); } + public bool GetAllowReplaceInOriginal() + { + return Configuration.Settings.General.AllowEditOfOriginalSubtitle + && _subtitleOriginal != null + && _subtitleOriginal.Paragraphs.Count > 0; + } + public void ListViewReplaceAll(ReplaceDialog replaceDialog, FindReplaceDialogHelper findHelper) { if (_findHelper == null) diff --git a/src/ui/Forms/Ocr/VobSubOcr.cs b/src/ui/Forms/Ocr/VobSubOcr.cs index 593d9a644..cefe304c3 100644 --- a/src/ui/Forms/Ocr/VobSubOcr.cs +++ b/src/ui/Forms/Ocr/VobSubOcr.cs @@ -9896,5 +9896,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr { throw new NotImplementedException(); } + + public bool GetAllowReplaceInOriginal() + { + return false; + } } } diff --git a/src/ui/Forms/ReplaceDialog.Designer.cs b/src/ui/Forms/ReplaceDialog.Designer.cs index a4739fd24..ec2e44d87 100644 --- a/src/ui/Forms/ReplaceDialog.Designer.cs +++ b/src/ui/Forms/ReplaceDialog.Designer.cs @@ -205,6 +205,7 @@ this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Replace"; + this.Activated += new System.EventHandler(this.ReplaceDialog_Activated); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ReplaceDialog_FormClosing); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FormReplaceDialog_KeyDown); this.ResumeLayout(false); diff --git a/src/ui/Forms/ReplaceDialog.cs b/src/ui/Forms/ReplaceDialog.cs index eab9314c5..e5097813b 100644 --- a/src/ui/Forms/ReplaceDialog.cs +++ b/src/ui/Forms/ReplaceDialog.cs @@ -70,11 +70,11 @@ namespace Nikse.SubtitleEdit.Forms result.FindType = FindType.RegEx; } - result.SearchOriginal = !comboBoxFindReplaceIn.Visible || + result.SearchOriginal = !comboBoxFindReplaceIn.Enabled || comboBoxFindReplaceIn.SelectedIndex == 0 || comboBoxFindReplaceIn.SelectedIndex == 2; - result.SearchTranslation = !comboBoxFindReplaceIn.Visible || + result.SearchTranslation = !comboBoxFindReplaceIn.Enabled || comboBoxFindReplaceIn.SelectedIndex == 0 || comboBoxFindReplaceIn.SelectedIndex == 1; @@ -139,8 +139,8 @@ namespace Nikse.SubtitleEdit.Forms checkBoxWholeWord.Checked = findHelper.FindReplaceType.WholeWord; } - labelFindReplaceIn.Visible = replaceInOriginal; - comboBoxFindReplaceIn.Visible = replaceInOriginal; + labelFindReplaceIn.Enabled = replaceInOriginal; + comboBoxFindReplaceIn.Enabled = replaceInOriginal; } private void ButtonReplaceClick(object sender, EventArgs e) @@ -285,5 +285,12 @@ namespace Nikse.SubtitleEdit.Forms { _findNext = false; } + + private void ReplaceDialog_Activated(object sender, EventArgs e) + { + var allowReplaceInOriginal = _findAndReplaceMethods.GetAllowReplaceInOriginal(); + labelFindReplaceIn.Enabled = allowReplaceInOriginal; + comboBoxFindReplaceIn.Enabled = allowReplaceInOriginal; + } } } diff --git a/src/ui/Logic/IFindAndReplace.cs b/src/ui/Logic/IFindAndReplace.cs index 1094802e1..f486c8b75 100644 --- a/src/ui/Logic/IFindAndReplace.cs +++ b/src/ui/Logic/IFindAndReplace.cs @@ -12,5 +12,6 @@ namespace Nikse.SubtitleEdit.Logic void ReplaceDialogReplace(FindReplaceDialogHelper findReplaceDialogHelper); void ReplaceDialogReplaceAll(FindReplaceDialogHelper findReplaceDialogHelper); void ReplaceDialogClose(); + bool GetAllowReplaceInOriginal(); } }