mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
tweak focus handling
This commit is contained in:
parent
4d694f0064
commit
77c20341c1
3 changed files with 15 additions and 9 deletions
|
@ -29,8 +29,8 @@ class AddCards(QDialog):
|
||||||
self.form = aqt.forms.addcards.Ui_Dialog()
|
self.form = aqt.forms.addcards.Ui_Dialog()
|
||||||
self.form.setupUi(self)
|
self.form.setupUi(self)
|
||||||
self.setWindowTitle(_("Add"))
|
self.setWindowTitle(_("Add"))
|
||||||
self.setupEditor()
|
|
||||||
self.setupChooser()
|
self.setupChooser()
|
||||||
|
self.setupEditor()
|
||||||
self.setupButtons()
|
self.setupButtons()
|
||||||
self.onReset()
|
self.onReset()
|
||||||
self.addedItems = 0
|
self.addedItems = 0
|
||||||
|
@ -42,14 +42,10 @@ class AddCards(QDialog):
|
||||||
|
|
||||||
def setupEditor(self):
|
def setupEditor(self):
|
||||||
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea)
|
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea)
|
||||||
# get a fact for testing
|
|
||||||
#fact = self.mw.deck.getFact(3951)
|
|
||||||
#self.editor.setFact(fact)
|
|
||||||
|
|
||||||
def setupChooser(self):
|
def setupChooser(self):
|
||||||
self.modelChooser = aqt.modelchooser.ModelChooser(
|
self.modelChooser = aqt.modelchooser.ModelChooser(
|
||||||
self.mw, self.form.modelArea)
|
self.mw, self.form.modelArea)
|
||||||
# modelChanged func
|
|
||||||
|
|
||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
aqt.openHelp("AddItems")
|
aqt.openHelp("AddItems")
|
||||||
|
@ -104,12 +100,9 @@ class AddCards(QDialog):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
break
|
break
|
||||||
self.editor.setFact(fact)
|
self.editor.setFact(fact)
|
||||||
#self.setTabOrder(self.editor.tags, self.addButton)
|
|
||||||
#self.setTabOrder(self.addButton, self.closeButton)
|
|
||||||
#self.setTabOrder(self.closeButton, self.helpButton)
|
|
||||||
|
|
||||||
def removeTempFact(self, fact):
|
def removeTempFact(self, fact):
|
||||||
if not fact:
|
if not fact or not fact.id:
|
||||||
return
|
return
|
||||||
# we don't have to worry about cards; just the fact
|
# we don't have to worry about cards; just the fact
|
||||||
self.mw.deck._delFacts([fact.id])
|
self.mw.deck._delFacts([fact.id])
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
|
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
|
||||||
|
|
||||||
|
# get a fact for testing
|
||||||
|
#fact = self.mw.deck.getFact(3951)
|
||||||
|
#self.editor.setFact(fact)
|
||||||
|
|
||||||
class EditCurrent(object):
|
class EditCurrent(object):
|
||||||
|
|
||||||
def __init__(self, mw):
|
def __init__(self, mw):
|
||||||
|
|
|
@ -15,6 +15,9 @@ from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile
|
||||||
import aqt
|
import aqt
|
||||||
import anki.js
|
import anki.js
|
||||||
|
|
||||||
|
# fixme: when tab order returns to the webview, the previously focused field
|
||||||
|
# is focused, which is not good when the user is tabbing through the dialog
|
||||||
|
|
||||||
pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif")
|
pics = ("jpg", "jpeg", "png", "tif", "tiff", "gif")
|
||||||
audio = ("wav", "mp3", "ogg", "flac")
|
audio = ("wav", "mp3", "ogg", "flac")
|
||||||
|
|
||||||
|
@ -174,6 +177,7 @@ class Editor(object):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.fact = None
|
self.fact = None
|
||||||
|
self.stealFocus = True
|
||||||
self._loaded = False
|
self._loaded = False
|
||||||
self._keepButtons = False
|
self._keepButtons = False
|
||||||
# current card, for card layout
|
# current card, for card layout
|
||||||
|
@ -296,6 +300,9 @@ class Editor(object):
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def bridge(self, str):
|
def bridge(self, str):
|
||||||
|
if not self.fact or not runHook:
|
||||||
|
# shutdown
|
||||||
|
return
|
||||||
# focus lost or key/button pressed?
|
# focus lost or key/button pressed?
|
||||||
if str.startswith("blur") or str.startswith("key"):
|
if str.startswith("blur") or str.startswith("key"):
|
||||||
(type, txt) = str.split(":", 1)
|
(type, txt) = str.split(":", 1)
|
||||||
|
@ -361,6 +368,8 @@ class Editor(object):
|
||||||
simplejson.dumps(self.fonts())))
|
simplejson.dumps(self.fonts())))
|
||||||
self.checkValid()
|
self.checkValid()
|
||||||
self.widget.show()
|
self.widget.show()
|
||||||
|
if self.stealFocus:
|
||||||
|
self.web.setFocus()
|
||||||
|
|
||||||
def fonts(self):
|
def fonts(self):
|
||||||
return [(f['font'], f['esize'])
|
return [(f['font'], f['esize'])
|
||||||
|
|
Loading…
Reference in a new issue