mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
make sure type answer box uses same font
This commit is contained in:
parent
d6df4f643b
commit
907343b83b
3 changed files with 19 additions and 9 deletions
|
@ -112,7 +112,6 @@ class Config(dict):
|
||||||
'syncOnProgramOpen': True,
|
'syncOnProgramOpen': True,
|
||||||
'syncPassword': "",
|
'syncPassword': "",
|
||||||
'syncUsername': "",
|
'syncUsername': "",
|
||||||
'typeAnswerFontSize': 20,
|
|
||||||
}
|
}
|
||||||
# disable sync on deck load when upgrading
|
# disable sync on deck load when upgrading
|
||||||
if not self.has_key("syncOnProgramOpen"):
|
if not self.has_key("syncOnProgramOpen"):
|
||||||
|
|
|
@ -636,12 +636,6 @@ counts are %d %d %d
|
||||||
self.typeAnswerField = QLineEditNoUndo(self)
|
self.typeAnswerField = QLineEditNoUndo(self)
|
||||||
self.typeAnswerField.setObjectName("typeAnswerField")
|
self.typeAnswerField.setObjectName("typeAnswerField")
|
||||||
self.typeAnswerField.setFixedWidth(351)
|
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 = QVBoxLayout()
|
||||||
vbox.setSpacing(0)
|
vbox.setSpacing(0)
|
||||||
vbox.setContentsMargins(0,0,0,0)
|
vbox.setContentsMargins(0,0,0,0)
|
||||||
|
|
|
@ -150,9 +150,10 @@ class View(object):
|
||||||
if (self.state != self.oldState and not nosound
|
if (self.state != self.oldState and not nosound
|
||||||
and self.main.config['autoplaySounds']):
|
and self.main.config['autoplaySounds']):
|
||||||
playFromText(q)
|
playFromText(q)
|
||||||
|
if self.main.currentCard.cardModel.typeAnswer:
|
||||||
|
self.adjustInputFont()
|
||||||
|
|
||||||
def calculateOkBadStyle(self):
|
def getFont(self):
|
||||||
"Precalculates styles for correct and incorrect part of answer"
|
|
||||||
sz = 20
|
sz = 20
|
||||||
fn = u"Arial"
|
fn = u"Arial"
|
||||||
for fm in self.main.currentCard.fact.model.fieldModels:
|
for fm in self.main.currentCard.fact.model.fieldModels:
|
||||||
|
@ -160,6 +161,22 @@ class View(object):
|
||||||
sz = fm.quizFontSize or sz
|
sz = fm.quizFontSize or sz
|
||||||
fn = fm.quizFontFamily or fn
|
fn = fm.quizFontFamily or fn
|
||||||
break
|
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;"
|
st = "background: %s; color: #000; font-size: %dpx; font-family: %s;"
|
||||||
self.styleOk = st % (passedCharColour, sz, fn)
|
self.styleOk = st % (passedCharColour, sz, fn)
|
||||||
self.styleBad = st % (failedCharColour, sz, fn)
|
self.styleBad = st % (failedCharColour, sz, fn)
|
||||||
|
|
Loading…
Reference in a new issue