From d9842e5a306d7d4ebe623ff55f88c4325b0529d3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 3 Dec 2008 21:31:45 +0900 Subject: [PATCH] add divider to main interface, make it neater --- ankiqt/config.py | 1 + ankiqt/ui/view.py | 36 +++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ankiqt/config.py b/ankiqt/config.py index 1e93059e7..f500cc4e1 100644 --- a/ankiqt/config.py +++ b/ankiqt/config.py @@ -66,6 +66,7 @@ class Config(dict): 'showSuspendedCards': True, 'simpleToolbar': True, 'scrollToAnswer': True, + 'qaDivider': True, } for (k,v) in fields.items(): if not self.has_key(k): diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index e136544c2..35c651ce4 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -48,18 +48,23 @@ class View(object): return self.clearWindow() self.setBackgroundColour() + self.haveTop = (self.main.lastCard and ( + self.main.config['showLastCardContent'] or + self.main.config['showLastCardInterval'])) + self.drawRule = (self.main.config['qaDivider'] and + not self.main.currentCard.cardModel.questionInAnswer) if not self.main.deck.isEmpty(): - if not self.main.lastCard or ( - not self.main.config['showLastCardContent'] and - not self.main.config['showLastCardInterval']): - self.buffer += "
" - else: + if self.haveTop: self.drawTopSection() if self.state == "showQuestion": self.drawQuestion() + if self.drawRule: + self.write("
") elif self.state == "showAnswer": if not self.main.currentCard.cardModel.questionInAnswer: self.drawQuestion(nosound=True) + if self.drawRule: + self.write("
") self.drawAnswer() elif self.state == "deckEmpty": self.drawWelcomeMessage() @@ -79,7 +84,6 @@ class View(object): color = ("; color: " + self.main.config[base + "Colour"]) s += ('.%s {font-family: "%s"; font-size: %spx%s}\n' % (base, family, size, color)) - # standard margins s += "" return s @@ -92,7 +96,10 @@ class View(object): def flush(self): "Write the current HTML buffer to the screen." - self.body.setHtml(self.addStyles() + '
' + self.buffer + "
") + txt = (self.addStyles() + ''' +
''' + + self.buffer + '
') + self.body.setHtml(txt) def write(self, text): if type(text) != types.UnicodeType: @@ -110,17 +117,28 @@ class View(object): # Question and answer ########################################################################## + def center(self, str, height=45): + return ''' +
+
+
%s
''' % (height, str) + def drawQuestion(self, nosound=False): "Show the question." q = self.main.currentCard.htmlQuestion() - self.write(mungeQA(self.main.deck, q)) + if self.haveTop: + height = 35 + else: + height = 45 + self.write(self.center(mungeQA(self.main.deck, q), height)) if self.state != self.oldState and not nosound: playFromText(q) def drawAnswer(self): "Show the answer." a = self.main.currentCard.htmlAnswer() - self.write('' + mungeQA(self.main.deck, a)) + self.write(self.center('' + + mungeQA(self.main.deck, a))) if self.state != self.oldState: playFromText(a)