def saveField(self, *args):
     if self.ignoreUpdate:
         return
     field = self.currentField
     if not field:
         return
     for type in ("quiz", "edit"):
         # family
         if self.fwidget("useFamily", type).isChecked():
             setattr(field, type + 'FontFamily', toCanonicalFont(unicode(
                 self.fwidget("fontFamily", type).currentFont().family())))
         else:
             setattr(field, type + 'FontFamily', None)
         # size
         if self.fwidget("useSize", type).isChecked():
             setattr(field, type + 'FontSize',
                     int(self.fwidget("fontSize", type).value()))
         else:
             setattr(field, type + 'FontSize', None)
         # colour
         if type == "quiz":
             if self.fwidget("useColour", type).isChecked():
                 w = self.fwidget("fontColour", type)
                 c = w.palette().window().color()
                 setattr(field, type + 'FontColour', str(c.name()))
             else:
                 setattr(field, type + 'FontColour', None)
         elif type == "edit":
             if self.dialog.rtl.isChecked():
                 field.features = u"rtl"
             else:
                 field.features = u""
     field.model.setModified()
     self.deck.flushMod()
     self.drawQuestionAndAnswer()
Esempio n. 2
0
 def saveField(self, *args):
     self.needFieldRebuild = True
     if self.updatingFields:
         return
     self.updatingFields = True
     field = self.field
     name = unicode(self.form.fieldName.text()) or _("Field")
     if field.name != name:
         oldVal = self.fact[field.name]
         self.deck.renameFieldModel(self.model, field, name)
         # the card models will have been updated
         self.readCard()
         # for add card case
         self.updateFact()
         self.fact[name] = oldVal
     field.unique = self.form.fieldUnique.isChecked()
     field.required = self.form.fieldRequired.isChecked()
     field.numeric = self.form.numeric.isChecked()
     field.quizFontFamily = toCanonicalFont(unicode(self.form.fontFamily.currentFont().family()))
     field.quizFontSize = int(self.form.fontSize.value())
     field.editFontSize = int(self.form.fontSizeEdit.value())
     field.quizFontColour = str(self.form.fontColour.palette().window().color().name())
     if self.form.rtl.isChecked():
         field.features = u"rtl"
     else:
         field.features = u""
     if self.form.preserveWhitespace.isChecked():
         field.editFontFamily = u"preserve"
     else:
         field.editFontFamily = u""
     field.model.setModified()
     self.deck.flushMod()
     self.renderPreview()
     self.fillFieldList()
     self.updatingFields = False
 def saveCard(self):
     if not self.card:
         return
     for type in ("question", "answer"):
         setattr(self.card, type + "FontFamily", toCanonicalFont(unicode(
             self.cwidget("Font", type).currentFont().family())))
         setattr(self.card, type + "FontSize", int(
             self.cwidget("Size", type).value()))
         setattr(self.card, type + "Align", int(
             self.cwidget("Align", type).currentIndex()))
         w = self.cwidget("Colour", type)
         c = w.palette().window().color()
         setattr(self.card, type + "FontColour", unicode(c.name()))
         self.card.model.setModified()
         self.deck.setModified()
     setattr(self.card, "lastFontColour", unicode(
         self.dialog.backgroundColour.palette().window().color().name()))
     self.drawQuestionAndAnswer()
Esempio n. 4
0
 def saveField(self, *args):
     self.needFieldRebuild = True
     if self.updatingFields:
         return
     self.updatingFields = True
     field = self.field
     name = unicode(self.form.fieldName.text()) or _("Field")
     if field.name != name:
         oldVal = self.fact[field.name]
         self.deck.renameFieldModel(self.model, field, name)
         # the card models will have been updated
         self.readCard()
         # for add card case
         self.updateFact()
         self.fact[name] = oldVal
     field.unique = self.form.fieldUnique.isChecked()
     field.required = self.form.fieldRequired.isChecked()
     field.numeric = self.form.numeric.isChecked()
     field.quizFontFamily = toCanonicalFont(
         unicode(self.form.fontFamily.currentFont().family()))
     field.quizFontSize = int(self.form.fontSize.value())
     field.editFontSize = int(self.form.fontSizeEdit.value())
     field.quizFontColour = str(
         self.form.fontColour.palette().window().color().name())
     if self.form.rtl.isChecked():
         field.features = u"rtl"
     else:
         field.features = u""
     if self.form.preserveWhitespace.isChecked():
         field.editFontFamily = u"preserve"
     else:
         field.editFontFamily = u""
     field.model.setModified()
     self.deck.flushMod()
     self.renderPreview()
     self.fillFieldList()
     self.updatingFields = False