mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -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.setupUi(self)
|
||||
self.setWindowTitle(_("Add"))
|
||||
self.setupEditor()
|
||||
self.setupChooser()
|
||||
self.setupEditor()
|
||||
self.setupButtons()
|
||||
self.onReset()
|
||||
self.addedItems = 0
|
||||
|
@ -42,14 +42,10 @@ class AddCards(QDialog):
|
|||
|
||||
def setupEditor(self):
|
||||
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):
|
||||
self.modelChooser = aqt.modelchooser.ModelChooser(
|
||||
self.mw, self.form.modelArea)
|
||||
# modelChanged func
|
||||
|
||||
def helpRequested(self):
|
||||
aqt.openHelp("AddItems")
|
||||
|
@ -104,12 +100,9 @@ class AddCards(QDialog):
|
|||
except IndexError:
|
||||
break
|
||||
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):
|
||||
if not fact:
|
||||
if not fact or not fact.id:
|
||||
return
|
||||
# we don't have to worry about cards; just the fact
|
||||
self.mw.deck._delFacts([fact.id])
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# 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):
|
||||
|
||||
def __init__(self, mw):
|
||||
|
|
|
@ -15,6 +15,9 @@ from aqt.utils import shortcut, showInfo, showWarning, getBase, getFile
|
|||
import aqt
|
||||
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")
|
||||
audio = ("wav", "mp3", "ogg", "flac")
|
||||
|
||||
|
@ -174,6 +177,7 @@ class Editor(object):
|
|||
self.widget = widget
|
||||
self.mw = mw
|
||||
self.fact = None
|
||||
self.stealFocus = True
|
||||
self._loaded = False
|
||||
self._keepButtons = False
|
||||
# current card, for card layout
|
||||
|
@ -296,6 +300,9 @@ class Editor(object):
|
|||
######################################################################
|
||||
|
||||
def bridge(self, str):
|
||||
if not self.fact or not runHook:
|
||||
# shutdown
|
||||
return
|
||||
# focus lost or key/button pressed?
|
||||
if str.startswith("blur") or str.startswith("key"):
|
||||
(type, txt) = str.split(":", 1)
|
||||
|
@ -361,6 +368,8 @@ class Editor(object):
|
|||
simplejson.dumps(self.fonts())))
|
||||
self.checkValid()
|
||||
self.widget.show()
|
||||
if self.stealFocus:
|
||||
self.web.setFocus()
|
||||
|
||||
def fonts(self):
|
||||
return [(f['font'], f['esize'])
|
||||
|
|
Loading…
Reference in a new issue