From 1072f8c5b58c9b3939a2078442826c7e603dac2a Mon Sep 17 00:00:00 2001 From: jupfi Date: Thu, 13 Jul 2023 08:41:30 +0200 Subject: [PATCH] Implemented event name checks. --- src/nqrduck_pulseprogrammer/view.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/nqrduck_pulseprogrammer/view.py b/src/nqrduck_pulseprogrammer/view.py index 38e5945..f5cc85f 100644 --- a/src/nqrduck_pulseprogrammer/view.py +++ b/src/nqrduck_pulseprogrammer/view.py @@ -216,7 +216,7 @@ class AddEventDialog(QDialog): QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel, self, ) - self.buttons.accepted.connect(self.accept) + self.buttons.accepted.connect(self.check_input) self.buttons.rejected.connect(self.reject) self.layout.addWidget(self.label) @@ -224,6 +224,14 @@ class AddEventDialog(QDialog): self.layout.addWidget(self.buttons) def get_name(self): - return self.name_input.text() + return self.name_input.text() - + def check_input(self): + # Make sure that name is not empty and that event name doesn't already exist. + if self.name_input.text() == "": + self.label.setText("Please enter a name for the event.") + elif self.name_input.text() in self.parent().module.model.pulse_sequence.events: + self.label.setText("Event name already exists. Please enter a different name.") + else: + self.accept() + \ No newline at end of file