From 96e3cf30aa6c5f83e38b4ee02ce0679d86b46b11 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 31 Mar 2011 16:38:39 +0900 Subject: [PATCH] fixed the rest of the templates tab --- aqt/clayout.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/aqt/clayout.py b/aqt/clayout.py index e860eb76c..8c39cb710 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -184,19 +184,17 @@ class CardLayout(QDialog): def saveCard(self): if self.updatingCards: return - card = self.card.cardModel - card.questionAlign = self.form.alignment.currentIndex() - card.lastFontColour = unicode( + t = self.card.template() + t['align'] = self.form.alignment.currentIndex() + t['bg'] = unicode( self.form.background.palette().window().color().name()) - card.questionInAnswer = self.form.questionInAnswer.isChecked() - card.allowEmptyAnswer = self.form.allowEmptyAnswer.isChecked() + t['hideQ'] = self.form.questionInAnswer.isChecked() + t['emptyAns'] = self.form.allowEmptyAnswer.isChecked() idx = self.form.typeAnswer.currentIndex() if not idx: - card.typeAnswer = u"" + t['typeAns'] = None else: - card.typeAnswer = self.typeFieldNames[idx-1] - card.model.setModified() - self.deck.flushMod() + t['typeAns'] = idx-1 self.renderPreview() def chooseColour(self, button, type="field"): @@ -214,9 +212,11 @@ class CardLayout(QDialog): c = self.card styles = self.model.genCSS() self.form.preview.setHtml( - ('%s' % getBase(self.deck, c)) + + ('%s' % + (getBase(self.deck, c), c.cssClass())) + "" + mungeQA(c.q(reload=True)) + + self.maybeTextInput() + "
" + mungeQA(c.a()) + "") @@ -226,8 +226,14 @@ class CardLayout(QDialog): playFromText(c.a()) self.playedAudio[c.id] = True + def maybeTextInput(self): + if self.card.template()['typeAns'] is not None: + return "
" + return "" + def reject(self): - return + return QDialog.reject(self) + self.fact.model.setModified() modified = False