UI: ProgramEditDialog: Simplify validateFields()

This commit is contained in:
Nodir Temirkhodjaev 2024-01-01 14:38:26 +03:00
parent 0f5945de50
commit d2b577d3b2

View File

@ -561,17 +561,14 @@ bool ProgramEditDialog::saveMulti(App &app)
bool ProgramEditDialog::validateFields() const
{
if (isWildcard()) {
if (m_editWildcard->isEmpty()) {
m_editWildcard->setFocus();
const bool isPathEmpty =
isWildcard() ? m_editWildcard->isEmpty() : m_editPath->text().isEmpty();
if (isPathEmpty) {
QWidget *c = isWildcard() ? static_cast<QWidget *>(m_editWildcard)
: static_cast<QWidget *>(m_editPath);
c->setFocus();
return false;
}
} else {
if (m_editPath->text().isEmpty()) {
m_editPath->setFocus();
return false;
}
}
if (m_editName->text().isEmpty()) {
m_editName->setFocus();