From 96cc48652894faff5d32c5610c01a2b6b9567dc4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 18 Feb 2014 15:13:59 +0900 Subject: [PATCH] editor needs to accept focus; rename cardViewer to canFocus --- aqt/editor.py | 2 +- aqt/main.py | 4 ++-- aqt/webview.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aqt/editor.py b/aqt/editor.py index 5dd6d1dab..ce76ebe3f 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -988,7 +988,7 @@ to a cloze type first, via Edit>Change Note Type.""")) class EditorWebView(AnkiWebView): def __init__(self, parent, editor): - AnkiWebView.__init__(self) + AnkiWebView.__init__(self, canFocus=True) self.editor = editor self.strip = self.editor.mw.pm.profile['stripHTML'] diff --git a/aqt/main.py b/aqt/main.py index 273f2b066..cdcc41a2f 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -409,12 +409,12 @@ the manual for information on how to restore from an automatic backup.")) def _reviewState(self, oldState): self.reviewer.show() - self.web.setCardViewer(True) + self.web.setCanFocus(True) def _reviewCleanup(self, newState): if newState != "resetRequired" and newState != "review": self.reviewer.cleanup() - self.web.setCardViewer(False) + self.web.setCanFocus(False) def noteChanged(self, nid): "Called when a card or note is edited (but not deleted)." diff --git a/aqt/webview.py b/aqt/webview.py index 3dd3ad990..3be755315 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -40,7 +40,7 @@ class AnkiWebPage(QWebPage): class AnkiWebView(QWebView): - def __init__(self, isCardViewer=False): + def __init__(self, canFocus=False): QWebView.__init__(self) self.setRenderHints( QPainter.TextAntialiasing | @@ -59,7 +59,7 @@ class AnkiWebView(QWebView): self.allowDrops = False # reset each time new html is set; used to detect if still in same state self.key = None - self.setCardViewer(isCardViewer) + self.setCanFocus(canFocus) def keyPressEvent(self, evt): if evt.matches(QKeySequence.Copy): @@ -130,7 +130,7 @@ button { def setBridge(self, 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 card display (e.g., allow context menu, copy/paste)"""