mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
allow all ankiwebview instances to take focus
the canFocus/canCopy separate variables was silly, as we ended up with text that could be copied from the context menu but not with a shortcut key. also we default to allowing focus now, since that's the more sensible default. fixes copy issues with card info dialog and some addons
This commit is contained in:
parent
70db1035b1
commit
ece78a7d11
5 changed files with 8 additions and 12 deletions
|
@ -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 + "<p>" + 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)
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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']
|
||||
|
||||
|
|
|
@ -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</button>''' % (
|
|||
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)
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Reference in a new issue