From 8d8e47193cba949107802fdcb84a016c62a560c2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 11 Feb 2013 09:33:46 +0100 Subject: [PATCH] fixed bug 1047995 by reimplementing the keyPressEvent Fixes: https://launchpad.net/bugs/1047995 --- openlp/plugins/songs/forms/editsongform.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index abd45fe9a..827238145 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -132,6 +132,27 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.findVerseSplit = re.compile(u'---\[\]---\n', re.UNICODE) self.whitespace = re.compile(r'\W+', re.UNICODE) + + def keyPressEvent(self, event): + """ + Reimplement the keyPressEvent to react on Return/Enter keys. When some + combo boxes have focus we do not want dialog's default action be + triggered but instead our own. + + ``event`` + A QtGui.QKeyEvent event. + """ + if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return): + if self.authorsComboBox.hasFocus() and \ + self.authorsComboBox.currentText(): + self.onAuthorAddButtonClicked() + return + if self.topicsComboBox.hasFocus() and \ + self.topicsComboBox.currentText(): + self.onTopicAddButtonClicked() + return + QtGui.QDialog.keyPressEvent(self, event) + def initialise(self): self.verseEditButton.setEnabled(False) self.verseDeleteButton.setEnabled(False)