editor needs to accept focus; rename cardViewer to canFocus

This commit is contained in:
Damien Elmes 2014-02-18 15:13:59 +09:00
parent a0f16d8ecb
commit 96cc486528
3 changed files with 6 additions and 6 deletions

View file

@ -988,7 +988,7 @@ to a cloze type first, via Edit>Change Note Type."""))
class EditorWebView(AnkiWebView): class EditorWebView(AnkiWebView):
def __init__(self, parent, editor): def __init__(self, parent, editor):
AnkiWebView.__init__(self) AnkiWebView.__init__(self, canFocus=True)
self.editor = editor self.editor = editor
self.strip = self.editor.mw.pm.profile['stripHTML'] self.strip = self.editor.mw.pm.profile['stripHTML']

View file

@ -409,12 +409,12 @@ the manual for information on how to restore from an automatic backup."))
def _reviewState(self, oldState): def _reviewState(self, oldState):
self.reviewer.show() self.reviewer.show()
self.web.setCardViewer(True) self.web.setCanFocus(True)
def _reviewCleanup(self, newState): def _reviewCleanup(self, newState):
if newState != "resetRequired" and newState != "review": if newState != "resetRequired" and newState != "review":
self.reviewer.cleanup() self.reviewer.cleanup()
self.web.setCardViewer(False) self.web.setCanFocus(False)
def noteChanged(self, nid): def noteChanged(self, nid):
"Called when a card or note is edited (but not deleted)." "Called when a card or note is edited (but not deleted)."

View file

@ -40,7 +40,7 @@ class AnkiWebPage(QWebPage):
class AnkiWebView(QWebView): class AnkiWebView(QWebView):
def __init__(self, isCardViewer=False): def __init__(self, canFocus=False):
QWebView.__init__(self) QWebView.__init__(self)
self.setRenderHints( self.setRenderHints(
QPainter.TextAntialiasing | QPainter.TextAntialiasing |
@ -59,7 +59,7 @@ class AnkiWebView(QWebView):
self.allowDrops = False self.allowDrops = False
# reset each time new html is set; used to detect if still in same state # reset each time new html is set; used to detect if still in same state
self.key = None self.key = None
self.setCardViewer(isCardViewer) self.setCanFocus(canFocus)
def keyPressEvent(self, evt): def keyPressEvent(self, evt):
if evt.matches(QKeySequence.Copy): if evt.matches(QKeySequence.Copy):
@ -130,7 +130,7 @@ button {
def setBridge(self, bridge): def setBridge(self, bridge):
self._bridge.setBridge(bridge) self._bridge.setBridge(bridge)
def setCardViewer(self, isCardViewer=False): def setCanFocus(self, isCardViewer=False):
"""Set flag to denote if this WebView should follow rules specific to """Set flag to denote if this WebView should follow rules specific to
card display (e.g., allow context menu, copy/paste)""" card display (e.g., allow context menu, copy/paste)"""