mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
fix navigation
This commit is contained in:
parent
949dc9defd
commit
fe083e916f
3 changed files with 20 additions and 11 deletions
|
@ -363,8 +363,12 @@ class Browser(QMainWindow):
|
||||||
|
|
||||||
def keyPressEvent(self, evt):
|
def keyPressEvent(self, evt):
|
||||||
"Show answer on RET or register answer."
|
"Show answer on RET or register answer."
|
||||||
if evt.key() in (Qt.Key_Escape,):
|
if evt.key() == Qt.Key_Escape:
|
||||||
self.close()
|
self.close()
|
||||||
|
elif self.mw.app.focusWidget() == self.form.tree:
|
||||||
|
if evt.key() in (Qt.Key_Return, Qt.Key_Enter):
|
||||||
|
item = self.form.tree.currentItem()
|
||||||
|
self.onTreeClick(item, 0)
|
||||||
|
|
||||||
def setupColumns(self):
|
def setupColumns(self):
|
||||||
self.columns = [
|
self.columns = [
|
||||||
|
@ -398,7 +402,9 @@ class Browser(QMainWindow):
|
||||||
def onSearch(self):
|
def onSearch(self):
|
||||||
txt = unicode(self.form.searchEdit.text()).strip()
|
txt = unicode(self.form.searchEdit.text()).strip()
|
||||||
self.model.search(txt)
|
self.model.search(txt)
|
||||||
show = not not self.model.cards
|
if not self.model.cards:
|
||||||
|
# no row change will fire
|
||||||
|
self.onRowChanged(None, None)
|
||||||
|
|
||||||
def updateTitle(self):
|
def updateTitle(self):
|
||||||
selected = len(self.form.tableView.selectionModel().selectedRows())
|
selected = len(self.form.tableView.selectionModel().selectedRows())
|
||||||
|
@ -434,7 +440,7 @@ class Browser(QMainWindow):
|
||||||
def onRowChanged(self, current, previous):
|
def onRowChanged(self, current, previous):
|
||||||
"Update current fact and hide/show editor."
|
"Update current fact and hide/show editor."
|
||||||
show = self.model.cards and self.updateTitle() == 1
|
show = self.model.cards and self.updateTitle() == 1
|
||||||
self.form.splitter_2.widget(1).setShown(show)
|
self.form.splitter_2.widget(1).setShown(not not show)
|
||||||
if not show:
|
if not show:
|
||||||
self.editor.setFact(None)
|
self.editor.setFact(None)
|
||||||
else:
|
else:
|
||||||
|
@ -445,7 +451,6 @@ class Browser(QMainWindow):
|
||||||
self.showCardInfo(self.card)
|
self.showCardInfo(self.card)
|
||||||
self.updateToggles()
|
self.updateToggles()
|
||||||
|
|
||||||
|
|
||||||
# Headers & sorting
|
# Headers & sorting
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -603,13 +608,13 @@ class Browser(QMainWindow):
|
||||||
def _systemTagTree(self, root):
|
def _systemTagTree(self, root):
|
||||||
tags = (
|
tags = (
|
||||||
(_("All cards"), "stock_new_template", ""),
|
(_("All cards"), "stock_new_template", ""),
|
||||||
|
(_("Marked"), "rating.png", "tag:marked"),
|
||||||
|
(_("Suspended"), "media-playback-pause.png", "is:suspended"),
|
||||||
|
(_("Leech"), "emblem-important.png", "tag:leech"),
|
||||||
(_("Never seen"), "stock_new_template_blue.png", "is:new"),
|
(_("Never seen"), "stock_new_template_blue.png", "is:new"),
|
||||||
(_("In learning"), "stock_new_template_red.png", "is:lrn"),
|
(_("In learning"), "stock_new_template_red.png", "is:lrn"),
|
||||||
(_("In review"), "stock_new_template_green.png", "is:rev"),
|
(_("In review"), "stock_new_template_green.png", "is:rev"),
|
||||||
(_("Due reviews"), "stock_new_template_green.png", "is:due"),
|
(_("Due reviews"), "stock_new_template_green.png", "is:due"))
|
||||||
(_("Marked"), "rating.png", "tag:marked"),
|
|
||||||
(_("Suspended"), "media-playback-pause.png", "is:suspended"),
|
|
||||||
(_("Leech"), "emblem-important.png", "tag:leech"))
|
|
||||||
for name, icon, cmd in tags:
|
for name, icon, cmd in tags:
|
||||||
item = self.CallbackItem(
|
item = self.CallbackItem(
|
||||||
name, lambda c=cmd: self.setFilter(c))
|
name, lambda c=cmd: self.setFilter(c))
|
||||||
|
@ -1099,6 +1104,7 @@ select fm.id, fm.name from fieldmodels fm""")
|
||||||
row = max(0, row - 1)
|
row = max(0, row - 1)
|
||||||
self.form.tableView.selectionModel().clear()
|
self.form.tableView.selectionModel().clear()
|
||||||
self.form.tableView.selectRow(row)
|
self.form.tableView.selectRow(row)
|
||||||
|
self.onFact()
|
||||||
|
|
||||||
def onNextCard(self):
|
def onNextCard(self):
|
||||||
if not self.model.cards:
|
if not self.model.cards:
|
||||||
|
@ -1108,16 +1114,17 @@ select fm.id, fm.name from fieldmodels fm""")
|
||||||
row = min(len(self.model.cards) - 1, row + 1)
|
row = min(len(self.model.cards) - 1, row + 1)
|
||||||
self.form.tableView.selectionModel().clear()
|
self.form.tableView.selectionModel().clear()
|
||||||
self.form.tableView.selectRow(row)
|
self.form.tableView.selectRow(row)
|
||||||
|
self.onFact()
|
||||||
|
|
||||||
def onFind(self):
|
def onFind(self):
|
||||||
self.form.searchEdit.setFocus()
|
self.form.searchEdit.setFocus()
|
||||||
self.form.searchEdit.selectAll()
|
self.form.searchEdit.selectAll()
|
||||||
|
|
||||||
def onFact(self):
|
def onFact(self):
|
||||||
self.editor.focusFirst()
|
self.editor.focus()
|
||||||
|
|
||||||
def onTags(self):
|
def onTags(self):
|
||||||
self.form.tagList.setFocus()
|
self.form.tree.setFocus()
|
||||||
|
|
||||||
def onSort(self):
|
def onSort(self):
|
||||||
self.form.sortBox.setFocus()
|
self.form.sortBox.setFocus()
|
||||||
|
|
|
@ -377,6 +377,9 @@ class Editor(object):
|
||||||
if self.stealFocus:
|
if self.stealFocus:
|
||||||
self.web.setFocus()
|
self.web.setFocus()
|
||||||
|
|
||||||
|
def focus(self):
|
||||||
|
self.web.setFocus()
|
||||||
|
|
||||||
def fonts(self):
|
def fonts(self):
|
||||||
return [(f['font'], f['esize'])
|
return [(f['font'], f['esize'])
|
||||||
for f in self.fact.model().fields]
|
for f in self.fact.model().fields]
|
||||||
|
|
|
@ -230,7 +230,6 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionFind"/>
|
<addaction name="actionFind"/>
|
||||||
<addaction name="actionTags"/>
|
<addaction name="actionTags"/>
|
||||||
<addaction name="actionSort"/>
|
|
||||||
<addaction name="actionFact"/>
|
<addaction name="actionFact"/>
|
||||||
<addaction name="actionCardList"/>
|
<addaction name="actionCardList"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
|
Loading…
Reference in a new issue