Fix is_zoom_event() (#1607)

This commit is contained in:
RumovZ 2022-01-20 02:56:12 +01:00 committed by GitHub
parent f90895995f
commit a51232debe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -1002,19 +1002,16 @@ def no_arg_trigger(func: Callable) -> Callable:
return pyqtSlot()(func) # type: ignore
def is_zoom_event(evt: QEvent) -> bool:
"""If the event will trigger zoom.
def is_gesture_or_zoom_event(evt: QEvent) -> bool:
"""If the event is a gesture and/or will trigger zoom.
Includes zoom by pinching, Ctrl-scrolling, and Meta-scrolling,
where scrolling may be triggered by mouse wheel or gesture.
Includes zoom by pinching, and Ctrl-scrolling on Win and Linux.
"""
return isinstance(evt, QNativeGestureEvent) or (
isinstance(evt, QWheelEvent)
and (
(is_mac and KeyboardModifiersPressed().meta)
or KeyboardModifiersPressed().control
)
and not is_mac
and KeyboardModifiersPressed().control
)

View File

@ -13,7 +13,7 @@ from anki.utils import is_lin, is_mac, is_win
from aqt import colors, gui_hooks
from aqt.qt import *
from aqt.theme import theme_manager
from aqt.utils import askUser, is_zoom_event, openLink, showInfo, tr
from aqt.utils import askUser, is_gesture_or_zoom_event, openLink, showInfo, tr
serverbaseurl = re.compile(r"^.+:\/\/[^\/]+")
@ -260,7 +260,7 @@ class AnkiWebView(QWebEngineView):
self._disable_zoom = True
def eventFilter(self, obj: QObject, evt: QEvent) -> bool:
if self._disable_zoom and is_zoom_event(evt):
if self._disable_zoom and is_gesture_or_zoom_event(evt):
return True
if (