From f80d250b4782fe88edf2b79bc3409c5130fad5d3 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 16 Apr 2019 13:37:27 +1000 Subject: [PATCH] Revert "Workaround for AltGr '@' issue." This reverts commit 1e433a7cdd8c7b33c5cc7cdb40a1a757ec79d6b7 and 91178d3d5870308158ffe13f3db47a5f9d50419b Due to regressions this will be moved into an optional add-on, at least for now. --- aqt/webview.py | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/aqt/webview.py b/aqt/webview.py index b4905e3b8..0af406cfe 100644 --- a/aqt/webview.py +++ b/aqt/webview.py @@ -84,32 +84,6 @@ class AnkiWebPage(QWebEnginePage): def _onCmd(self, str): return self._onBridgeCmd(str) -# this is a hack to work around a qt bug - do not use this function in add-ons -# as it will likely go away in the future -def _runJavaScriptSync(page, js, timeout=500): - result = None - eventLoop = QEventLoop() - called = False - - def callback(val): - nonlocal result, called - result = val - called = True - eventLoop.quit() - - page.runJavaScript(js, callback) - - if not called: - timer = QTimer() - timer.setSingleShot(True) - timer.timeout.connect(eventLoop.quit) - timer.start(timeout) - eventLoop.exec_() - - if not called: - print('runJavaScriptSync() timed out') - return result - # Main web view ########################################################################## @@ -145,20 +119,6 @@ class AnkiWebView(QWebEngineView): QShortcut(QKeySequence("ctrl+shift+v"), self, context=Qt.WidgetWithChildrenShortcut, activated=self.onPaste) - def event(self, evt): - if evt.type() == QEvent.ShortcutOverride: - # alt-gr bug workaround - exceptChars = (str(num) for num in range(1, 10)) - if evt.text() not in exceptChars: - js = ''' -var e=document.activeElement; -(e.tagName === "DIV" && e.contentEditable) || -["INPUT", "TEXTAREA"].indexOf(document.activeElement.tagName) !== -1''' - if _runJavaScriptSync(self.page(), js, timeout=100): - evt.accept() - return True - return QWebEngineView.event(self, evt) - def eventFilter(self, obj, evt): # disable pinch to zoom gesture if isinstance(evt, QNativeGestureEvent):