mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
added jump menu to cardlist
This commit is contained in:
parent
890bbb8c0d
commit
aac727f2b5
8 changed files with 144 additions and 4 deletions
|
@ -396,6 +396,7 @@ class EditDeck(QMainWindow):
|
|||
self.dialog.tableView.horizontalHeader().setResizeMode(2, QHeaderView.ResizeToContents)
|
||||
|
||||
def setupMenus(self):
|
||||
# actions
|
||||
self.connect(self.dialog.actionDelete, SIGNAL("triggered()"), self.deleteCards)
|
||||
self.connect(self.dialog.actionAddTag, SIGNAL("triggered()"), self.addTags)
|
||||
self.connect(self.dialog.actionDeleteTag, SIGNAL("triggered()"), self.deleteTags)
|
||||
|
@ -405,6 +406,13 @@ class EditDeck(QMainWindow):
|
|||
self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection)
|
||||
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
|
||||
self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo)
|
||||
# jumps
|
||||
self.connect(self.dialog.actionFirstCard, SIGNAL("triggered()"), self.onFirstCard)
|
||||
self.connect(self.dialog.actionLastCard, SIGNAL("triggered()"), self.onLastCard)
|
||||
self.connect(self.dialog.actionPreviousCard, SIGNAL("triggered()"), self.onPreviousCard)
|
||||
self.connect(self.dialog.actionNextCard, SIGNAL("triggered()"), self.onNextCard)
|
||||
self.connect(self.dialog.actionFind, SIGNAL("triggered()"), self.onFind)
|
||||
self.connect(self.dialog.actionFact, SIGNAL("triggered()"), self.onFact)
|
||||
runHook('editor.setupMenus', self)
|
||||
|
||||
def onClose(self):
|
||||
|
@ -602,6 +610,43 @@ where id in (%s)""" % ",".join([
|
|||
self.updateSearch()
|
||||
self.updateAfterCardChange()
|
||||
|
||||
# Jumping
|
||||
######################################################################
|
||||
|
||||
def onFirstCard(self):
|
||||
if not self.model.cards:
|
||||
return
|
||||
self.dialog.tableView.selectionModel().clear()
|
||||
self.dialog.tableView.selectRow(0)
|
||||
|
||||
def onLastCard(self):
|
||||
if not self.model.cards:
|
||||
return
|
||||
self.dialog.tableView.selectionModel().clear()
|
||||
self.dialog.tableView.selectRow(len(self.model.cards) - 1)
|
||||
|
||||
def onPreviousCard(self):
|
||||
if not self.model.cards:
|
||||
return
|
||||
row = self.dialog.tableView.currentIndex().row()
|
||||
row = max(0, row - 1)
|
||||
self.dialog.tableView.selectionModel().clear()
|
||||
self.dialog.tableView.selectRow(row)
|
||||
|
||||
def onNextCard(self):
|
||||
if not self.model.cards:
|
||||
return
|
||||
row = self.dialog.tableView.currentIndex().row()
|
||||
row = min(len(self.model.cards) - 1, row + 1)
|
||||
self.dialog.tableView.selectionModel().clear()
|
||||
self.dialog.tableView.selectRow(row)
|
||||
|
||||
def onFind(self):
|
||||
self.dialog.filterEdit.setFocus()
|
||||
|
||||
def onFact(self):
|
||||
self.editor.focusFirst()
|
||||
|
||||
class AddCardChooser(QDialog):
|
||||
|
||||
def __init__(self, parent, cms):
|
||||
|
@ -644,4 +689,3 @@ order by ordinal""" % ids2str(self.cms))
|
|||
def onHelp(self):
|
||||
QDesktopServices.openUrl(QUrl(ankiqt.appWiki +
|
||||
"Editor#AddCards"))
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@ class FactEditor(object):
|
|||
self.fontChanged = False
|
||||
self.deck.setUndoBarrier()
|
||||
|
||||
def focusFirst(self):
|
||||
if self.focusTarget:
|
||||
self.focusTarget.setFocus()
|
||||
|
||||
def initMedia(self):
|
||||
os.chdir(self.deck.mediaDir(create=True))
|
||||
|
||||
|
@ -229,7 +233,7 @@ class FactEditor(object):
|
|||
self.fields = {}
|
||||
self.widgets = {}
|
||||
n = 0
|
||||
first = None
|
||||
first = True
|
||||
for field in fields:
|
||||
# label
|
||||
l = QLabel(field.name)
|
||||
|
@ -251,6 +255,9 @@ class FactEditor(object):
|
|||
self.onTextChanged)
|
||||
w.connect(w, SIGNAL("currentCharFormatChanged(QTextCharFormat)"),
|
||||
lambda w=w: self.formatChanged(w))
|
||||
if first:
|
||||
self.focusTarget = w
|
||||
first = False
|
||||
n += 1
|
||||
# tags
|
||||
self.fieldsGrid.addWidget(QLabel(_("Tags")), n, 0)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>599</width>
|
||||
<height>602</height>
|
||||
<height>462</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
|
@ -18,7 +18,7 @@
|
|||
<x>0</x>
|
||||
<y>23</y>
|
||||
<width>599</width>
|
||||
<height>579</height>
|
||||
<height>439</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
|
@ -196,8 +196,21 @@
|
|||
<addaction name="actionResetProgress" />
|
||||
<addaction name="actionDelete" />
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuJump" >
|
||||
<property name="title" >
|
||||
<string>&Jump</string>
|
||||
</property>
|
||||
<addaction name="actionFind" />
|
||||
<addaction name="actionFact" />
|
||||
<addaction name="separator" />
|
||||
<addaction name="actionFirstCard" />
|
||||
<addaction name="actionPreviousCard" />
|
||||
<addaction name="actionNextCard" />
|
||||
<addaction name="actionLastCard" />
|
||||
</widget>
|
||||
<addaction name="menuActions" />
|
||||
<addaction name="menuEdit" />
|
||||
<addaction name="menuJump" />
|
||||
</widget>
|
||||
<action name="actionDelete" >
|
||||
<property name="icon" >
|
||||
|
@ -280,6 +293,78 @@
|
|||
<string>&Invert Selection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFind" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/document-preview.png</normaloff>:/icons/document-preview.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Find</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFact" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/Anki_Fact.png</normaloff>:/icons/Anki_Fact.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>F&act</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+Shift+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNextCard" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/arrow-down.png</normaloff>:/icons/arrow-down.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Next Card</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPreviousCard" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/arrow-up.png</normaloff>:/icons/arrow-up.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Previous Card</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFirstCard" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/arrow-up-double.png</normaloff>:/icons/arrow-up-double.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>F&irst Card</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+Home</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLastCard" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons.qrc" >
|
||||
<normaloff>:/icons/arrow-down-double.png</normaloff>:/icons/arrow-down-double.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Last Card</string>
|
||||
</property>
|
||||
<property name="shortcut" >
|
||||
<string>Ctrl+End</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../icons.qrc" />
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>icons/arrow-down-double.png</file>
|
||||
<file>icons/arrow-up-double.png</file>
|
||||
<file>icons/arrow-down.png</file>
|
||||
<file>icons/arrow-up.png</file>
|
||||
<file>icons/view-pim-calendar.png</file>
|
||||
<file>icons/anki-tag.png</file>
|
||||
<file>icons/edit-redo.png</file>
|
||||
|
|
BIN
icons/arrow-down-double.png
Normal file
BIN
icons/arrow-down-double.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
icons/arrow-down.png
Normal file
BIN
icons/arrow-down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,006 B |
BIN
icons/arrow-up-double.png
Normal file
BIN
icons/arrow-up-double.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
icons/arrow-up.png
Normal file
BIN
icons/arrow-up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 927 B |
Loading…
Reference in a new issue