Advanced F&R: Improve code on Return key

This commit is contained in:
Juergen Spitzmueller 2021-02-17 09:51:09 +01:00
parent a2a5656d07
commit 50783d94a8

View File

@ -102,17 +102,13 @@ bool FindAndReplaceWidget::eventFilter(QObject * obj, QEvent * event)
case Qt::Key_Enter: case Qt::Key_Enter:
case Qt::Key_Return: { case Qt::Key_Return: {
// with shift we (temporarily) change search/replace direction bool const searchback = (e->modifiers() == Qt::ShiftModifier);
bool const searchback = searchbackCB->isChecked(); bool const replace = (obj == replace_work_area_);
if (e->modifiers() == Qt::ShiftModifier && !searchback) findAndReplace(searchback, replace);
searchbackCB->setChecked(true); if (replace)
replace_work_area_->setFocus();
if (obj == find_work_area_)
on_findNextPB_clicked();
else else
on_replacePB_clicked(); find_work_area_->setFocus();
// back to how it was
searchbackCB->setChecked(searchback);
return true; return true;
} }