make sure type answer box uses same font

This commit is contained in:
Damien Elmes 2011-02-21 07:03:50 +09:00
parent d6df4f643b
commit 907343b83b
3 changed files with 19 additions and 9 deletions

View file

@ -112,7 +112,6 @@ class Config(dict):
'syncOnProgramOpen': True,
'syncPassword': "",
'syncUsername': "",
'typeAnswerFontSize': 20,
}
# disable sync on deck load when upgrading
if not self.has_key("syncOnProgramOpen"):

View file

@ -636,12 +636,6 @@ counts are %d %d %d
self.typeAnswerField = QLineEditNoUndo(self)
self.typeAnswerField.setObjectName("typeAnswerField")
self.typeAnswerField.setFixedWidth(351)
f = QFont()
f.setPixelSize(self.config['typeAnswerFontSize'])
self.typeAnswerField.setFont(f)
# add some extra space as layout is wrong on osx
self.typeAnswerField.setFixedHeight(
self.typeAnswerField.sizeHint().height() + 10)
vbox = QVBoxLayout()
vbox.setSpacing(0)
vbox.setContentsMargins(0,0,0,0)

View file

@ -150,9 +150,10 @@ class View(object):
if (self.state != self.oldState and not nosound
and self.main.config['autoplaySounds']):
playFromText(q)
if self.main.currentCard.cardModel.typeAnswer:
self.adjustInputFont()
def calculateOkBadStyle(self):
"Precalculates styles for correct and incorrect part of answer"
def getFont(self):
sz = 20
fn = u"Arial"
for fm in self.main.currentCard.fact.model.fieldModels:
@ -160,6 +161,22 @@ class View(object):
sz = fm.quizFontSize or sz
fn = fm.quizFontFamily or fn
break
return (fn, sz)
def adjustInputFont(self):
(fn, sz) = self.getFont()
f = QFont()
f.setFamily(fn)
f.setPixelSize(sz)
self.main.typeAnswerField.setFont(f)
# add some extra space as layout is wrong on osx
self.main.typeAnswerField.setFixedHeight(
self.main.typeAnswerField.sizeHint().height() + 10)
def calculateOkBadStyle(self):
"Precalculates styles for correct and incorrect part of answer"
(fn, sz) = self.getFont()
st = "background: %s; color: #000; font-size: %dpx; font-family: %s;"
self.styleOk = st % (passedCharColour, sz, fn)
self.styleBad = st % (failedCharColour, sz, fn)