split template selection into separate dialog, add manage button in card layout

This commit is contained in:
Damien Elmes 2011-04-01 13:09:49 +09:00
parent 56e6e3bb52
commit 058f5e6efc
9 changed files with 503 additions and 468 deletions

View file

@ -9,8 +9,9 @@ from anki.consts import *
import aqt import aqt
from anki.sound import playFromText, clearAudioQueue from anki.sound import playFromText, clearAudioQueue
from aqt.utils import saveGeom, restoreGeom, getBase, mungeQA, \ from aqt.utils import saveGeom, restoreGeom, getBase, mungeQA, \
saveSplitter, restoreSplitter, showInfo, isMac, isWin, askUser saveSplitter, restoreSplitter, showInfo, isMac, isWin, askUser, \
from anki.hooks import runFilter getText
import aqt.templates
class ResizingTextEdit(QTextEdit): class ResizingTextEdit(QTextEdit):
def sizeHint(self): def sizeHint(self):
@ -30,11 +31,10 @@ class CardLayout(QDialog):
self.model = fact.model() self.model = fact.model()
self.form = aqt.forms.clayout.Ui_Dialog() self.form = aqt.forms.clayout.Ui_Dialog()
self.form.setupUi(self) self.form.setupUi(self)
self.setWindowTitle(_("%s Layout") % self.model.name)
self.plastiqueStyle = None self.plastiqueStyle = None
if isMac or isWin: if isMac or isWin:
self.plastiqueStyle = QStyleFactory.create("plastique") self.plastiqueStyle = QStyleFactory.create("plastique")
# FIXME: add editing
self.form.editTemplates.hide()
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
self.onHelp) self.onHelp)
self.setupCards() self.setupCards()
@ -52,6 +52,12 @@ class CardLayout(QDialog):
def reload(self): def reload(self):
self.cards = self.deck.previewCards(self.fact, self.type) self.cards = self.deck.previewCards(self.fact, self.type)
if not self.cards:
self.accept()
showInfo(_(
"The current fact was deleted."))
self
return
self.fillCardList() self.fillCardList()
self.fillFieldList() self.fillFieldList()
self.fieldChanged() self.fieldChanged()
@ -84,11 +90,9 @@ class CardLayout(QDialog):
w = ResizingTextEdit(self) w = ResizingTextEdit(self)
setattr(f, e, w) setattr(f, e, w)
f.templateLayout.addWidget(w, r[0], r[1]) f.templateLayout.addWidget(w, r[0], r[1])
self.connect(f.cardList, SIGNAL("activated(int)"),
self.cardChanged)
# self.connect(f.editTemplates, SIGNAL("clicked())"),
# self.onEdit)
c = self.connect c = self.connect
c(f.cardList, SIGNAL("activated(int)"), self.cardChanged)
c(f.editTemplates, SIGNAL("clicked()"), self.onEdit)
c(f.cardQuestion, SIGNAL("textChanged()"), self.formatChanged) c(f.cardQuestion, SIGNAL("textChanged()"), self.formatChanged)
c(f.cardAnswer, SIGNAL("textChanged()"), self.formatChanged) c(f.cardAnswer, SIGNAL("textChanged()"), self.formatChanged)
c(f.alignment, SIGNAL("activated(int)"), self.saveCard) c(f.alignment, SIGNAL("activated(int)"), self.saveCard)
@ -124,10 +128,9 @@ class CardLayout(QDialog):
fmt = fmt.replace("}}\n", "}}<br>") fmt = fmt.replace("}}\n", "}}<br>")
return fmt return fmt
# def onEdit(self): def onEdit(self):
# ui.modelproperties.ModelProperties( aqt.templates.Templates(self.mw, self.model, self)
# self, self.deck, self.model, self.mw, self.reload()
# onFinish=self.updateModelsList)
def formatChanged(self): def formatChanged(self):
if self.updatingCards: if self.updatingCards:
@ -172,7 +175,6 @@ class CardLayout(QDialog):
cards.append(c.template()['name']) cards.append(c.template()['name'])
self.form.cardList.addItems( self.form.cardList.addItems(
QStringList(cards)) QStringList(cards))
self.form.editTemplates.setEnabled(False)
self.form.cardList.setCurrentIndex(idx) self.form.cardList.setCurrentIndex(idx)
self.cardChanged(idx) self.cardChanged(idx)
self.form.cardList.setFocus() self.form.cardList.setFocus()
@ -232,10 +234,14 @@ class CardLayout(QDialog):
return "<center><input type=text></center>" return "<center><input type=text></center>"
return "" return ""
def accept(self):
self.reject()
def reject(self): def reject(self):
self.model.flush() self.model.flush()
saveGeom(self, "CardLayout") saveGeom(self, "CardLayout")
saveSplitter(self.form.splitter, "clayout") saveSplitter(self.form.splitter, "clayout")
self.mw.reset()
return QDialog.reject(self) return QDialog.reject(self)
self.fact.model.setModified() self.fact.model.setModified()

