From 1b3e956d5fc316c2a8013b23377711e54055c0a2 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 17 Dec 2011 17:25:31 +0900 Subject: [PATCH] add new css field to clayout --- aqt/clayout.py | 14 +++- aqt/editor.py | 3 +- aqt/reviewer.py | 3 +- designer/addmodel.ui | 2 +- designer/template.ui | 192 +++++++++++++++++++++++++++++++++++-------- 5 files changed, 175 insertions(+), 39 deletions(-) diff --git a/aqt/clayout.py b/aqt/clayout.py index 748b8e9df..1d9470e57 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Copyright: Damien Elmes # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html @@ -73,7 +74,12 @@ class CardLayout(QDialog): # template area tform = aqt.forms.template.Ui_Form() tform.setupUi(left) + tform.label1.setText(u" →") + tform.label2.setText(u" →") + tform.labelc1.setText(u" ↗") + tform.labelc2.setText(u" ↘") c(tform.front, SIGNAL("textChanged()"), self.saveCard) + c(tform.css, SIGNAL("textChanged()"), self.saveCard) c(tform.back, SIGNAL("textChanged()"), self.saveCard) l.addWidget(left, 5) # preview area @@ -144,6 +150,7 @@ Please create a new card first.""")) t = self.card.template() self.redrawing = True self.tab['tform'].front.setPlainText(t['qfmt']) + self.tab['tform'].css.setPlainText(t['css']) self.tab['tform'].back.setPlainText(t['afmt']) self.redrawing = False @@ -152,6 +159,8 @@ Please create a new card first.""")) return text = self.tab['tform'].front.toPlainText() self.card.template()['qfmt'] = text + text = self.tab['tform'].css.toPlainText() + self.card.template()['css'] = text text = self.tab['tform'].back.toPlainText() self.card.template()['afmt'] = text self.renderPreview() @@ -161,15 +170,14 @@ Please create a new card first.""")) def renderPreview(self): c = self.card - styles = "\n.cloze { font-weight: bold; color: blue; }" html = '''%s %s''' ti = self.maybeTextInput base = getBase(self.mw.col) self.tab['pform'].front.setHtml( - html % (base, styles, ti(mungeQA(c.q(reload=True))))) + html % (base, "", ti(mungeQA(c.q(reload=True))))) self.tab['pform'].back.setHtml( - html % (base, styles, ti(mungeQA(c.a()), 'a'))) + html % (base, "", ti(mungeQA(c.a()), 'a'))) def maybeTextInput(self, txt, type='q'): if type == 'q': diff --git a/aqt/editor.py b/aqt/editor.py index 20b9fef8e..3d0f48930 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -564,7 +564,7 @@ class Editor(object): def onCloze(self): # check that the model is set up for cloze deletion if 'cloze' not in self.note.model()['tmpls'][0]['qfmt']: - showInfo(_("Please select the cloze deletion note type first."), + showInfo(_("Cloze deletion requires a Cloze note type."), help="ClozeDeletion") return f = self.note.fields[self.currentField] @@ -643,6 +643,7 @@ class Editor(object): spc = QSpacerItem(5,10, QSizePolicy.Fixed) g.addItem(spc, n+1, 0) cb = QPushButton(_("+")) + cb.setShortcut(QKeySequence("F5")) cb.connect(cb, SIGNAL("clicked()"), self.onNewColour) cb.setFixedWidth(80) cb.setFixedHeight(16) diff --git a/aqt/reviewer.py b/aqt/reviewer.py index a26287718..422dde2f2 100644 --- a/aqt/reviewer.py +++ b/aqt/reviewer.py @@ -90,7 +90,7 @@ function _updateQA (q, answerMode) { typeans.focus(); } if (answerMode) { - window.location = "#answerStart"; + window.location = "#answer"; } }; function _getTypedText () { @@ -213,7 +213,6 @@ function _typeAnsPress() { _css = """ hr { background-color:#ccc; margin: 1em; } body { margin:1.5em; } -.cloze { font-weight: bold; color: blue; } img { max-width: 95%; max-height: 95%; } """ diff --git a/designer/addmodel.ui b/designer/addmodel.ui index 9a86dc51d..1ceda6b81 100644 --- a/designer/addmodel.ui +++ b/designer/addmodel.ui @@ -11,7 +11,7 @@ - Add Model + Add Note Type diff --git a/designer/template.ui b/designer/template.ui index c46ef20b0..da247aa81 100644 --- a/designer/template.ui +++ b/designer/template.ui @@ -6,8 +6,8 @@ 0 0 - 279 - 251 + 470 + 569 @@ -19,45 +19,173 @@ Form - + + + 0 + 0 - - - Front Template + + + 0 - - - 0 - - - - - - + + + + Front Template + + + + 0 + + + 0 + + + + + + + + + + + + + + + - - - - 10 - 0 - + + + 0 - - Back Template + + + + Appearance + + + + 0 + + + 0 + + + + + + + + + + + 0 + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 1 + 15 + + + + + + + + + + + + + + + Qt::Vertical + + + + 1 + 40 + + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 1 + 10 + + + + + + + + + + + + 0 - - - 0 - - - - - - + + + + + 10 + 0 + + + + Back Template + + + + 0 + + + 0 + + + + + + + + + + + + + + +