From ff2d1d19645336b52afb9e1d7f64cb2e7ee3f913 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 23 Mar 2009 09:47:07 +0900 Subject: [PATCH] change tab order so 'add' comes after tags, make add default except in tags --- ankiqt/ui/addcards.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ankiqt/ui/addcards.py b/ankiqt/ui/addcards.py index 5e8b30ca3..3363fa2ca 100644 --- a/ankiqt/ui/addcards.py +++ b/ankiqt/ui/addcards.py @@ -56,7 +56,6 @@ class AddCards(QDialog): self.addButton.setToolTip(_("Add (shortcut: command+return)")) else: self.addButton.setToolTip(_("Add (shortcut: ctrl+return)")) - self.addButton.setAutoDefault(False) s = QShortcut(QKeySequence(_("Ctrl+Enter")), self) s.connect(s, SIGNAL("activated()"), self.addButton, SLOT("click()")) self.connect(self.addButton, SIGNAL("clicked()"), self.addCards) @@ -95,6 +94,7 @@ class AddCards(QDialog): fact.tags = self.parent.deck.lastTags # set the new fact self.editor.setFact(fact, check=True) + self.setTabOrder(self.editor.tags, self.addButton) def addCards(self): # make sure updated @@ -131,6 +131,14 @@ question or answer on all cards."""), parent=self) self.editor.tags.addTags(parseTags(self.parent.deck.lastTags)) self.maybeSave() + def keyPressEvent(self, evt): + "Show answer on RET or register answer." + if (evt.key() in (Qt.Key_Enter, Qt.Key_Return) + and self.editor.tags.hasFocus()): + evt.accept() + return + return QDialog.keyPressEvent(self, evt) + def closeEvent(self, evt): if self.onClose(): evt.accept()