View file

@ -677,6 +677,9 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
def onDonate(self): def onDonate(self):
QDesktopServices.openUrl(QUrl(aqt.appDonate)) QDesktopServices.openUrl(QUrl(aqt.appDonate))
def onDocumentation(self):
QDesktopServices.openUrl(QUrl(aqt.appHelpSite))
# Importing & exporting # Importing & exporting
########################################################################## ##########################################################################
@ -785,6 +788,7 @@ Please choose a new deck name:"""))
self.connect(m.actionStudyOptions, s, self.onStudyOptions) self.connect(m.actionStudyOptions, s, self.onStudyOptions)
self.connect(m.actionOverview, s, self.onOverview) self.connect(m.actionOverview, s, self.onOverview)
self.connect(m.actionGroups, s, self.onGroups) self.connect(m.actionGroups, s, self.onGroups)
self.connect(m.actionDocumentation, s, self.onDocumentation)
self.connect(m.actionDonate, s, self.onDonate) self.connect(m.actionDonate, s, self.onDonate)
self.connect(m.actionBuryFact, s, self.onBuryFact) self.connect(m.actionBuryFact, s, self.onBuryFact)

View file

@ -3,7 +3,7 @@
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
from aqt.utils import showInfo, askUser from aqt.utils import showInfo, askUser, getText
import aqt.modelchooser, aqt.clayout import aqt.modelchooser, aqt.clayout
class Models(QDialog): class Models(QDialog):
@ -13,13 +13,11 @@ class Models(QDialog):
QDialog.__init__(self, self.parent, Qt.Window) QDialog.__init__(self, self.parent, Qt.Window)
self.deck = mw.deck self.deck = mw.deck
self.mw.checkpoint(_("Models")) self.mw.checkpoint(_("Models"))
#self.m = model
self.form = aqt.forms.models.Ui_Dialog() self.form = aqt.forms.models.Ui_Dialog()
self.form.setupUi(self) self.form.setupUi(self)
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"), self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
lambda: openHelp("Models")) lambda: aqt.openHelp("Models"))
self.setupModels() self.setupModels()
self.setupCards()
self.exec_() self.exec_()
# Models # Models
@ -27,14 +25,29 @@ class Models(QDialog):
def setupModels(self): def setupModels(self):
self.model = None self.model = None
c = self.connect; f = self.form; s = SIGNAL("clicked()") c = self.connect; f = self.form; box = f.buttonBox
c(f.modelsAdd, s, self.onAdd) s = SIGNAL("clicked()")
c(f.modelsLayout, s, self.onLayout) t = QDialogButtonBox.ActionRole
c(f.modelsDelete, s, self.onDelete) b = box.addButton(_("Layout..."), t)
self.connect(self.form.modelsList, SIGNAL("currentRowChanged(int)"), c(b, s, self.onLayout)
self.modelChanged) b.setDefault(True)
b = box.addButton(_("Add"), t)
c(b, s, self.onAdd)
b = box.addButton(_("Rename"), t)
c(b, s, self.onRename)
b = box.addButton(_("Delete"), t)
c(b, s, self.onDelete)
c(f.modelsList, SIGNAL("currentRowChanged(int)"), self.modelChanged)
c(f.modelsList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"),
self.onRename)
self.updateModelsList()
f.modelsList.setCurrentRow(0)
def onRename(self):
txt = getText(_("New name?"), default=self.model.name)
if txt[0]:
self.model.name = txt[0]
self.updateModelsList() self.updateModelsList()
self.form.modelsList.setCurrentRow(0)
def updateModelsList(self): def updateModelsList(self):
row = self.form.modelsList.currentRow() row = self.form.modelsList.currentRow()
@ -54,7 +67,6 @@ class Models(QDialog):
self.saveModel() self.saveModel()
idx = self.form.modelsList.currentRow() idx = self.form.modelsList.currentRow()
self.model = self.models[idx] self.model = self.models[idx]
self.updateCards()
def onAdd(self): def onAdd(self):
m = aqt.modelchooser.AddModel(self.mw, self).get() m = aqt.modelchooser.AddModel(self.mw, self).get()
@ -98,90 +110,6 @@ class Models(QDialog):
def saveModel(self): def saveModel(self):
self.model.flush() self.model.flush()
# Cards
##########################################################################
def setupCards(self):
f = self.form; c = self.connect; s = SIGNAL("clicked()")
c(f.cardList, SIGNAL("currentRowChanged(int)"),
self.cardRowChanged)
c(f.cardList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"),
self.renameCard)
c(f.cardAdd, s, self.addCard)
c(f.cardDelete, s, self.deleteCard)
c(f.cardUp, s, self.moveCardUp)
c(f.cardDown, s, self.moveCardDown)
self.updateCards()
def renameCard(self, item):
txt = ui.utils.getText(_("New name?"), parent=self)
if txt[0]:
self.template['name'] = txt[0]
def updateCards(self, row = None):
row = self.form.cardList.currentRow() or 0
if row == -1:
row = 0
self.form.cardList.clear()
for card in self.model.templates:
item = QListWidgetItem(card['name'])
self.form.cardList.addItem(item)
count = self.form.cardList.count()
self.form.cardList.setCurrentRow(row)
def cardRowChanged(self):
self.template = self.model.templates[self.form.cardList.currentRow()]
self.enableCardMoveButtons()
def enableCardMoveButtons(self):
f = self.form
row = f.cardList.currentRow()
f.cardUp.setEnabled(row >= 1)
f.cardDown.setEnabled(row < (f.cardList.count() - 1))
def addCard(self):
cards = len(self.model.templates)
t = self.model.newTemplate()
t['name'] = _("Template %d") % (cards+1)
fields = self.model.fields
t['qfmt'] = "{{%s}}" % fields[0]['name']
if len(fields) > 1:
t['afmt'] = "{{%s}}" % fields[1]['name']
else:
t['afmt'] = ""
self.model.addTemplate(t)
self.updateCards()
def deleteCard(self):
if len (self.model.templates) < 2:
ui.utils.showWarning(
_("Please add a new template first."),
parent=self)
return
if not askUser(
_("Delete this template and all cards that use it?")):
return
self.model.delTemplate(self.template)
self.updateCards()
def moveCardUp(self):
row = self.form.cardList.currentRow()
if row == 0:
return
self.mw.progress.start()
self.model.moveTemplate(self.template, row-1)
self.mw.progress.finish()
self.updateCards()
def moveCardDown(self):
row = self.form.cardList.currentRow()
if row == len(self.model.templates) - 1:
return
self.mw.progress.start()
self.model.moveTemplate(self.template, row+1)
self.mw.progress.finish()
self.updateCards()
# Cleanup # Cleanup
########################################################################## ##########################################################################

106
aqt/templates.py Normal file
View file

@ -0,0 +1,106 @@
# Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import aqt
from aqt.utils import saveGeom, restoreGeom, askUser, getText
class Templates(QDialog):
def __init__(self, mw, model, parent=None):
self.parent = parent or mw
QDialog.__init__(self, self.parent, Qt.Window)
self.mw = aqt.mw
self.model = model
self.form = aqt.forms.templates.Ui_Dialog()
self.form.setupUi(self)
self.setWindowTitle(_("%s Templates") % self.model.name)
self.setupTemplates()
self.updateTemplates()
self.exec_()
# Templates
##########################################################################
def setupTemplates(self):
f = self.form; c = self.connect; s = SIGNAL("clicked()")
c(f.templateList, SIGNAL("currentRowChanged(int)"),
self.templateRowChanged)
c(f.templateList, SIGNAL("itemDoubleClicked(QListWidgetItem*)"),
self.renameTemplate)
c(f.templateAdd, s, self.addTemplate)
c(f.templateDelete, s, self.deleteTemplate)
c(f.templateUp, s, self.moveTemplateUp)
c(f.templateDown, s, self.moveTemplateDown)
def renameTemplate(self, item):
txt = getText(_("New name?"), default=self.template['name'])
if txt[0]:
self.template['name'] = txt[0]
def updateTemplates(self, row = None):
row = self.form.templateList.currentRow() or 0
if row == -1:
row = 0
self.form.templateList.clear()
for template in self.model.templates:
item = QListWidgetItem(template['name'])
self.form.templateList.addItem(item)
count = self.form.templateList.count()
self.form.templateList.setCurrentRow(row)
def templateRowChanged(self):
self.template = self.model.templates[self.form.templateList.currentRow()]
self.enableTemplateMoveButtons()
def enableTemplateMoveButtons(self):
f = self.form
row = f.templateList.currentRow()
f.templateUp.setEnabled(row >= 1)
f.templateDown.setEnabled(row < (f.templateList.count() - 1))
def addTemplate(self):
templates = len(self.model.templates)
t = self.model.newTemplate()
t['name'] = _("Template %d") % (templates+1)
fields = self.model.fields
t['qfmt'] = "{{%s}}" % fields[0]['name']
if len(fields) > 1:
t['afmt'] = "{{%s}}" % fields[1]['name']
else:
t['afmt'] = ""
self.model.addTemplate(t)
self.updateTemplates()
def deleteTemplate(self):
if len (self.model.templates) < 2:
ui.utils.showWarning(
_("Please add a new template first."),
parent=self)
return
if not askUser(
_("Delete this template and all cards that use it?")):
return
self.model.delTemplate(self.template)
self.updateTemplates()
def moveTemplateUp(self):
row = self.form.templateList.currentRow()
if row == 0:
return
self.mw.progress.start()
self.model.moveTemplate(self.template, row-1)
self.mw.progress.finish()
self.updateTemplates()
self.form.templateList.setCurrentRow(row-1)
def moveTemplateDown(self):
row = self.form.templateList.currentRow()
if row == len(self.model.templates) - 1:
return
self.mw.progress.start()
self.model.moveTemplate(self.template, row+1)
self.mw.progress.finish()
self.updateTemplates()
self.form.templateList.setCurrentRow(row+1)

View file

@ -6,12 +6,12 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>472</width> <width>759</width>
<height>531</height> <height>560</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Card Layout</string> <string/>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
@ -37,11 +37,14 @@
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
<string>Card Templates</string> <string>Appearance</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="templateLayout"> <layout class="QGridLayout" name="templateLayout">
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QTextEdit" name="cardQuestion"> <widget class="QTextEdit" name="cardQuestion">
<property name="sizePolicy"> <property name="sizePolicy">
@ -89,27 +92,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="cardList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editTemplates">
<property name="text">
<string>&amp;Edit</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" rowspan="2"> <item row="3" column="0" rowspan="2">
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_6">
<item> <item>
@ -191,6 +173,30 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="cardList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editTemplates">
<property name="text">
<string>&amp;Manage...</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View file

@ -47,6 +47,7 @@
<property name="title"> <property name="title">
<string>&amp;Help</string> <string>&amp;Help</string>
</property> </property>
<addaction name="actionDocumentation"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionDonate"/> <addaction name="actionDonate"/>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
@ -59,7 +60,6 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionAddcards"/> <addaction name="actionAddcards"/>
<addaction name="actionEditCurrent"/> <addaction name="actionEditCurrent"/>
<addaction name="actionEditLayout"/>
<addaction name="actionEditdeck"/> <addaction name="actionEditdeck"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMarkCard"/> <addaction name="actionMarkCard"/>
@ -147,8 +147,10 @@
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<addaction name="actionOverview"/> <addaction name="actionOverview"/>
<addaction name="actionEditLayout"/>
<addaction name="actionGroups"/> <addaction name="actionGroups"/>
<addaction name="actionModels"/> <addaction name="actionModels"/>
<addaction name="separator"/>
<addaction name="actionStudyOptions"/> <addaction name="actionStudyOptions"/>
<addaction name="actionDeckProperties"/> <addaction name="actionDeckProperties"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -279,7 +281,7 @@
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset> <normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Add Items...</string> <string>&amp;Add...</string>
</property> </property>
<property name="statusTip"> <property name="statusTip">
<string/> <string/>
@ -294,7 +296,7 @@
<normaloff>:/icons/find.png</normaloff>:/icons/find.png</iconset> <normaloff>:/icons/find.png</normaloff>:/icons/find.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Brows&amp;e Items...</string> <string>&amp;Browse...</string>
</property> </property>
<property name="statusTip"> <property name="statusTip">
<string/> <string/>
@ -516,7 +518,7 @@
<normaloff>:/icons/edit-rename.png</normaloff>:/icons/edit-rename.png</iconset> <normaloff>:/icons/edit-rename.png</normaloff>:/icons/edit-rename.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Current Fact...</string> <string>&amp;Edit Current...</string>
</property> </property>
<property name="statusTip"> <property name="statusTip">
<string/> <string/>
@ -646,7 +648,7 @@
<normaloff>:/icons/layout.png</normaloff>:/icons/layout.png</iconset> <normaloff>:/icons/layout.png</normaloff>:/icons/layout.png</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Card Layout...</string> <string>Layout...</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>L</string> <string>L</string>
@ -685,6 +687,14 @@
<string>Ctrl+M</string> <string>Ctrl+M</string>
</property> </property>
</action> </action>
<action name="actionDocumentation">
<property name="text">
<string>Documentation...</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc"/> <include location="icons.qrc"/>

View file

@ -9,14 +9,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>425</width> <width>396</width>
<height>446</height> <height>255</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Models</string> <string>Models</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5" stretch="100,0">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
@ -41,51 +41,14 @@
<number>12</number> <number>12</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="modelsAdd"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="text">
<string>&amp;Add</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modelsDelete">
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="modelsLayout">
<property name="text">
<string>&amp;Layout...</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/layout.png</normaloff>:/icons/layout.png</iconset>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="standardButtons">
<size> <set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
<width>20</width>
<height>40</height>
</size>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -107,152 +70,10 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>10</verstretch>
</sizepolicy>
</property>
<property name="title">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sort Field</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="sortField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Card Templates</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QListWidget" name="cardList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="cardAdd">
<property name="text">
<string>&amp;Add</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cardUp">
<property name="text">
<string>&amp;Up</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cardDown">
<property name="text">
<string>Dow&amp;n</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cardDelete">
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>modelsList</tabstop> <tabstop>modelsList</tabstop>
<tabstop>modelsAdd</tabstop>
<tabstop>modelsDelete</tabstop>
<tabstop>modelsLayout</tabstop>
<tabstop>sortField</tabstop>
<tabstop>cardList</tabstop>
<tabstop>cardAdd</tabstop>
<tabstop>cardUp</tabstop>
<tabstop>cardDown</tabstop>
<tabstop>cardDelete</tabstop>
<tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="icons.qrc"/> <include location="icons.qrc"/>

View file

@ -6,159 +6,170 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>380</width> <width>382</width>
<height>291</height> <height>319</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Study Options</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item row="4" column="0"> <item>
<widget class="QLabel" name="label_2"> <layout class="QGridLayout" name="gridLayout">
<property name="text"> <item row="4" column="0">
<string>Next day starts at</string> <widget class="QLabel" name="label_2">
</property> <property name="text">
</widget> <string>Next day starts at</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="dayOffset">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="maximum">
<number>23</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Learn ahead limit</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="lrnCutoff">
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>mins</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>New cards/day</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="newPerDay">
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QComboBox" name="newOrder"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QComboBox" name="newSpread"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QComboBox" name="revOrder"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Timebox question limit</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Timebox time limit</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="questionLimit">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="timeLimit">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>mins</string>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
<item row="4" column="1"> <item>
<widget class="QSpinBox" name="dayOffset"> <layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,5">
<property name="maximumSize"> <item>
<size> <widget class="QDialogButtonBox" name="buttonBox">
<width>60</width> <property name="orientation">
<height>16777215</height> <enum>Qt::Vertical</enum>
</size> </property>
</property> <property name="standardButtons">
<property name="maximum"> <set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<number>23</number> </property>
</property> </widget>
</widget> </item>
</item> <item>
<item row="5" column="0"> <spacer name="verticalSpacer_2">
<widget class="QLabel" name="label_4"> <property name="orientation">
<property name="text"> <enum>Qt::Vertical</enum>
<string>Learn ahead limit</string> </property>
</property> <property name="sizeHint" stdset="0">
</widget> <size>
</item> <width>20</width>
<item row="5" column="1"> <height>40</height>
<widget class="QSpinBox" name="lrnCutoff"> </size>
<property name="maximumSize"> </property>
<size> </spacer>
<width>60</width> </item>
<height>16777215</height> </layout>
</size>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>mins</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>New cards/day</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="newPerDay">
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QComboBox" name="newOrder"/>
</item>
<item row="2" column="0" colspan="3">
<widget class="QComboBox" name="newSpread"/>
</item>
<item row="3" column="0" colspan="3">
<widget class="QComboBox" name="revOrder"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Timebox question limit</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Timebox time limit</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QSpinBox" name="questionLimit">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QSpinBox" name="timeLimit">
<property name="maximum">
<number>9999</number>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>mins</string>
</property>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,5"> <widget class="QLabel" name="label_3">
<item> <property name="text">
<widget class="QDialogButtonBox" name="buttonBox"> <string>More study options are available in the group settings.</string>
<property name="orientation"> </property>
<enum>Qt::Vertical</enum> </widget>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

143
designer/templates.ui Normal file
View file

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="QListWidget" name="templateList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QPushButton" name="templateAdd">
<property name="text">
<string>&amp;Add</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="templateUp">
<property name="text">
<string>&amp;Up</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="templateDown">
<property name="text">
<string>Dow&amp;n</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="templateDelete">
<property name="text">
<string>&amp;Delete</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="icons.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>