mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
add home+end shortcuts
This commit is contained in:
parent
0a0190103f
commit
e2ed5b54c8
2 changed files with 38 additions and 2 deletions
|
@ -354,6 +354,8 @@ class Browser(QMainWindow):
|
|||
# jumps
|
||||
c(f.actionPreviousCard, s, self.onPreviousCard)
|
||||
c(f.actionNextCard, s, self.onNextCard)
|
||||
c(f.actionFirstCard, s, self.onFirstCard)
|
||||
c(f.actionLastCard, s, self.onLastCard)
|
||||
c(f.actionFind, s, self.onFind)
|
||||
c(f.actionNote, s, self.onNote)
|
||||
c(f.actionTags, s, self.onTags)
|
||||
|
@ -1208,12 +1210,13 @@ select fm.id, fm.name from fieldmodels fm""")
|
|||
# Jumping
|
||||
######################################################################
|
||||
|
||||
def _moveCur(self, dir):
|
||||
def _moveCur(self, dir=None, idx=None):
|
||||
if not self.model.cards:
|
||||
return
|
||||
self.editor.saveNow()
|
||||
tv = self.form.tableView
|
||||
idx = tv.moveCursor(dir, Qt.NoModifier)
|
||||
if idx is None:
|
||||
idx = tv.moveCursor(dir, self.mw.app.keyboardModifiers())
|
||||
tv.selectionModel().clear()
|
||||
tv.setCurrentIndex(idx)
|
||||
|
||||
|
@ -1225,6 +1228,13 @@ select fm.id, fm.name from fieldmodels fm""")
|
|||
self._moveCur(QAbstractItemView.MoveDown)
|
||||
self.editor.web.setFocus()
|
||||
|
||||
def onFirstCard(self):
|
||||
self._moveCur(None, self.model.index(0, 0))
|
||||
|
||||
def onLastCard(self):
|
||||
self._moveCur(
|
||||
None, self.model.index(len(self.model.cards) - 1, 0))
|
||||
|
||||
def onFind(self):
|
||||
self.form.searchEdit.setFocus()
|
||||
self.form.searchEdit.lineEdit().selectAll()
|
||||
|
|
|
@ -260,8 +260,10 @@
|
|||
<addaction name="actionNote"/>
|
||||
<addaction name="actionCardList"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFirstCard"/>
|
||||
<addaction name="actionPreviousCard"/>
|
||||
<addaction name="actionNextCard"/>
|
||||
<addaction name="actionLastCard"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
|
@ -455,6 +457,30 @@
|
|||
<string>Reposition...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFirstCard">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/arrow-up.png</normaloff>:/icons/arrow-up.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>First Card</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Home</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLastCard">
|
||||
<property name="icon">
|
||||
<iconset resource="icons.qrc">
|
||||
<normaloff>:/icons/arrow-down.png</normaloff>:/icons/arrow-down.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Last Card</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>End</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
|
Loading…
Reference in a new issue