diff --git a/aqt/browser.py b/aqt/browser.py index db28d61b7..3ea922722 100644 --- a/aqt/browser.py +++ b/aqt/browser.py @@ -875,7 +875,7 @@ by clicking on one on the left.""")) d = QDialog(self) l = QVBoxLayout() l.setMargin(0) - w = AnkiWebView(canCopy=True) + w = AnkiWebView() l.addWidget(w) w.stdHtml(info + "
" + reps) bb = QDialogButtonBox(QDialogButtonBox.Close) @@ -1010,7 +1010,7 @@ where id in %s""" % ids2str(sf)) c(self._previewWindow, SIGNAL("finished(int)"), self._onPreviewFinished) vbox = QVBoxLayout() vbox.setMargin(0) - self._previewWeb = AnkiWebView(True) + self._previewWeb = AnkiWebView() vbox.addWidget(self._previewWeb) bbox = QDialogButtonBox() self._previewReplay = bbox.addButton(_("Replay Audio"), QDialogButtonBox.ActionRole) diff --git a/aqt/clayout.py b/aqt/clayout.py index fd2eba116..1850468ab 100644 --- a/aqt/clayout.py +++ b/aqt/clayout.py @@ -120,9 +120,9 @@ class CardLayout(QDialog): self.model, joinFields(self.note.fields))) for g in pform.groupBox, pform.groupBox_2: g.setTitle(g.title() + _(" (1 of %d)") % max(cnt, 1)) - pform.frontWeb = AnkiWebView(True) + pform.frontWeb = AnkiWebView() pform.frontPrevBox.addWidget(pform.frontWeb) - pform.backWeb = AnkiWebView(True) + pform.backWeb = AnkiWebView() pform.backPrevBox.addWidget(pform.backWeb) for wig in pform.frontWeb, pform.backWeb: wig.page().setLinkDelegationPolicy( diff --git a/aqt/editor.py b/aqt/editor.py index b83c74678..5e82b0648 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -987,7 +987,7 @@ to a cloze type first, via Edit>Change Note Type.""")) class EditorWebView(AnkiWebView): def __init__(self, parent, editor): - AnkiWebView.__init__(self, canFocus=True) + AnkiWebView.__init__(self) self.editor = editor self.strip = self.editor.mw.pm.profile['stripHTML'] diff --git a/aqt/main.py b/aqt/main.py index ec85c06c2..eff919904 100644 --- a/aqt/main.py +++ b/aqt/main.py @@ -417,12 +417,10 @@ the manual for information on how to restore from an automatic backup.")) def _reviewState(self, oldState): self.reviewer.show() - self.web.setCanFocus(True) def _reviewCleanup(self, newState): if newState != "resetRequired" and newState != "review": self.reviewer.cleanup() - self.web.setCanFocus(False) def noteChanged(self, nid): "Called when a card or note is edited (but not deleted)." @@ -518,7 +516,7 @@ title="%s">%s''' % ( self.toolbar = aqt.toolbar.Toolbar(self, tweb) self.toolbar.draw() # main area - self.web = aqt.webview.AnkiWebView(canFocus=True) + self.web = aqt.webview.AnkiWebView() self.web.setObjectName("mainText") self.web.setFocusPolicy(Qt.WheelFocus) self.web.setMinimumWidth(400) diff --git a/aqt/webview.py b/aqt/webview.py index 54ac42bcd..1cb7810d0 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -40,8 +40,7 @@ class AnkiWebPage(QWebPage): class AnkiWebView(QWebView): - # canFocus implies canCopy - def __init__(self, canFocus=False, canCopy=False): + def __init__(self, canFocus=True): QWebView.__init__(self) self.setRenderHints( QPainter.TextAntialiasing | @@ -61,7 +60,6 @@ class AnkiWebView(QWebView): # reset each time new html is set; used to detect if still in same state self.key = None self.setCanFocus(canFocus) - self._canCopy = canCopy or canFocus def keyPressEvent(self, evt): if evt.matches(QKeySequence.Copy): @@ -81,7 +79,7 @@ class AnkiWebView(QWebView): QWebView.keyReleaseEvent(self, evt) def contextMenuEvent(self, evt): - if not self._canCopy: + if not self._canFocus: return m = QMenu(self) a = m.addAction(_("Copy"))