From f1eecd59590d5e21c6d8f1144de76faa1b190fbd Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 3 Apr 2024 20:15:14 +0200 Subject: [PATCH] Add back simple check_input method --- src/nqrduck_pulseprogrammer/view.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/nqrduck_pulseprogrammer/view.py b/src/nqrduck_pulseprogrammer/view.py index 8483df8..64b93af 100644 --- a/src/nqrduck_pulseprogrammer/view.py +++ b/src/nqrduck_pulseprogrammer/view.py @@ -787,11 +787,24 @@ class AddEventDialog(QDialog): Decimal: The duration value provided by the user, or 20""" return Decimal(self.duration_lineedit.text() or 20) + def check_input(self) -> None: + """Checks if the name and duration entered by the user is valid. If it is, the dialog is accepted. If not, the user is informed of the error.""" + if ( + self.duration_lineedit.validator.validate(self.duration_lineedit.text(), 0)[ + 0 + ] + == QValidator.State.Acceptable + and self.name_input.validator.validate(self.name_input.text(), 0)[0] + == QValidator.State.Acceptable + ): + self.accept() + class NameInputValidator(QValidator): """A validator for the name input field. This is used to validate the input of the QLineEdit widget. """ + def validate(self, value, position): """Validates the input value.