Fix disabling of widgets for (simple) Search dialog

This allows to remove the calls to ButtonController::addReadonly,
which are placebo since 78ade7e6.
This commit is contained in:
Jean-Marc Lasgouttes 2020-12-03 15:31:35 +01:00
parent 37eb3cd961
commit 24b71d30d5

View File

@ -66,9 +66,6 @@ GuiSearch::GuiSearch(GuiView & lv)
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setCancel(buttonBox->button(QDialogButtonBox::Close)); bc().setCancel(buttonBox->button(QDialogButtonBox::Close));
bc().addReadOnly(replaceCO);
bc().addReadOnly(replacePB);
bc().addReadOnly(replaceallPB);
findCO->setCompleter(0); findCO->setCompleter(0);
replaceCO->setCompleter(0); replaceCO->setCompleter(0);
@ -80,6 +77,7 @@ GuiSearch::GuiSearch(GuiView & lv)
void GuiSearch::showEvent(QShowEvent * e) void GuiSearch::showEvent(QShowEvent * e)
{ {
findChanged();
findPB->setFocus(); findPB->setFocus();
findCO->lineEdit()->selectAll(); findCO->lineEdit()->selectAll();
GuiDialog::showEvent(e); GuiDialog::showEvent(e);
@ -88,15 +86,12 @@ void GuiSearch::showEvent(QShowEvent * e)
void GuiSearch::findChanged() void GuiSearch::findChanged()
{ {
if (findCO->currentText().isEmpty()) { bool const replace = !findCO->currentText().isEmpty() && !isBufferReadonly();
findPB->setEnabled(false); findPB->setEnabled(replace);
replacePB->setEnabled(false); replacePB->setEnabled(replace);
replaceallPB->setEnabled(false); replaceallPB->setEnabled(replace);
} else { replaceLA->setEnabled(replace);
findPB->setEnabled(true); replaceCO->setEnabled(replace);
replacePB->setEnabled(!isBufferReadonly());
replaceallPB->setEnabled(!isBufferReadonly());
}
} }