diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 88b6eab80..3e6fc3edb 100644 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -266,12 +266,9 @@ Please do not file a bug report with Anki.\n\n""") def keyPressEvent(self, evt): "Show answer on RET or register answer." - if evt.key() in (Qt.Key_Up,Qt.Key_Down,Qt.Key_Left,Qt.Key_Right, Qt.Key_PageUp,Qt.Key_PageDown): - mf = self.bodyView.body.page().currentFrame() - if evt.key() == Qt.Key_Up: mf.evaluateJavaScript("window.scrollBy(0,-20)") elif evt.key() == Qt.Key_Down: @@ -288,10 +285,8 @@ Please do not file a bug report with Anki.\n\n""") mf.evaluateJavaScript("window.scrollBy(0,%d)" % int(0.9*self.bodyView.body.size(). height())) - evt.accept() return - if self.state == "showQuestion": if evt.key() in (Qt.Key_Enter, Qt.Key_Return): @@ -304,6 +299,11 @@ Please do not file a bug report with Anki.\n\n""") num=int(key) evt.accept() return self.cardAnswered(num) + elif self.state == "studyScreen": + if evt.key() in (Qt.Key_Enter, + Qt.Key_Return): + evt.accept() + return self.onStartReview() evt.ignore() def cardAnswered(self, quality): @@ -436,9 +436,13 @@ new: self.mainWin.buttonStack.hide() def showAnswerButton(self): - self.mainWin.buttonStack.setCurrentIndex(0) + if self.currentCard.cardModel.typeAnswer: + self.mainWin.buttonStack.setCurrentIndex(4) + self.mainWin.typeAnswerField.selectAll() + else: + self.mainWin.buttonStack.setCurrentIndex(0) + self.mainWin.showAnswerButton.setFocus() self.mainWin.buttonStack.show() - self.mainWin.showAnswerButton.setFocus() def showEaseButtons(self): self.updateEaseButtons() diff --git a/ankiqt/ui/modelproperties.py b/ankiqt/ui/modelproperties.py index fbb6fb086..31b34a11d 100644 --- a/ankiqt/ui/modelproperties.py +++ b/ankiqt/ui/modelproperties.py @@ -293,6 +293,7 @@ class ModelProperties(QDialog): self.dialog.cardAnswer.setPlainText(card.aformat.replace("
", "\n")) self.dialog.questionInAnswer.setChecked(card.questionInAnswer) self.dialog.allowEmptyAnswer.setChecked(card.allowEmptyAnswer) + self.dialog.typeAnswer.setChecked(card.typeAnswer) self.updateToggleButtonText(card) def enableCardMoveButtons(self): @@ -329,6 +330,7 @@ class ModelProperties(QDialog): changed = changed or changed2 self.updateField(card, 'questionInAnswer', self.dialog.questionInAnswer.isChecked()) self.updateField(card, 'allowEmptyAnswer', self.dialog.allowEmptyAnswer.isChecked()) + self.updateField(card, 'typeAnswer', self.dialog.typeAnswer.isChecked()) if changed: # need to generate all question/answers for this card self.deck.updateCardsFromModel(self.m) diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index 33e918f87..17f5ee12f 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -124,11 +124,11 @@ class View(object): def center(self, str, height=40): if not self.main.config['splitQA']: - return str - return ''' -
\ + return "
" + str + "
" + return '''\ +
\
\ -
%s
''' % (height, str) +
%s
''' % (height, str) def drawQuestion(self, nosound=False): "Show the question." @@ -146,6 +146,17 @@ class View(object): def drawAnswer(self): "Show the answer." a = self.main.currentCard.htmlAnswer() + if self.main.currentCard.cardModel.typeAnswer: + cor = stripHTML(self.main.currentCard.answer) + given = unicode(self.main.mainWin.typeAnswerField.text()) + res = [] + for (i, c) in enumerate(given): + if c == cor[i]: + res.append("%s" % c) + else: + res.append("%s" % c) + a += "
" + (_("You typed:
") + + "".join(res)) + "
" self.write(self.center('' + self.mungeQA(self.main.deck, a))) if self.state != self.oldState: diff --git a/designer/main.ui b/designer/main.ui index bf8b1af18..b092fab4c 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -449,7 +449,7 @@ - 4 + 5 @@ -697,7 +697,7 @@ - PushButton + Review @@ -712,6 +712,46 @@ 49 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 2 + + + + + + + + + 12 + + + + Type answer and hit enter + + + + + + + + + 0 + 0 + 542 + 49 + + diff --git a/designer/modelproperties.ui b/designer/modelproperties.ui index b4ecbca69..7a51394e9 100644 --- a/designer/modelproperties.ui +++ b/designer/modelproperties.ui @@ -490,6 +490,13 @@ + + + + Ask me to type in the answer + + + @@ -539,6 +546,7 @@ cardAnswer questionInAnswer allowEmptyAnswer + typeAnswer buttonBox