From 35a556903814a727a02271a726d6606d51ef65c8 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Mon, 29 Nov 2010 04:56:45 +0900 Subject: [PATCH] dialog refactor wip --- ankiqt/ui/__init__.py | 3 +- ankiqt/ui/clayout.py | 554 ++++++++++++++++++++++++ ankiqt/ui/displayproperties.py | 318 -------------- ankiqt/ui/facteditor.py | 231 +++++----- ankiqt/ui/main.py | 5 - ankiqt/ui/modelproperties.py | 246 +---------- designer/cardlist.ui | 6 + designer/clayout.ui | 571 +++++++++++++++++++++++++ designer/deckproperties.ui | 424 ++++++++++--------- designer/displayproperties.ui | 741 --------------------------------- designer/main.ui | 1 - designer/modelproperties.ui | 647 +++++++--------------------- designer/previewcards.ui | 82 ---- tools/build_ui.sh | 2 +- 14 files changed, 1639 insertions(+), 2192 deletions(-) create mode 100644 ankiqt/ui/clayout.py delete mode 100644 ankiqt/ui/displayproperties.py create mode 100644 designer/clayout.ui delete mode 100644 designer/displayproperties.ui delete mode 100644 designer/previewcards.ui diff --git a/ankiqt/ui/__init__.py b/ankiqt/ui/__init__.py index 0e41f8b1f..894cdb94d 100644 --- a/ankiqt/ui/__init__.py +++ b/ankiqt/ui/__init__.py @@ -10,7 +10,7 @@ def importAll(): import cardlist import deckproperties import importing - import displayproperties + import clayout import exporting import facteditor import help @@ -67,7 +67,6 @@ class DialogManager(object): def registerDialogs(self): self.registerDialog("AddCards", addcards.AddCards) self.registerDialog("CardList", cardlist.EditDeck) - self.registerDialog("DisplayProperties", displayproperties.DisplayProperties) self.registerDialog("Graphs", self.graphProxy) dialogs = DialogManager() diff --git a/ankiqt/ui/clayout.py b/ankiqt/ui/clayout.py new file mode 100644 index 000000000..4fe7e0bca --- /dev/null +++ b/ankiqt/ui/clayout.py @@ -0,0 +1,554 @@ +# Copyright: Damien Elmes +# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html + +from PyQt4.QtGui import * +from PyQt4.QtCore import * +import sys, re +import ankiqt.forms +import anki +from anki.models import * +from anki.facts import * +from anki.fonts import toCanonicalFont +from anki.cards import Card +from ankiqt.ui.utils import saveGeom, restoreGeom +from ankiqt import ui + +class CardLayout(QDialog): + + def __init__(self, parent, fact, card=None): + QDialog.__init__(self, parent) #, Qt.Window) + self.parent = parent + self.mw = ankiqt.mw + self.deck = self.mw.deck + self.fact = fact + self.model = fact.model + self.card = card or self.model.cardModels[0] + self.ignoreUpdate = False + self.plastiqueStyle = None + if (sys.platform.startswith("darwin") or + sys.platform.startswith("win32")): + self.plastiqueStyle = QStyleFactory.create("plastique") + self.form = ankiqt.forms.clayout.Ui_Dialog() + self.form.setupUi(self) + # self.connect(self.form.helpButton, SIGNAL("clicked()"), + # self.onHelp) + + # self.setupChooser() + self.setupCards() + # self.setupFields() + # self.setupButtons() + restoreGeom(self, "CardLayout") + self.exec_() + + def setupCards(self): + self.connect(self.form.cardList, SIGNAL("activated(int)"), + self.cardChanged) + self.connect(self.form.alignment, + SIGNAL("activated(int)"), + self.saveCard) + self.connect(self.form.background, + SIGNAL("clicked()"), + lambda w=self.form.background:\ + self.chooseColour(w)) + if self.plastiqueStyle: + self.form.background.setStyle(self.plastiqueStyle) + self.drawCards() + + + def formatToScreen(self, fmt): + fmt = fmt.replace("
", "
\n") + fmt = re.sub("%\((.+?)\)s", "{{\\1}}", fmt) + return fmt + + def screenToFormat(self, fmt): + fmt = fmt.replace("
\n", "
") + fmt = re.sub("{{(.+?)}}", "%(\\1)s", fmt) + return fmt + + def saveCurrentCard(self): + if not self.currentCard: + return + card = self.currentCard + newname = unicode(self.form.cardName.text()) + if not newname: + newname = _("Card-%d") % (self.model.cardModels.index(card) + 1) + self.updateField(card, 'name', newname) + s = unicode(self.form.cardQuestion.toPlainText()) + changed = self.updateField(card, 'qformat', self.screenToFormat(s)) + s = unicode(self.form.cardAnswer.toPlainText()) + changed2 = self.updateField(card, 'aformat', self.screenToFormat(s)) + self.needRebuild = self.needRebuild or changed or changed2 + self.updateField(card, 'questionInAnswer', self.form.questionInAnswer.isChecked()) + self.updateField(card, 'allowEmptyAnswer', self.form.allowEmptyAnswer.isChecked()) + idx = self.form.typeAnswer.currentIndex() + if not idx: + self.updateField(card, 'typeAnswer', u"") + else: + self.updateField(card, 'typeAnswer', self.fieldNames[idx-1]) + self.ignoreCardUpdate = True + self.updateCards() + self.ignoreCardUpdate = False + + def updateField(self, obj, field, value): + if getattr(obj, field) != value: + setattr(obj, field, value) + self.model.setModified() + self.deck.setModified() + return True + return False + + + + def drawCards(self): + self.form.cardList.clear() + self.form.cardList.addItems( + QStringList([c.name for c in self.model.cardModels])) + self.form.alignment.clear() + self.form.alignment.addItems( + QStringList(alignmentLabels().values())) + self.cardChanged(0) + + def cardChanged(self, idx): + self.card = self.model.cardModels[idx] + self.readCard() + self.drawQuestionAndAnswer() + + def readCard(self): + card = self.card + self.form.background.setPalette(QPalette(QColor( + getattr(card, "lastFontColour")))) + self.form.cardQuestion.setPlainText(self.formatToScreen(card.qformat)) + self.form.cardAnswer.setPlainText(self.formatToScreen(card.aformat)) + self.form.questionInAnswer.setChecked(card.questionInAnswer) + self.form.allowEmptyAnswer.setChecked(card.allowEmptyAnswer) + self.form.typeAnswer.clear() + self.fieldNames = self.deck.s.column0(""" +select fieldModels.name as n from fieldModels, cardModels +where cardModels.modelId = fieldModels.modelId +and cardModels.id = :id +order by n""", id=card.id) + s = [_("Don't ask me to type in the answer")] + s += [_("Compare with field '%s'") % f for f in self.fieldNames] + self.form.typeAnswer.insertItems(0, QStringList(s)) + try: + idx = self.fieldNames.index(card.typeAnswer) + except ValueError: + idx = -1 + self.form.typeAnswer.setCurrentIndex(idx + 1) + + def saveCard(self): + if not self.card: + return + self.card.questionAlign = self.form.align.currentIndex() + setattr(self.card, "lastFontColour", unicode( + self.form.backgroundColour.palette().window().color().name())) + self.card.model.setModified() + self.deck.setModified() + + self.drawQuestionAndAnswer() + + def cwidget(self, name, type): + "Return a card widget." + return getattr(self.form, type + name) + + def setupFields(self): + self.connect(self.form.fieldList, SIGNAL("currentRowChanged(int)"), + self.fieldChanged) + for type in ("quiz", "edit"): + self.connect(self.fwidget("fontFamily", type), + SIGNAL("currentFontChanged(QFont)"), + self.saveField) + self.connect(self.fwidget("fontSize", type), + SIGNAL("valueChanged(int)"), + self.saveField) + self.connect(self.fwidget("useFamily", type), + SIGNAL("stateChanged(int)"), + self.saveField) + self.connect(self.fwidget("useSize", type), + SIGNAL("stateChanged(int)"), + self.saveField) + if type == "quiz": + self.connect(self.fwidget("useColour", type), + SIGNAL("stateChanged(int)"), + self.saveField) + w = self.fwidget("fontColour", type) + if self.plastiqueStyle: + w.setStyle(self.plastiqueStyle) + self.connect(w, + SIGNAL("clicked()"), + lambda w=w: self.chooseColour(w)) + elif type == "edit": + self.connect(self.form.rtl, + SIGNAL("stateChanged(int)"), + self.saveField) + self.currentField = None + self.drawFields() + + def drawFields(self): + self.form.fieldList.clear() + n = 1 + self.ignoreUpdate = True + for field in self.model.fieldModels: + item = QListWidgetItem( + _("Field %(num)d: %(name)s") % { + 'num': n, + 'name': field.name, + }) + self.form.fieldList.addItem(item) + n += 1 + self.form.fieldList.setCurrentRow(0) + self.fieldChanged(0) + self.ignoreUpdate = False + + def fwidget(self, name, type): + "Return a field widget." + if type == "edit": + return getattr(self.form, name+"Edit") + else: + return getattr(self.form, name) + + def fieldChanged(self, idx): + self.saveField() + self.currentField = None + field = self.model.fieldModels[idx] + for type in ("quiz", "edit"): + # family + if getattr(field, type + 'FontFamily'): + self.fwidget("useFamily", type).setCheckState(Qt.Checked) + self.fwidget("fontFamily", type).setCurrentFont(QFont( + getattr(field, type + 'FontFamily'))) + self.fwidget("fontFamily", type).setEnabled(True) + else: + self.fwidget("useFamily", type).setCheckState(Qt.Unchecked) + self.fwidget("fontFamily", type).setEnabled(False) + # size + if getattr(field, type + 'FontSize'): + self.fwidget("useSize", type).setCheckState(Qt.Checked) + self.fwidget("fontSize", type).setValue( + getattr(field, type + 'FontSize')) + self.fwidget("fontSize", type).setEnabled(True) + else: + self.fwidget("useSize", type).setCheckState(Qt.Unchecked) + self.fwidget("fontSize", type).setEnabled(False) + if type == "quiz": + # colour + if getattr(field, type + 'FontColour'): + self.fwidget("useColour", type).setCheckState(Qt.Checked) + self.fwidget("fontColour", type).setPalette(QPalette(QColor( + getattr(field, type + 'FontColour')))) + self.fwidget("fontColour", type).setEnabled(True) + else: + self.fwidget("useColour", type).setCheckState(Qt.Unchecked) + self.fwidget("fontColour", type).setEnabled(False) + elif type == "edit": + self.form.rtl.setChecked(not not field.features) + self.currentField = field + + 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.form.rtl.isChecked(): + field.features = u"rtl" + else: + field.features = u"" + field.model.setModified() + self.deck.flushMod() + self.drawQuestionAndAnswer() + + def chooseColour(self, button): + new = QColorDialog.getColor(button.palette().window().color(), self) + if new.isValid(): + button.setPalette(QPalette(new)) + self.saveField() + self.saveCard() + + def drawQuestionAndAnswer(self): + print "draw qa" + return + self.deck.flushMod() + f = self.deck.newFact() + f.tags = u"" + for field in f.fields: + f[field.name] = field.name + f.model = self.model + c = Card(f, self.card) + t = "
" + c.htmlQuestion() + "
" + bg = "body { background-color: %s; }\n" % self.card.lastFontColour + self.form.question.setText( + "\n" + t) + t = "
" + c.htmlAnswer() + "
" + self.form.answer.setText( + "\n" + t) + self.mw.updateViews(self.mw.state) + + + def reject(self): + saveGeom(self, "CardLayout") + QDialog.reject(self) + + def onHelp(self): + QDesktopServices.openUrl(QUrl(ankiqt.appWiki + + "DisplayProperties")) + + # Fields + ########################################################################## + + # def setupFields(self): + # self.fieldOrdinalUpdatedIds = [] + # self.ignoreFieldUpdate = False + # self.currentField = None + # self.updateFields() + # self.readCurrentField() + # self.connect(self.form.fieldList, SIGNAL("currentRowChanged(int)"), + # self.fieldRowChanged) + # self.connect(self.form.tabWidget, SIGNAL("currentChanged(int)"), + # self.fieldRowChanged) + # self.connect(self.form.fieldAdd, SIGNAL("clicked()"), + # self.addField) + # self.connect(self.form.fieldDelete, SIGNAL("clicked()"), + # self.deleteField) + # self.connect(self.form.fieldUp, SIGNAL("clicked()"), + # self.moveFieldUp) + # self.connect(self.form.fieldDown, SIGNAL("clicked()"), + # self.moveFieldDown) + # self.connect(self.form.fieldName, SIGNAL("lostFocus()"), + # self.updateFields) + + # def updateFields(self, row = None): + # oldRow = self.form.fieldList.currentRow() + # if oldRow == -1: + # oldRow = 0 + # self.form.fieldList.clear() + # n = 1 + # for field in self.model.fieldModels: + # label = _("Field %(num)d: %(name)s [%(cards)s non-empty]") % { + # 'num': n, + # 'name': field.name, + # 'cards': self.deck.fieldModelUseCount(field) + # } + # item = QListWidgetItem(label) + # self.form.fieldList.addItem(item) + # n += 1 + # count = self.form.fieldList.count() + # if row != None: + # self.form.fieldList.setCurrentRow(row) + # else: + # while (count > 0 and oldRow > (count - 1)): + # oldRow -= 1 + # self.form.fieldList.setCurrentRow(oldRow) + # self.enableFieldMoveButtons() + + # def fieldRowChanged(self): + # if self.ignoreFieldUpdate: + # return + # self.saveCurrentField() + # self.readCurrentField() + + # def readCurrentField(self): + # if not len(self.model.fieldModels): + # self.form.fieldEditBox.hide() + # self.form.fieldUp.setEnabled(False) + # self.form.fieldDown.setEnabled(False) + # return + # else: + # self.form.fieldEditBox.show() + # self.currentField = self.model.fieldModels[self.form.fieldList.currentRow()] + # field = self.currentField + # self.form.fieldName.setText(field.name) + # self.form.fieldUnique.setChecked(field.unique) + # self.form.fieldRequired.setChecked(field.required) + # self.form.numeric.setChecked(field.numeric) + + # def enableFieldMoveButtons(self): + # row = self.form.fieldList.currentRow() + # if row < 1: + # self.form.fieldUp.setEnabled(False) + # else: + # self.form.fieldUp.setEnabled(True) + # if row == -1 or row >= (self.form.fieldList.count() - 1): + # self.form.fieldDown.setEnabled(False) + # else: + # self.form.fieldDown.setEnabled(True) + + # def saveCurrentField(self): + # if not self.currentField: + # return + # field = self.currentField + # name = unicode(self.form.fieldName.text()).strip() + # # renames + # if not name: + # name = _("Field %d") % (self.model.fieldModels.index(field) + 1) + # if name != field.name: + # self.deck.renameFieldModel(self.m, field, name) + # # the card models will have been updated + # self.readCurrentCard() + # # unique, required, numeric + # self.updateField(field, 'unique', + # self.form.fieldUnique.checkState() == Qt.Checked) + # self.updateField(field, 'required', + # self.form.fieldRequired.checkState() == Qt.Checked) + # self.updateField(field, 'numeric', + # self.form.numeric.checkState() == Qt.Checked) + # self.ignoreFieldUpdate = True + # self.updateFields() + # self.ignoreFieldUpdate = False + + # def addField(self): + # f = FieldModel(required=False, unique=False) + # f.name = _("Field %d") % (len(self.model.fieldModels) + 1) + # self.deck.addFieldModel(self.m, f) + # self.updateFields() + # self.form.fieldList.setCurrentRow(len(self.model.fieldModels)-1) + # self.form.fieldName.setFocus() + # self.form.fieldName.selectAll() + + # def deleteField(self): + # row = self.form.fieldList.currentRow() + # if row == -1: + # return + # if len(self.model.fieldModels) < 2: + # ui.utils.showInfo( + # _("Please add a new field first."), + # parent=self) + # return + # field = self.model.fieldModels[row] + # count = self.deck.fieldModelUseCount(field) + # if count: + # if not ui.utils.askUser( + # _("This field is used by %d cards. If you delete it,\n" + # "all information in this field will be lost.\n" + # "\nReally delete this field?") % count, + # parent=self): + # return + # self.deck.deleteFieldModel(self.m, field) + # self.currentField = None + # self.updateFields() + # # need to update q/a format + # self.readCurrentCard() + + # def moveFieldUp(self): + # row = self.form.fieldList.currentRow() + # if row == -1: + # return + # if row == 0: + # return + # field = self.model.fieldModels[row] + # tField = self.model.fieldModels[row - 1] + # self.model.fieldModels.remove(field) + # self.model.fieldModels.insert(row - 1, field) + # if field.id not in self.fieldOrdinalUpdatedIds: + # self.fieldOrdinalUpdatedIds.append(field.id) + # if tField.id not in self.fieldOrdinalUpdatedIds: + # self.fieldOrdinalUpdatedIds.append(tField.id) + # self.ignoreFieldUpdate = True + # self.updateFields(row - 1) + # self.ignoreFieldUpdate = False + + # def moveFieldDown(self): + # row = self.form.fieldList.currentRow() + # if row == -1: + # return + # if row == len(self.model.fieldModels) - 1: + # return + # field = self.model.fieldModels[row] + # tField = self.model.fieldModels[row + 1] + # self.model.fieldModels.remove(field) + # self.model.fieldModels.insert(row + 1, field) + # if field.id not in self.fieldOrdinalUpdatedIds: + # self.fieldOrdinalUpdatedIds.append(field.id) + # if tField.id not in self.fieldOrdinalUpdatedIds: + # self.fieldOrdinalUpdatedIds.append(tField.id) + # self.ignoreFieldUpdate = True + # self.updateFields(row + 1) + # self.ignoreFieldUpdate = False + + + + # rebuild ordinals if changed + # if len(self.fieldOrdinalUpdatedIds) > 0: + # self.deck.rebuildFieldOrdinals(self.model.id, self.fieldOrdinalUpdatedIds) + # self.model.setModified() + # self.deck.setModified() + +# class PreviewDialog(QDialog): + +# def __init__(self, parent, deck, fact, *args): +# QDialog.__init__(self, parent, *args) +# self.deck = deck +# self.fact = fact +# cards = self.deck.previewFact(self.fact) +# if not cards: +# ui.utils.showInfo(_("No cards to preview."), +# parent=parent) +# return +# self.cards = cards +# self.currentCard = 0 +# self.form = ankiqt.forms.previewcards.Ui_Dialog() +# self.form.setupUi(self) +# self.form.webView.page().setLinkDelegationPolicy( +# QWebPage.DelegateExternalLinks) +# self.connect(self.form.webView, +# SIGNAL("linkClicked(QUrl)"), +# self.linkClicked) +# self.form.comboBox.addItems(QStringList( +# [c.cardModel.name for c in self.cards])) +# self.connect(self.form.comboBox, SIGNAL("activated(int)"), +# self.onChange) +# self.updateCard() +# restoreGeom(self, "preview") +# self.exec_() + +# def linkClicked(self, url): +# QDesktopServices.openUrl(QUrl(url)) + +# def updateCard(self): +# c = self.cards[self.currentCard] +# styles = (self.deck.css + +# ("\nhtml { background: %s }" % c.cardModel.lastFontColour) + +# "\ndiv { white-space: pre-wrap; }") +# styles = runFilter("addStyles", styles, c) +# self.form.webView.setHtml( +# ('%s' % getBase(self.deck, c)) + +# "" + +# runFilter("drawQuestion", mungeQA(self.deck, c.htmlQuestion()), +# c) + +# "




" + +# runFilter("drawAnswer", mungeQA(self.deck, c.htmlAnswer()), +# c) +# + "") +# clearAudioQueue() +# playFromText(c.question) +# playFromText(c.answer) + +# def onChange(self, idx): +# self.currentCard = idx +# self.updateCard() + +# def reject(self): +# saveGeom(self, "preview") +# QDialog.reject(self) diff --git a/ankiqt/ui/displayproperties.py b/ankiqt/ui/displayproperties.py deleted file mode 100644 index 9b04391a6..000000000 --- a/ankiqt/ui/displayproperties.py +++ /dev/null @@ -1,318 +0,0 @@ -# Copyright: Damien Elmes -# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html - -from PyQt4.QtGui import * -from PyQt4.QtCore import * -import sys, re -import ankiqt.forms -import anki -from anki.models import * -from anki.facts import * -from anki.fonts import toCanonicalFont -from anki.cards import Card -from ankiqt import ui - -class DisplayProperties(QDialog): - - def __init__(self, parent, main=None): - QDialog.__init__(self, parent, Qt.Window) - if not main: - main = parent - self.parent = parent - self.main = main - self.deck = main.deck - self.ignoreUpdate = False - self.plastiqueStyle = None - if (sys.platform.startswith("darwin") or - sys.platform.startswith("win32")): - self.plastiqueStyle = QStyleFactory.create("plastique") - self.dialog = ankiqt.forms.displayproperties.Ui_DisplayProperties() - self.dialog.setupUi(self) - self.model = self.deck.currentModel - self.setupChooser() - self.setupCards() - self.setupFields() - self.setupButtons() - self.show() - ui.dialogs.open("DisplayProperties", self) - - def setupChooser(self): - self.modelChooser = ui.modelchooser.ModelChooser(self, - self.main, - self.main.deck, - self.modelChanged, - cards=False) - self.dialog.modelArea.setLayout(self.modelChooser) - - def modelChanged(self, model): - self.model = model - self.drawCards() - self.drawFields() - - def setupButtons(self): - self.connect(self.dialog.preview, SIGNAL("clicked()"), - self.previewClicked) - self.connect(self.dialog.helpButton, SIGNAL("clicked()"), - self.onHelp) - if self.main.config['showFontPreview']: - self.dialog.preview.setChecked(True) - else: - self.dialog.preview.setChecked(False) - self.previewClicked() - - def previewClicked(self): - if self.dialog.preview.isChecked(): - self.dialog.previewGroup.show() - self.setMaximumWidth(16777215) - self.setMinimumWidth(790) - self.main.config['showFontPreview'] = True - else: - self.dialog.previewGroup.hide() - self.setFixedWidth(380) - self.main.config['showFontPreview'] = False - - def setupCards(self): - self.connect(self.dialog.cardList, SIGNAL("activated(int)"), - self.cardChanged) - for type in ("question", "answer"): - self.connect(self.cwidget("Font", type), - SIGNAL("currentFontChanged(QFont)"), - self.saveCard) - self.connect(self.cwidget("Size", type), - SIGNAL("valueChanged(int)"), - self.saveCard) - w = self.cwidget("Colour", type) - if self.plastiqueStyle: - w.setStyle(self.plastiqueStyle) - self.connect(w, - SIGNAL("clicked()"), - lambda w=w: self.chooseColour(w)) - self.connect(self.cwidget("Align", type), - SIGNAL("activated(int)"), - self.saveCard) - # background colour - self.connect(self.dialog.backgroundColour, - SIGNAL("clicked()"), - lambda w=self.dialog.backgroundColour:\ - self.chooseColour(w)) - if self.plastiqueStyle: - self.dialog.backgroundColour.setStyle(self.plastiqueStyle) - - self.drawCards() - - def drawCards(self): - self.dialog.cardList.clear() - self.dialog.cardList.addItems( - QStringList([c.name for c in self.model.cardModels])) - for t in ("question", "answer"): - self.cwidget("Align", t).clear() - self.cwidget("Align", t).addItems( - QStringList(alignmentLabels().values())) - self.cardChanged(0) - - def cardChanged(self, idx): - self.card = self.model.cardModels[idx] - self.readCard() - self.drawQuestionAndAnswer() - - def readCard(self): - card = self.card - self.card = None - for type in ("question", "answer"): - self.cwidget("Font", type).setCurrentFont(QFont( - getattr(card, type + "FontFamily"))) - self.cwidget("Size", type).setValue( - getattr(card, type + "FontSize")) - self.cwidget("Colour", type).setPalette(QPalette(QColor( - getattr(card, type + "FontColour")))) - self.cwidget("Align", type).setCurrentIndex( - getattr(card, type + "Align")) - self.dialog.backgroundColour.setPalette(QPalette(QColor( - getattr(card, "lastFontColour")))) - self.card = card - - 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() - - def cwidget(self, name, type): - "Return a card widget." - return getattr(self.dialog, type + name) - - def setupFields(self): - self.connect(self.dialog.fieldList, SIGNAL("currentRowChanged(int)"), - self.fieldChanged) - for type in ("quiz", "edit"): - self.connect(self.fwidget("fontFamily", type), - SIGNAL("currentFontChanged(QFont)"), - self.saveField) - self.connect(self.fwidget("fontSize", type), - SIGNAL("valueChanged(int)"), - self.saveField) - self.connect(self.fwidget("useFamily", type), - SIGNAL("stateChanged(int)"), - self.saveField) - self.connect(self.fwidget("useSize", type), - SIGNAL("stateChanged(int)"), - self.saveField) - if type == "quiz": - self.connect(self.fwidget("useColour", type), - SIGNAL("stateChanged(int)"), - self.saveField) - w = self.fwidget("fontColour", type) - if self.plastiqueStyle: - w.setStyle(self.plastiqueStyle) - self.connect(w, - SIGNAL("clicked()"), - lambda w=w: self.chooseColour(w)) - elif type == "edit": - self.connect(self.dialog.rtl, - SIGNAL("stateChanged(int)"), - self.saveField) - self.currentField = None - self.drawFields() - - def drawFields(self): - self.dialog.fieldList.clear() - n = 1 - self.ignoreUpdate = True - for field in self.model.fieldModels: - item = QListWidgetItem( - _("Field %(num)d: %(name)s") % { - 'num': n, - 'name': field.name, - }) - self.dialog.fieldList.addItem(item) - n += 1 - self.dialog.fieldList.setCurrentRow(0) - self.fieldChanged(0) - self.ignoreUpdate = False - - def fwidget(self, name, type): - "Return a field widget." - if type == "edit": - return getattr(self.dialog, name+"Edit") - else: - return getattr(self.dialog, name) - - def fieldChanged(self, idx): - self.saveField() - self.currentField = None - field = self.model.fieldModels[idx] - for type in ("quiz", "edit"): - # family - if getattr(field, type + 'FontFamily'): - self.fwidget("useFamily", type).setCheckState(Qt.Checked) - self.fwidget("fontFamily", type).setCurrentFont(QFont( - getattr(field, type + 'FontFamily'))) - self.fwidget("fontFamily", type).setEnabled(True) - else: - self.fwidget("useFamily", type).setCheckState(Qt.Unchecked) - self.fwidget("fontFamily", type).setEnabled(False) - # size - if getattr(field, type + 'FontSize'): - self.fwidget("useSize", type).setCheckState(Qt.Checked) - self.fwidget("fontSize", type).setValue( - getattr(field, type + 'FontSize')) - self.fwidget("fontSize", type).setEnabled(True) - else: - self.fwidget("useSize", type).setCheckState(Qt.Unchecked) - self.fwidget("fontSize", type).setEnabled(False) - if type == "quiz": - # colour - if getattr(field, type + 'FontColour'): - self.fwidget("useColour", type).setCheckState(Qt.Checked) - self.fwidget("fontColour", type).setPalette(QPalette(QColor( - getattr(field, type + 'FontColour')))) - self.fwidget("fontColour", type).setEnabled(True) - else: - self.fwidget("useColour", type).setCheckState(Qt.Unchecked) - self.fwidget("fontColour", type).setEnabled(False) - elif type == "edit": - self.dialog.rtl.setChecked(not not field.features) - self.currentField = field - - 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() - - def chooseColour(self, button): - new = QColorDialog.getColor(button.palette().window().color(), self) - if new.isValid(): - button.setPalette(QPalette(new)) - self.saveField() - self.saveCard() - - def drawQuestionAndAnswer(self): - self.deck.flushMod() - f = self.deck.newFact() - f.tags = u"" - for field in f.fields: - f[field.name] = field.name - f.model = self.model - c = Card(f, self.card) - t = "
" + c.htmlQuestion() + "
" - bg = "body { background-color: %s; }\n" % self.card.lastFontColour - self.dialog.question.setText( - "\n" + t) - t = "
" + c.htmlAnswer() + "
" - self.dialog.answer.setText( - "\n" + t) - self.main.updateViews(self.main.state) - - - def reject(self): - ui.dialogs.close("DisplayProperties") - self.modelChooser.deinit() - QDialog.reject(self) - - def onHelp(self): - QDesktopServices.openUrl(QUrl(ankiqt.appWiki + - "DisplayProperties")) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index d8abe7c29..c86b118c8 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -49,6 +49,7 @@ class FactEditor(object): self.changeTimer = None self.lastCloze = None self.resetOnEdit = True + self.card=None addHook("deckClosed", self.deckClosedHook) addHook("guiReset", self.refresh) addHook("colourChanged", self.colourChanged) @@ -106,6 +107,9 @@ class FactEditor(object): def setupFields(self): # init for later self.fields = {} + # button styles for mac + self.plastiqueStyle = QStyleFactory.create("plastique") + self.widget.setStyle(self.plastiqueStyle) # top level vbox self.fieldsBox = QVBoxLayout(self.widget) self.fieldsBox.setMargin(0) @@ -115,6 +119,20 @@ class FactEditor(object): self.iconsBox2 = QHBoxLayout() self.fieldsBox.addLayout(self.iconsBox) self.fieldsBox.addLayout(self.iconsBox2) + # card layout + self.iconsBox.addItem(QSpacerItem(20,1, QSizePolicy.Expanding)) + self.clayout = QPushButton("&Edit Card") + self.clayout.connect(self.clayout, SIGNAL("clicked()"), self.onCardLayout) + self.clayout.setSizePolicy(QSizePolicy.Preferred,QSizePolicy.Preferred) + self.clayout.setFixedHeight(20) + # self.clayout.setFixedWidth(48) + self.clayout.setIcon(QIcon(":/icons/edit.png")) + #self.clayout.setIconSize(QSize(32,32)) + #self.clayout.setToolTip(_("Bold text (Ctrl+b)")) + #self.clayout.setShortcut(_("Ctrl+b")) + self.clayout.setFocusPolicy(Qt.NoFocus) + self.iconsBox.addWidget(self.clayout) + self.clayout.setStyle(self.plastiqueStyle) # scrollarea self.fieldsScroll = QScrollArea() self.fieldsScroll.setWidgetResizable(True) @@ -133,15 +151,13 @@ class FactEditor(object): self.fieldsBox.addLayout(self.tagsBox) # icons self.iconsBox.setMargin(0) - self.iconsBox.addItem(QSpacerItem(20,1, QSizePolicy.Expanding)) self.iconsBox2.setMargin(0) - self.iconsBox2.setMargin(0) - self.iconsBox2.addItem(QSpacerItem(20,1, QSizePolicy.Expanding)) - # button styles for mac - self.plastiqueStyle = QStyleFactory.create("plastique") - self.widget.setStyle(self.plastiqueStyle) # bold + spc = QSpacerItem(5,5) + self.iconsBox.addItem(spc) self.bold = QPushButton() + self.bold.setFixedHeight(20) + self.bold.setFixedWidth(20) self.bold.setCheckable(True) self.bold.connect(self.bold, SIGNAL("toggled(bool)"), self.toggleBold) self.bold.setIcon(QIcon(":/icons/text_bold.png")) @@ -153,6 +169,8 @@ class FactEditor(object): self.bold.setStyle(self.plastiqueStyle) # italic self.italic = QPushButton(self.widget) + self.italic.setFixedHeight(20) + self.italic.setFixedWidth(20) self.italic.setCheckable(True) self.italic.connect(self.italic, SIGNAL("toggled(bool)"), self.toggleItalic) self.italic.setIcon(QIcon(":/icons/text_italic.png")) @@ -164,6 +182,8 @@ class FactEditor(object): self.italic.setStyle(self.plastiqueStyle) # underline self.underline = QPushButton(self.widget) + self.underline.setFixedHeight(20) + self.underline.setFixedWidth(20) self.underline.setCheckable(True) self.underline.connect(self.underline, SIGNAL("toggled(bool)"), self.toggleUnderline) self.underline.setIcon(QIcon(":/icons/text_under.png")) @@ -180,8 +200,8 @@ class FactEditor(object): self.foreground.setShortcut(_("F7, F7")) self.foreground.setFocusPolicy(Qt.NoFocus) self.foreground.setEnabled(False) - self.foreground.setFixedWidth(30) - self.foreground.setFixedHeight(26) + self.foreground.setFixedWidth(20) + self.foreground.setFixedHeight(20) self.foregroundFrame = QFrame() self.foregroundFrame.setAutoFillBackground(True) hbox = QHBoxLayout() @@ -190,60 +210,62 @@ class FactEditor(object): self.foreground.setLayout(hbox) self.iconsBox.addWidget(self.foreground) self.foreground.setStyle(self.plastiqueStyle) + self.iconsBox.addItem(QSpacerItem(5,1, QSizePolicy.Fixed)) # picker - vbox = QVBoxLayout() - vbox.setMargin(0) - vbox.setSpacing(0) - hbox = QHBoxLayout() - hbox.setMargin(0) - hbox.setSpacing(0) - self.fleft = QPushButton() - self.fleft.connect(self.fleft, SIGNAL("clicked()"), self.previousForeground) - self.fleft.setToolTip(_("Previous colour (F7 then F6)")) - self.fleft.setText("<") - self.fleft.setShortcut(_("F7, F6")) - self.fleft.setFocusPolicy(Qt.NoFocus) - self.fleft.setEnabled(False) - self.fleft.setFixedWidth(15) - self.fleft.setFixedHeight(14) - hbox.addWidget(self.fleft) - self.fleft.setStyle(self.plastiqueStyle) - self.fright = QPushButton() - self.fright.connect(self.fright, SIGNAL("clicked()"), self.nextForeground) - self.fright.setToolTip(_("Next colour (F7 then F8)")) - self.fright.setText(">") - self.fright.setShortcut(_("F7, F8")) - self.fright.setFocusPolicy(Qt.NoFocus) - self.fright.setEnabled(False) - self.fright.setFixedWidth(15) - self.fright.setFixedHeight(14) - hbox.addWidget(self.fright) - self.fright.setStyle(self.plastiqueStyle) - vbox.addLayout(hbox) - self.fchoose = QPushButton() - self.fchoose.connect(self.fchoose, SIGNAL("clicked()"), self.selectForeground) - self.fchoose.setToolTip(_("Choose colour (F7 then F5)")) - self.fchoose.setText("+") - self.fchoose.setShortcut(_("F7, F5")) - self.fchoose.setFocusPolicy(Qt.NoFocus) - self.fchoose.setEnabled(False) - self.fchoose.setFixedWidth(30) - self.fchoose.setFixedHeight(12) - vbox.addWidget(self.fchoose) - self.fchoose.setStyle(self.plastiqueStyle) - self.iconsBox.addLayout(vbox) + # vbox = QVBoxLayout() + # vbox.setMargin(0) + # vbox.setSpacing(0) + # hbox = QHBoxLayout() + # hbox.setMargin(0) + # hbox.setSpacing(0) + # self.fleft = QPushButton() + # self.fleft.connect(self.fleft, SIGNAL("clicked()"), self.previousForeground) + # self.fleft.setToolTip(_("Previous colour (F7 then F6)")) + # self.fleft.setText("<") + # self.fleft.setShortcut(_("F7, F6")) + # self.fleft.setFocusPolicy(Qt.NoFocus) + # self.fleft.setEnabled(False) + # self.fleft.setFixedWidth(15) + # self.fleft.setFixedHeight(14) + # hbox.addWidget(self.fleft) + # self.fleft.setStyle(self.plastiqueStyle) + # self.fright = QPushButton() + # self.fright.setFixedHeight(20) + # self.fright.connect(self.fright, SIGNAL("clicked()"), self.nextForeground) + # self.fright.setToolTip(_("Next colour (F7 then F8)")) + # self.fright.setText(">") + # self.fright.setShortcut(_("F7, F8")) + # self.fright.setFocusPolicy(Qt.NoFocus) + # self.fright.setEnabled(False) + # self.fright.setFixedWidth(15) + # self.fright.setFixedHeight(14) + # hbox.addWidget(self.fright) + # self.fright.setStyle(self.plastiqueStyle) + # vbox.addLayout(hbox) + # self.fchoose = QPushButton() + # self.fchoose.connect(self.fchoose, SIGNAL("clicked()"), self.selectForeground) + # self.fchoose.setToolTip(_("Choose colour (F7 then F5)")) + # self.fchoose.setText("+") + # self.fchoose.setShortcut(_("F7, F5")) + # self.fchoose.setFocusPolicy(Qt.NoFocus) + # self.fchoose.setEnabled(False) + # self.fchoose.setFixedWidth(30) + # self.fchoose.setFixedHeight(12) + # vbox.addWidget(self.fchoose) + # self.fchoose.setStyle(self.plastiqueStyle) + # self.iconsBox.addLayout(vbox) # cloze - spc = QSpacerItem(5,5) - self.iconsBox.addItem(spc) + # spc = QSpacerItem(5,5) + # self.iconsBox2.addItem(spc) self.cloze = QPushButton(self.widget) + self.cloze.setFixedHeight(20) self.clozeSC = QShortcut(QKeySequence(_("F9")), self.widget) self.cloze.connect(self.cloze, SIGNAL("clicked()"), self.onCloze) self.cloze.connect(self.clozeSC, SIGNAL("activated()"), self.onCloze) self.cloze.setToolTip(_("Cloze (F9)")) - self.cloze.setFixedWidth(30) - self.cloze.setFixedHeight(26) + self.cloze.setFixedWidth(24) self.cloze.setText("[...]") self.cloze.setFocusPolicy(Qt.NoFocus) self.cloze.setEnabled(False) @@ -251,6 +273,8 @@ class FactEditor(object): self.cloze.setStyle(self.plastiqueStyle) # pictures self.addPicture = QPushButton(self.widget) + self.addPicture.setFixedHeight(20) + self.addPicture.setFixedWidth(20) self.addPicture.connect(self.addPicture, SIGNAL("clicked()"), self.onAddPicture) self.addPicture.setFocusPolicy(Qt.NoFocus) self.addPicture.setShortcut(_("F3")) @@ -261,6 +285,8 @@ class FactEditor(object): self.addPicture.setStyle(self.plastiqueStyle) # sounds self.addSound = QPushButton(self.widget) + self.addSound.setFixedHeight(20) + self.addSound.setFixedWidth(20) self.addSound.connect(self.addSound, SIGNAL("clicked()"), self.onAddSound) self.addSound.setFocusPolicy(Qt.NoFocus) self.addSound.setShortcut(_("F4")) @@ -271,6 +297,8 @@ class FactEditor(object): self.addSound.setStyle(self.plastiqueStyle) # sounds self.recSound = QPushButton(self.widget) + self.recSound.setFixedHeight(20) + self.recSound.setFixedWidth(20) self.recSound.connect(self.recSound, SIGNAL("clicked()"), self.onRecSound) self.recSound.setFocusPolicy(Qt.NoFocus) self.recSound.setShortcut(_("F5")) @@ -279,35 +307,23 @@ class FactEditor(object): self.recSound.setToolTip(_("Record audio (F5)")) self.iconsBox.addWidget(self.recSound) self.recSound.setStyle(self.plastiqueStyle) - # preview - spc = QSpacerItem(5,5) - self.iconsBox.addItem(spc) - self.preview = QPushButton(self.widget) - self.previewSC = QShortcut(QKeySequence(_("F2")), self.widget) - self.preview.connect(self.preview, SIGNAL("clicked()"), - self.onPreview) - self.preview.connect(self.previewSC, SIGNAL("activated()"), - self.onPreview) - self.preview.setToolTip(_("Preview (F2)")) - self.preview.setIcon(QIcon(":/icons/document-preview.png")) - self.preview.setFocusPolicy(Qt.NoFocus) - self.iconsBox.addWidget(self.preview) - self.preview.setStyle(self.plastiqueStyle) # more self.more = QPushButton(self.widget) + self.more.setFixedHeight(20) + self.more.setFixedWidth(20) self.more.connect(self.more, SIGNAL("clicked()"), self.onMore) self.more.setToolTip(_("Show advanced options")) self.more.setText(">>") self.more.setFocusPolicy(Qt.NoFocus) - self.more.setFixedWidth(30) - self.more.setFixedHeight(26) self.iconsBox.addWidget(self.more) self.more.setStyle(self.plastiqueStyle) # latex - spc = QSpacerItem(5,5) + spc = QSpacerItem(5,5, QSizePolicy.Expanding) self.iconsBox2.addItem(spc) self.latex = QPushButton(self.widget) + self.latex.setFixedHeight(20) + self.latex.setFixedWidth(20) self.latex.setToolTip(_("Latex (Ctrl+l then l)")) self.latexSC = QShortcut(QKeySequence(_("Ctrl+l, l")), self.widget) self.latex.connect(self.latex, SIGNAL("clicked()"), self.insertLatex) @@ -319,6 +335,8 @@ class FactEditor(object): self.latex.setStyle(self.plastiqueStyle) # latex eqn self.latexEqn = QPushButton(self.widget) + self.latexEqn.setFixedHeight(20) + self.latexEqn.setFixedWidth(20) self.latexEqn.setToolTip(_("Latex equation (Ctrl+l then e)")) self.latexEqnSC = QShortcut(QKeySequence(_("Ctrl+l, e")), self.widget) self.latexEqn.connect(self.latexEqn, SIGNAL("clicked()"), self.insertLatexEqn) @@ -330,6 +348,8 @@ class FactEditor(object): self.latexEqn.setStyle(self.plastiqueStyle) # latex math env self.latexMathEnv = QPushButton(self.widget) + self.latexMathEnv.setFixedHeight(20) + self.latexMathEnv.setFixedWidth(20) self.latexMathEnv.setToolTip(_("Latex math environment (Ctrl+l then m)")) self.latexMathEnvSC = QShortcut(QKeySequence(_("Ctrl+l, m")), self.widget) self.latexMathEnv.connect(self.latexMathEnv, SIGNAL("clicked()"), @@ -343,6 +363,8 @@ class FactEditor(object): self.latexMathEnv.setStyle(self.plastiqueStyle) # html self.htmlEdit = QPushButton(self.widget) + self.htmlEdit.setFixedHeight(20) + self.htmlEdit.setFixedWidth(20) self.htmlEdit.setToolTip(_("HTML Editor (Ctrl+F9)")) self.htmlEditSC = QShortcut(QKeySequence(_("Ctrl+F9")), self.widget) self.htmlEdit.connect(self.htmlEdit, SIGNAL("clicked()"), @@ -369,6 +391,7 @@ class FactEditor(object): self.fieldsGrid = QGridLayout(self.fieldsFrame) self.fieldsFrame.setLayout(self.fieldsGrid) self.fieldsGrid.setMargin(0) + self.fieldsGrid.setSpacing(5) def drawField(self, field, n): # label @@ -645,9 +668,9 @@ class FactEditor(object): self.italic.setEnabled(val) self.underline.setEnabled(val) self.foreground.setEnabled(val) - self.fchoose.setEnabled(val) - self.fleft.setEnabled(val) - self.fright.setEnabled(val) + # self.fchoose.setEnabled(val) + # self.fleft.setEnabled(val) + # self.fright.setEnabled(val) self.addPicture.setEnabled(val) self.addSound.setEnabled(val) self.latex.setEnabled(val) @@ -781,9 +804,9 @@ class FactEditor(object): self.latexMathEnv.setShown(toggle) self.htmlEdit.setShown(toggle) - def onPreview(self): + def onCardLayout(self): self.saveFields() - PreviewDialog(self.parent, self.deck, self.fact) + ui.clayout.CardLayout(self.parent, self.fact, self.card) # FIXME: in some future version, we should use a different delimiter, as # [sound] et al conflicts @@ -1107,61 +1130,3 @@ class FactEdit(QTextEdit): if self._ownLayout == None: self._ownLayout = self._programLayout ActivateKeyboardLayout(self._ownLayout, 0) - -class PreviewDialog(QDialog): - - def __init__(self, parent, deck, fact, *args): - QDialog.__init__(self, parent, *args) - self.deck = deck - self.fact = fact - cards = self.deck.previewFact(self.fact) - if not cards: - ui.utils.showInfo(_("No cards to preview."), - parent=parent) - return - self.cards = cards - self.currentCard = 0 - self.dialog = ankiqt.forms.previewcards.Ui_Dialog() - self.dialog.setupUi(self) - self.dialog.webView.page().setLinkDelegationPolicy( - QWebPage.DelegateExternalLinks) - self.connect(self.dialog.webView, - SIGNAL("linkClicked(QUrl)"), - self.linkClicked) - self.dialog.comboBox.addItems(QStringList( - [c.cardModel.name for c in self.cards])) - self.connect(self.dialog.comboBox, SIGNAL("activated(int)"), - self.onChange) - self.updateCard() - restoreGeom(self, "preview") - self.exec_() - - def linkClicked(self, url): - QDesktopServices.openUrl(QUrl(url)) - - def updateCard(self): - c = self.cards[self.currentCard] - styles = (self.deck.css + - ("\nhtml { background: %s }" % c.cardModel.lastFontColour) + - "\ndiv { white-space: pre-wrap; }") - styles = runFilter("addStyles", styles, c) - self.dialog.webView.setHtml( - ('%s' % getBase(self.deck, c)) + - "" + - runFilter("drawQuestion", mungeQA(self.deck, c.htmlQuestion()), - c) + - "




" + - runFilter("drawAnswer", mungeQA(self.deck, c.htmlAnswer()), - c) - + "") - clearAudioQueue() - playFromText(c.question) - playFromText(c.answer) - - def onChange(self, idx): - self.currentCard = idx - self.updateCard() - - def reject(self): - saveGeom(self, "preview") - QDialog.reject(self) diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 29fe8a869..9002220ea 100755 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -1905,9 +1905,6 @@ learnt today") def onDeckProperties(self): self.deckProperties = ui.deckproperties.DeckProperties(self, self.deck) - def onDisplayProperties(self): - ui.dialogs.get("DisplayProperties", self) - def onPrefs(self): ui.preferences.Preferences(self, self.config) @@ -2376,7 +2373,6 @@ This deck already exists on your computer. Overwrite the local copy?"""), "Close", "Addcards", "Editdeck", - "DisplayProperties", "DeckProperties", "Undo", "Redo", @@ -2407,7 +2403,6 @@ This deck already exists on your computer. Overwrite the local copy?"""), self.connect(m.actionExit, s, self, SLOT("close()")) self.connect(m.actionSyncdeck, s, self.syncDeck) self.connect(m.actionDeckProperties, s, self.onDeckProperties) - self.connect(m.actionDisplayProperties, s,self.onDisplayProperties) self.connect(m.actionAddcards, s, self.onAddCard) self.connect(m.actionEditdeck, s, self.onEditDeck) self.connect(m.actionEditCurrent, s, self.onEditCurrent) diff --git a/ankiqt/ui/modelproperties.py b/ankiqt/ui/modelproperties.py index d0c47e93c..58cb844aa 100644 --- a/ankiqt/ui/modelproperties.py +++ b/ankiqt/ui/modelproperties.py @@ -28,9 +28,8 @@ class ModelProperties(QDialog): self.dialog.setupUi(self) self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.helpRequested) - self.setupFields() - self.setupCards() self.readData() + self.setupCards() self.show() self.undoName = _("Model Properties") self.deck.setUndoStart(self.undoName) @@ -43,178 +42,6 @@ class ModelProperties(QDialog): self.dialog.initialSpacing.setText(str(self.m.initialSpacing/60)) self.dialog.mediaURL.setText(unicode(self.m.features)) - # Fields - ########################################################################## - - def setupFields(self): - self.fieldOrdinalUpdatedIds = [] - self.ignoreFieldUpdate = False - self.currentField = None - self.updateFields() - self.readCurrentField() - self.connect(self.dialog.fieldList, SIGNAL("currentRowChanged(int)"), - self.fieldRowChanged) - self.connect(self.dialog.tabWidget, SIGNAL("currentChanged(int)"), - self.fieldRowChanged) - self.connect(self.dialog.fieldAdd, SIGNAL("clicked()"), - self.addField) - self.connect(self.dialog.fieldDelete, SIGNAL("clicked()"), - self.deleteField) - self.connect(self.dialog.fieldUp, SIGNAL("clicked()"), - self.moveFieldUp) - self.connect(self.dialog.fieldDown, SIGNAL("clicked()"), - self.moveFieldDown) - self.connect(self.dialog.fieldName, SIGNAL("lostFocus()"), - self.updateFields) - - def updateFields(self, row = None): - oldRow = self.dialog.fieldList.currentRow() - if oldRow == -1: - oldRow = 0 - self.dialog.fieldList.clear() - n = 1 - for field in self.m.fieldModels: - label = _("Field %(num)d: %(name)s [%(cards)s non-empty]") % { - 'num': n, - 'name': field.name, - 'cards': self.deck.fieldModelUseCount(field) - } - item = QListWidgetItem(label) - self.dialog.fieldList.addItem(item) - n += 1 - count = self.dialog.fieldList.count() - if row != None: - self.dialog.fieldList.setCurrentRow(row) - else: - while (count > 0 and oldRow > (count - 1)): - oldRow -= 1 - self.dialog.fieldList.setCurrentRow(oldRow) - self.enableFieldMoveButtons() - - def fieldRowChanged(self): - if self.ignoreFieldUpdate: - return - self.saveCurrentField() - self.readCurrentField() - - def readCurrentField(self): - if not len(self.m.fieldModels): - self.dialog.fieldEditBox.hide() - self.dialog.fieldUp.setEnabled(False) - self.dialog.fieldDown.setEnabled(False) - return - else: - self.dialog.fieldEditBox.show() - self.currentField = self.m.fieldModels[self.dialog.fieldList.currentRow()] - field = self.currentField - self.dialog.fieldName.setText(field.name) - self.dialog.fieldUnique.setChecked(field.unique) - self.dialog.fieldRequired.setChecked(field.required) - self.dialog.numeric.setChecked(field.numeric) - - def enableFieldMoveButtons(self): - row = self.dialog.fieldList.currentRow() - if row < 1: - self.dialog.fieldUp.setEnabled(False) - else: - self.dialog.fieldUp.setEnabled(True) - if row == -1 or row >= (self.dialog.fieldList.count() - 1): - self.dialog.fieldDown.setEnabled(False) - else: - self.dialog.fieldDown.setEnabled(True) - - def saveCurrentField(self): - if not self.currentField: - return - field = self.currentField - name = unicode(self.dialog.fieldName.text()).strip() - # renames - if not name: - name = _("Field %d") % (self.m.fieldModels.index(field) + 1) - if name != field.name: - self.deck.renameFieldModel(self.m, field, name) - # the card models will have been updated - self.readCurrentCard() - # unique, required, numeric - self.updateField(field, 'unique', - self.dialog.fieldUnique.checkState() == Qt.Checked) - self.updateField(field, 'required', - self.dialog.fieldRequired.checkState() == Qt.Checked) - self.updateField(field, 'numeric', - self.dialog.numeric.checkState() == Qt.Checked) - self.ignoreFieldUpdate = True - self.updateFields() - self.ignoreFieldUpdate = False - - def addField(self): - f = FieldModel(required=False, unique=False) - f.name = _("Field %d") % (len(self.m.fieldModels) + 1) - self.deck.addFieldModel(self.m, f) - self.updateFields() - self.dialog.fieldList.setCurrentRow(len(self.m.fieldModels)-1) - self.dialog.fieldName.setFocus() - self.dialog.fieldName.selectAll() - - def deleteField(self): - row = self.dialog.fieldList.currentRow() - if row == -1: - return - if len(self.m.fieldModels) < 2: - ui.utils.showInfo( - _("Please add a new field first."), - parent=self) - return - field = self.m.fieldModels[row] - count = self.deck.fieldModelUseCount(field) - if count: - if not ui.utils.askUser( - _("This field is used by %d cards. If you delete it,\n" - "all information in this field will be lost.\n" - "\nReally delete this field?") % count, - parent=self): - return - self.deck.deleteFieldModel(self.m, field) - self.currentField = None - self.updateFields() - # need to update q/a format - self.readCurrentCard() - - def moveFieldUp(self): - row = self.dialog.fieldList.currentRow() - if row == -1: - return - if row == 0: - return - field = self.m.fieldModels[row] - tField = self.m.fieldModels[row - 1] - self.m.fieldModels.remove(field) - self.m.fieldModels.insert(row - 1, field) - if field.id not in self.fieldOrdinalUpdatedIds: - self.fieldOrdinalUpdatedIds.append(field.id) - if tField.id not in self.fieldOrdinalUpdatedIds: - self.fieldOrdinalUpdatedIds.append(tField.id) - self.ignoreFieldUpdate = True - self.updateFields(row - 1) - self.ignoreFieldUpdate = False - - def moveFieldDown(self): - row = self.dialog.fieldList.currentRow() - if row == -1: - return - if row == len(self.m.fieldModels) - 1: - return - field = self.m.fieldModels[row] - tField = self.m.fieldModels[row + 1] - self.m.fieldModels.remove(field) - self.m.fieldModels.insert(row + 1, field) - if field.id not in self.fieldOrdinalUpdatedIds: - self.fieldOrdinalUpdatedIds.append(field.id) - if tField.id not in self.fieldOrdinalUpdatedIds: - self.fieldOrdinalUpdatedIds.append(tField.id) - self.ignoreFieldUpdate = True - self.updateFields(row + 1) - self.ignoreFieldUpdate = False - # Cards ########################################################################## @@ -236,8 +63,12 @@ class ModelProperties(QDialog): self.moveCardUp) self.connect(self.dialog.cardDown, SIGNAL("clicked()"), self.moveCardDown) - self.connect(self.dialog.cardName, SIGNAL("lostFocus()"), - self.updateCards) + self.connect(self.dialog.cardRename, SIGNAL("clicked()"), + self.renameCard) + + def renameCard(self): + self.needRebuild = True + self.updateCards() def updateCards(self, row = None): oldRow = self.dialog.cardList.currentRow() @@ -250,7 +81,7 @@ class ModelProperties(QDialog): status="" else: status=_("; disabled") - label = _("Card %(num)d (%(name)s): used %(cards)d times%(status)s") % { + label = _("%(name)s: used %(cards)d times%(status)s") % { 'num': n, 'name': card.name, 'status': status, @@ -274,49 +105,18 @@ class ModelProperties(QDialog): self.saveCurrentCard() self.readCurrentCard() - def formatToScreen(self, fmt): - fmt = fmt.replace("
", "
\n") - fmt = re.sub("%\((.+?)\)s", "{{\\1}}", fmt) - return fmt - - def screenToFormat(self, fmt): - fmt = fmt.replace("
\n", "
") - fmt = re.sub("{{(.+?)}}", "%(\\1)s", fmt) - return fmt - def readCurrentCard(self): if not len(self.m.cardModels): - self.dialog.cardEditBox.hide() self.dialog.cardToggle.setEnabled(False) self.dialog.cardDelete.setEnabled(False) self.dialog.cardUp.setEnabled(False) self.dialog.cardDown.setEnabled(False) return else: - self.dialog.cardEditBox.show() self.dialog.cardToggle.setEnabled(True) self.dialog.cardDelete.setEnabled(True) self.currentCard = self.m.cardModels[self.dialog.cardList.currentRow()] card = self.currentCard - self.dialog.cardName.setText(card.name) - self.dialog.cardQuestion.setPlainText(self.formatToScreen(card.qformat)) - self.dialog.cardAnswer.setPlainText(self.formatToScreen(card.aformat)) - self.dialog.questionInAnswer.setChecked(card.questionInAnswer) - self.dialog.allowEmptyAnswer.setChecked(card.allowEmptyAnswer) - self.dialog.typeAnswer.clear() - self.fieldNames = self.deck.s.column0(""" -select fieldModels.name as n from fieldModels, cardModels -where cardModels.modelId = fieldModels.modelId -and cardModels.id = :id -order by n""", id=card.id) - s = [_("Don't ask me to type in the answer")] - s += [_("Compare with field '%s'") % f for f in self.fieldNames] - self.dialog.typeAnswer.insertItems(0, QStringList(s)) - try: - idx = self.fieldNames.index(card.typeAnswer) - except ValueError: - idx = -1 - self.dialog.typeAnswer.setCurrentIndex(idx + 1) self.updateToggleButtonText(card) def enableCardMoveButtons(self): @@ -340,22 +140,6 @@ order by n""", id=card.id) if not self.currentCard: return card = self.currentCard - newname = unicode(self.dialog.cardName.text()) - if not newname: - newname = _("Card-%d") % (self.m.cardModels.index(card) + 1) - self.updateField(card, 'name', newname) - s = unicode(self.dialog.cardQuestion.toPlainText()) - changed = self.updateField(card, 'qformat', self.screenToFormat(s)) - s = unicode(self.dialog.cardAnswer.toPlainText()) - changed2 = self.updateField(card, 'aformat', self.screenToFormat(s)) - self.needRebuild = self.needRebuild or changed or changed2 - self.updateField(card, 'questionInAnswer', self.dialog.questionInAnswer.isChecked()) - self.updateField(card, 'allowEmptyAnswer', self.dialog.allowEmptyAnswer.isChecked()) - idx = self.dialog.typeAnswer.currentIndex() - if not idx: - self.updateField(card, 'typeAnswer', u"") - else: - self.updateField(card, 'typeAnswer', self.fieldNames[idx-1]) self.ignoreCardUpdate = True self.updateCards() self.ignoreCardUpdate = False @@ -370,13 +154,11 @@ order by n""", id=card.id) def addCard(self): cards = len(self.m.cardModels) - name = _("Card %d") % (cards+1) + name = _("Name_%d") % (cards+1) cm = CardModel(name=name) self.m.addCardModel(cm) self.updateCards() self.dialog.cardList.setCurrentRow(len(self.m.cardModels)-1) - self.dialog.cardName.setFocus() - self.dialog.cardName.selectAll() def deleteCard(self): row = self.dialog.cardList.currentRow() @@ -491,18 +273,12 @@ order by n""", id=card.id) pass # before field, or it's overwritten self.saveCurrentCard() - self.saveCurrentField() - # rebuild ordinals if changed - if len(self.fieldOrdinalUpdatedIds) > 0: - self.deck.rebuildFieldOrdinals(self.m.id, self.fieldOrdinalUpdatedIds) - self.m.setModified() - self.deck.setModified() + # if changed, reset deck + reset = False if len(self.cardOrdinalUpdatedIds) > 0: self.deck.rebuildCardOrdinals(self.cardOrdinalUpdatedIds) self.m.setModified() self.deck.setModified() - # if changed, reset deck - reset = False if self.origModTime != self.deck.modified: self.deck.updateTagsForModel(self.m) reset = True diff --git a/designer/cardlist.ui b/designer/cardlist.ui index 7e30c8fca..949ab3757 100644 --- a/designer/cardlist.ui +++ b/designer/cardlist.ui @@ -161,6 +161,12 @@ QFrame::Raised + + 0 + + + 2 + diff --git a/designer/clayout.ui b/designer/clayout.ui new file mode 100644 index 000000000..62998d1f9 --- /dev/null +++ b/designer/clayout.ui @@ -0,0 +1,571 @@ + + + Dialog + + + + 0 + 0 + 640 + 464 + + + + Dialog + + + + + + + + Preview + + + + 6 + + + 6 + + + + + + 0 + 0 + + + + true + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close|QDialogButtonBox::Help + + + + + + + + 0 + 0 + + + + 0 + + + + Card Templates + + + + + + 0 + + + 6 + + + + + + 0 + 0 + + + + + 50 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + Qt::ScrollBarAlwaysOff + + + true + + + false + + + + + + + Template + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + 0 + 0 + + + + + + + + &Edit + + + + + + + + + + + Question + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + &nbsp;&nbsp;&nbsp;<a href="#">(flip)</a> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Answer + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + Alignment + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + Background + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + false + + + + + + + + + + + + Hide the question when showing answer + + + + + + + Allow the answer to be blank + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Fields + + + + + + + + + 0 + 0 + + + + + 50 + 60 + + + + + + + + + + &Add + + + false + + + + + + + Move selected field up + + + &Up + + + false + + + + + + + Move selected field down + + + Dow&n + + + false + + + + + + + &Delete + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 0 + + + 6 + + + + + + + + Name + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Font + + + + + + + Size + + + + + + + Color + + + + + + + + 0 + 25 + + + + + + + + true + + + + + + false + + + + + + + + + Reviewing + + + + + + + 5 + + + 300 + + + 14 + + + + + + + Editing + + + + + + + 5 + + + 300 + + + 14 + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + Options + + + + + + + Reverse text direction (RTL) + + + + + + + Sort as numbers in browser + + + + + + + Prevent empty entries + + + + + + + Prevent duplicates + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/designer/deckproperties.ui b/designer/deckproperties.ui index c02f788da..5967987fb 100644 --- a/designer/deckproperties.ui +++ b/designer/deckproperties.ui @@ -9,8 +9,8 @@ 0 0 - 419 - 457 + 379 + 396 @@ -27,13 +27,13 @@ - Models && Priorities + Basic - <h1>Priorities</h1> + <b>Priorities</b> @@ -42,7 +42,7 @@ - <b>Very High Priority</b> + Very high priority true @@ -55,7 +55,7 @@ - <b>High Priority</b> + High priority true @@ -68,7 +68,7 @@ - <b>Low Priority</b> + Low priority true @@ -93,111 +93,99 @@ - + - <h1>Models</h1> + <b>Models</b> true - - - - - - 6 - - - 0 - - - - - &Add - - - false + + + + + + 0 + 0 + - - - - &Edit - - - false - - - - - - - &Delete - - - false - - + + + + + + &Add + + + false + + + + + + + &Edit + + + false + + + + + + + &Delete + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - - - Synchronisation - - - - - - - - label - - - <h1>Synchronisation</h1> - - - false - - - true - - - - - - - Synchronise this deck - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - + + + + Synchronize this deck with AnkiWeb + + + + + + + label + + + <b>Synchronization</b> + + + false + + + true + + @@ -212,13 +200,6 @@ 6 - - - - <h1>Advanced</h1> - - - @@ -227,88 +208,130 @@ 6 - - + + + + + 0 + 0 + + + - + Min - + Min - - + + + + + 0 + 0 + + + - + - <b>4: Initial Easy Interval</b> + Initial button 4 interval - + - <b>3: Initial Good Interval</b> + Initial button 3 interval - + Max - - + + + + + 0 + 0 + + + - - + + + + + 0 + 0 + + + - + Max - - + + + + + 0 + 0 + + + - - + + + + + 0 + 0 + + + - + Min - + Max - + - <b>2: Initial Hard Interval</b> + Initial button 2 interval - + @@ -318,88 +341,111 @@ - - - - <b>1: Extra Mature Delay</b> - - - true - - - - - - - - 0 - 0 - - - - - - - - <b>1: Failure Multiplier</b> - - - true - - - - - - - - 0 - 0 - - - - - <b>1: Again Delay</b> + Button 1 delay - + mins - - - - days - - - - + days - + days - + days + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Button 1 multiplier + + + true + + + + + + + Mature bonus + + + true + + + + + + + days + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + @@ -414,7 +460,7 @@ - <b>New day starts at</b> + New day starts at @@ -437,7 +483,7 @@ - <b>Show failed cards early</b> + Show failed cards early true @@ -467,7 +513,7 @@ - <b>Suspend leeches</b> + Suspend leeches @@ -481,7 +527,7 @@ - <b>Leech failure threshold</b> + Leech failure threshold @@ -491,7 +537,7 @@ - <b>Per-day scheduling</b> + Per-day scheduling @@ -535,6 +581,7 @@ qtabwidget + doSync modelsList modelsAdd modelsEdit @@ -542,10 +589,10 @@ highPriority medPriority lowPriority - doSync + buttonBox delay0 - delay1 delay2 + delay1 hardMin hardMax midMin @@ -557,7 +604,6 @@ timeOffset suspendLeeches leechFails - buttonBox diff --git a/designer/displayproperties.ui b/designer/displayproperties.ui deleted file mode 100644 index f14ee7dc5..000000000 --- a/designer/displayproperties.ui +++ /dev/null @@ -1,741 +0,0 @@ - - - DisplayProperties - - - - 0 - 0 - 818 - 427 - - - - - 0 - 0 - - - - Fonts & Colours - - - - :/icons/fonts.png:/icons/fonts.png - - - - 6 - - - 9 - - - - - 0 - - - 12 - - - - - - 0 - 0 - - - - - 360 - 0 - - - - - 360 - 16777215 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 6 - - - 0 - - - - - 7 - - - 0 - - - - - - - - 0 - - - 6 - - - - - - - - - - 0 - 0 - - - - 0 - - - - Cards - - - - - - - - - 0 - 0 - - - - Card: - - - - - - - - - - - - Qt::Horizontal - - - - - - - 0 - - - 5 - - - - - Question font - - - - - - - - - - false - - - - - - - Answer size - - - - - - - Answer colour - - - - - - - Answer font - - - - - - - - - - Question alignment - - - - - - - Question size - - - - - - - 300 - - - - - - - - - - - - - false - - - - - - - 300 - - - - - - - Question colour - - - - - - - Answer alignment - - - - - - - - - - - 0 - 0 - - - - - - - - Background colour - - - - - - - - - - false - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Fields - - - - - - - 0 - 0 - - - - - 0 - 60 - - - - - - - - <b>When reviewing and editing:</b> - - - - - - - 0 - - - 5 - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Use custom size - - - - - - - - 0 - 25 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Use custom font - - - - - - - 5 - - - 300 - - - 14 - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Use custom colour - - - - - - - true - - - - - - false - - - - - - - - - <b>When editing (overrides above):</b> - - - - - - - 0 - - - 5 - - - - - 5 - - - 300 - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Use custom size - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Use custom font - - - - - - - Right to Left (RTL) - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Help - - - false - - - - - - - Show preview - - - true - - - false - - - - - - - Close - - - false - - - - - - - - - - - - - - - - Preview - - - - 6 - - - 6 - - - - - - 0 - 0 - - - - true - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - - - tabWidget - cardList - questionFont - questionSize - questionColour - questionAlign - answerFont - answerSize - answerColour - answerAlign - backgroundColour - fieldList - useFamily - fontFamily - useSize - fontSize - useColour - fontColour - useFamilyEdit - fontFamilyEdit - useSizeEdit - fontSizeEdit - rtl - helpButton - preview - closeButton - question - answer - - - - - - - closeButton - clicked() - DisplayProperties - reject() - - - 315 - 385 - - - 325 - 525 - - - - - useFamily - toggled(bool) - fontFamily - setEnabled(bool) - - - 107 - 187 - - - 178 - 194 - - - - - useSize - toggled(bool) - fontSize - setEnabled(bool) - - - 134 - 226 - - - 205 - 224 - - - - - useColour - toggled(bool) - fontColour - setEnabled(bool) - - - 93 - 256 - - - 175 - 253 - - - - - useFamilyEdit - toggled(bool) - fontFamilyEdit - setEnabled(bool) - - - 122 - 299 - - - 215 - 301 - - - - - useSizeEdit - toggled(bool) - fontSizeEdit - setEnabled(bool) - - - 129 - 340 - - - 210 - 337 - - - - - diff --git a/designer/main.ui b/designer/main.ui index b61c1a522..6ba20ae2c 100644 --- a/designer/main.ui +++ b/designer/main.ui @@ -3135,7 +3135,6 @@ - diff --git a/designer/modelproperties.ui b/designer/modelproperties.ui index 13261a71c..d58f70113 100644 --- a/designer/modelproperties.ui +++ b/designer/modelproperties.ui @@ -9,8 +9,8 @@ 0 0 - 420 - 551 + 471 + 435 @@ -18,465 +18,173 @@ - - - 0 + + + General - - - General && Fields - - - - 6 - - - 9 - - - - - <h1>General</h1> - - - - - - - 4 - - - 4 - - - - - <b>Name</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - <b>Minimum spacing</b> - - - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Spacing multiplier</span></p></body></html> - - - true - - - - - - - - - - - - - - - - - - - - - <b>Media URL</B> - - - - - - - - - - - - Qt::Horizontal - - - - - - - <h1>Fields</h1> - - - - - - - 6 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 60 - - - - - - - - - - - - &Add - - - false - - - - - - - Move selected field up - - - Move &Up - - - false - - - - - - - Move selected field down - - - Move Dow&n - - - false - - - - - - - &Delete - - - false - - - - - - - - - - - - false - - + + + + + 4 + + + 4 + + + + + Name + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + Minimum spacing + + + true + + + + + + + Spacing multiplier + + + true + + + + + - - - 0 - - - 6 - - - - - <b>Options</b> - - - - - - - - - - Prevent duplicates - - - - - - - <b>Name</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Prevent empty entries - - - - - - - Sort as numbers - - - - + - - - - - - - Card Templates - - - - - - <h1>Card Templates</h1> - - - - - - - 6 - - - 0 - - - - - - 0 - 1 - - - - - 0 - 60 - - - - - - - - - - - - &Add - - - - - - - Move selected card model up - - - Move &Up - - - - - - - Move selected card model down - - - Move Dow&n - - - - - - - - - - - - - - &Delete - - - - - - - - - - 0 - 0 - - - - - - + + + - - - 0 - - - 6 - - - - - <b>Options</b> - - - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - false - - - - - - - <b>Answer</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - true - - - - - - - <b>Name</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - <b>Question</b> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - - - - Hide the question when showing answer - - - - - - - Allow the answer to be blank - - - - + - - - - + + + + + Media URL + + + + + + + + + + + + + + + Card Templates + + + + + + + + + 0 + 1 + + + + + 0 + 60 + + + + + + + + + + &Add + + + + + + + &Rename + + + + + + + Move selected card model up + + + &Up + + + + + + + Move selected card model down + + + Dow&n + + + + + + + + + + + + + + &Delete + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + @@ -490,38 +198,7 @@ p, li { white-space: pre-wrap; } - buttonBox - tabWidget - - tabWidget - name - initialSpacing - spacing - mediaURL - fieldList - fieldAdd - fieldUp - fieldDown - fieldDelete - fieldName - fieldUnique - fieldRequired - numeric - cardList - cardAdd - cardUp - cardDown - cardToggle - cardDelete - cardName - cardQuestion - cardAnswer - typeAnswer - questionInAnswer - allowEmptyAnswer - buttonBox - diff --git a/designer/previewcards.ui b/designer/previewcards.ui deleted file mode 100644 index e4f667240..000000000 --- a/designer/previewcards.ui +++ /dev/null @@ -1,82 +0,0 @@ - - Dialog - - - - 0 - 0 - 400 - 300 - - - - Preview Cards - - - - - - - - - - about:blank - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - QWebView - QWidget -
QtWebKit/QWebView
-
-
- - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/tools/build_ui.sh b/tools/build_ui.sh index ce6a32497..b7531555a 100755 --- a/tools/build_ui.sh +++ b/tools/build_ui.sh @@ -68,7 +68,7 @@ cat $temp >> $init rm $temp # use older integer format so qt4.4 still works -sed -i 's/setProperty("value", 14)/setProperty("value", QtCore.QVariant(14))/' ankiqt/forms/displayproperties.py +#sed -i 's/setProperty("value", 14)/setProperty("value", QtCore.QVariant(14))/' ankiqt/forms/displayproperties.py echo "Building resources.." $pyrcc icons.qrc -o icons_rc.py