mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 15:17:12 -05:00
delay event filter installation
Qt 5.11 doesn't initialize the focusProxy until a page has been loaded.
This commit is contained in:
parent
63f2ccdb3a
commit
1af556cb8d
1 changed files with 5 additions and 2 deletions
|
|
@ -97,6 +97,7 @@ class AnkiWebView(QWebEngineView):
|
||||||
self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache)
|
self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache)
|
||||||
self.resetHandlers()
|
self.resetHandlers()
|
||||||
self.allowDrops = False
|
self.allowDrops = False
|
||||||
|
self._filterSet = False
|
||||||
QShortcut(QKeySequence("Esc"), self,
|
QShortcut(QKeySequence("Esc"), self,
|
||||||
context=Qt.WidgetWithChildrenShortcut, activated=self.onEsc)
|
context=Qt.WidgetWithChildrenShortcut, activated=self.onEsc)
|
||||||
if isMac:
|
if isMac:
|
||||||
|
|
@ -112,8 +113,6 @@ class AnkiWebView(QWebEngineView):
|
||||||
QShortcut(QKeySequence("ctrl+shift+v"), self,
|
QShortcut(QKeySequence("ctrl+shift+v"), self,
|
||||||
context=Qt.WidgetWithChildrenShortcut, activated=self.onPaste)
|
context=Qt.WidgetWithChildrenShortcut, activated=self.onPaste)
|
||||||
|
|
||||||
self.focusProxy().installEventFilter(self)
|
|
||||||
|
|
||||||
def eventFilter(self, obj, evt):
|
def eventFilter(self, obj, evt):
|
||||||
# disable pinch to zoom gesture
|
# disable pinch to zoom gesture
|
||||||
if isinstance(evt, QNativeGestureEvent):
|
if isinstance(evt, QNativeGestureEvent):
|
||||||
|
|
@ -327,6 +326,10 @@ body {{ zoom: {}; {} }}
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _onBridgeCmd(self, cmd):
|
def _onBridgeCmd(self, cmd):
|
||||||
|
if not self._filterSet:
|
||||||
|
self.focusProxy().installEventFilter(self)
|
||||||
|
self._filterSet = True
|
||||||
|
|
||||||
if self._shouldIgnoreWebEvent():
|
if self._shouldIgnoreWebEvent():
|
||||||
print("ignored late bridge cmd", cmd)
|
print("ignored late bridge cmd", cmd)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue