mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
add 'note types' to main menu
This commit is contained in:
parent
a35ce1fd8e
commit
ce4c62fcbb
3 changed files with 37 additions and 1 deletions
|
@ -695,6 +695,10 @@ and check the statistics for a home deck instead."""))
|
||||||
import aqt.preferences
|
import aqt.preferences
|
||||||
aqt.preferences.Preferences(self)
|
aqt.preferences.Preferences(self)
|
||||||
|
|
||||||
|
def onNoteTypes(self):
|
||||||
|
import aqt.models
|
||||||
|
aqt.models.Models(self, self, fromMain=True)
|
||||||
|
|
||||||
def onAbout(self):
|
def onAbout(self):
|
||||||
import aqt.about
|
import aqt.about
|
||||||
aqt.about.show(self)
|
aqt.about.show(self)
|
||||||
|
@ -760,6 +764,7 @@ and check the statistics for a home deck instead."""))
|
||||||
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
self.connect(m.actionStudyDeck, s, self.onStudyDeck)
|
||||||
self.connect(m.actionCreateFiltered, s, self.onCram)
|
self.connect(m.actionCreateFiltered, s, self.onCram)
|
||||||
self.connect(m.actionEmptyCards, s, self.onEmptyCards)
|
self.connect(m.actionEmptyCards, s, self.onEmptyCards)
|
||||||
|
self.connect(m.actionNoteTypes, s, self.onNoteTypes)
|
||||||
|
|
||||||
def updateTitleBar(self):
|
def updateTitleBar(self):
|
||||||
self.setWindowTitle("Anki")
|
self.setWindowTitle("Anki")
|
||||||
|
|
|
@ -9,9 +9,10 @@ from anki import stdmodels
|
||||||
from aqt.utils import saveGeom, restoreGeom
|
from aqt.utils import saveGeom, restoreGeom
|
||||||
|
|
||||||
class Models(QDialog):
|
class Models(QDialog):
|
||||||
def __init__(self, mw, parent=None):
|
def __init__(self, mw, parent=None, fromMain=False):
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.parent = parent or mw
|
self.parent = parent or mw
|
||||||
|
self.fromMain = fromMain
|
||||||
QDialog.__init__(self, self.parent, Qt.Window)
|
QDialog.__init__(self, self.parent, Qt.Window)
|
||||||
self.col = mw.col
|
self.col = mw.col
|
||||||
self.mm = self.col.models
|
self.mm = self.col.models
|
||||||
|
@ -38,6 +39,11 @@ class Models(QDialog):
|
||||||
c(b, s, self.onRename)
|
c(b, s, self.onRename)
|
||||||
b = box.addButton(_("Delete"), t)
|
b = box.addButton(_("Delete"), t)
|
||||||
c(b, s, self.onDelete)
|
c(b, s, self.onDelete)
|
||||||
|
if self.fromMain:
|
||||||
|
b = box.addButton(_("Fields..."), t)
|
||||||
|
c(b, s, self.onFields)
|
||||||
|
b = box.addButton(_("Cards..."), t)
|
||||||
|
c(b, s, self.onCards)
|
||||||
b = box.addButton(_("Options..."), t)
|
b = box.addButton(_("Options..."), t)
|
||||||
c(b, s, self.onAdvanced)
|
c(b, s, self.onAdvanced)
|
||||||
c(f.modelsList, SIGNAL("currentRowChanged(int)"), self.modelChanged)
|
c(f.modelsList, SIGNAL("currentRowChanged(int)"), self.modelChanged)
|
||||||
|
@ -115,6 +121,25 @@ class Models(QDialog):
|
||||||
def saveModel(self):
|
def saveModel(self):
|
||||||
self.mm.save(self.model)
|
self.mm.save(self.model)
|
||||||
|
|
||||||
|
def _tmpNote(self):
|
||||||
|
self.mm.setCurrent(self.model)
|
||||||
|
n = self.col.newNote()
|
||||||
|
for name in n.keys():
|
||||||
|
n[name] = "("+name+")"
|
||||||
|
if "{{cloze:Text}}" in self.model['tmpls'][0]['qfmt']:
|
||||||
|
n['Text'] = _("This is a {{c1::sample}} cloze deletion.")
|
||||||
|
return n
|
||||||
|
|
||||||
|
def onFields(self):
|
||||||
|
from aqt.fields import FieldDialog
|
||||||
|
n = self._tmpNote()
|
||||||
|
FieldDialog(self.mw, n, parent=self)
|
||||||
|
|
||||||
|
def onCards(self):
|
||||||
|
from aqt.clayout import CardLayout
|
||||||
|
n = self._tmpNote()
|
||||||
|
CardLayout(self.mw, n, ord=0, parent=self, addMode=True)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,7 @@
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="menuPlugins"/>
|
<addaction name="menuPlugins"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionNoteTypes"/>
|
||||||
<addaction name="actionPreferences"/>
|
<addaction name="actionPreferences"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuCol"/>
|
<addaction name="menuCol"/>
|
||||||
|
@ -257,6 +258,11 @@
|
||||||
<string>F</string>
|
<string>F</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionNoteTypes">
|
||||||
|
<property name="text">
|
||||||
|
<string>Note Types...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
Loading…
Reference in a new issue