Only disable "Search in" when no original - OmrSi :)

Related to #6832
This commit is contained in:
niksedk 2023-04-18 06:25:28 +02:00
parent c4c18b8d63
commit 90381af1d3
5 changed files with 25 additions and 4 deletions

View File

@ -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)

View File

@ -9896,5 +9896,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
throw new NotImplementedException();
}
public bool GetAllowReplaceInOriginal()
{
return false;
}
}
}

View File

@ -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);

View File

@ -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;
}
}
}

View File

@ -12,5 +12,6 @@ namespace Nikse.SubtitleEdit.Logic
void ReplaceDialogReplace(FindReplaceDialogHelper findReplaceDialogHelper);
void ReplaceDialogReplaceAll(FindReplaceDialogHelper findReplaceDialogHelper);
void ReplaceDialogClose();
bool GetAllowReplaceInOriginal();
}
}