mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Refactor cursor: pointer event filter
This commit is contained in:
parent
7d1e8e99f4
commit
2c0a1dd298
1 changed files with 12 additions and 20 deletions
|
@ -345,27 +345,19 @@ class AnkiApp(QApplication):
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
def eventFilter(self, src: Any, evt: QEvent) -> bool:
|
def eventFilter(self, src: Any, evt: QEvent) -> bool:
|
||||||
|
pointer_classes = (
|
||||||
|
QPushButton,
|
||||||
|
QCheckBox,
|
||||||
|
QRadioButton,
|
||||||
|
QMenu,
|
||||||
|
# classes with PyQt5 compatibility proxy
|
||||||
|
without_qt5_compat_wrapper(QToolButton),
|
||||||
|
without_qt5_compat_wrapper(QTabBar),
|
||||||
|
)
|
||||||
if evt.type() in [QEvent.Type.Enter, QEvent.Type.HoverEnter]:
|
if evt.type() in [QEvent.Type.Enter, QEvent.Type.HoverEnter]:
|
||||||
if (
|
if (isinstance(src, pointer_classes) and src.isEnabled()) or (
|
||||||
(
|
isinstance(src, without_qt5_compat_wrapper(QComboBox))
|
||||||
isinstance(
|
and not src.isEditable()
|
||||||
src,
|
|
||||||
(
|
|
||||||
QPushButton,
|
|
||||||
QCheckBox,
|
|
||||||
QRadioButton,
|
|
||||||
QMenu,
|
|
||||||
# classes with PyQt5 compatibility proxy
|
|
||||||
without_qt5_compat_wrapper(QToolButton),
|
|
||||||
without_qt5_compat_wrapper(QTabBar),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
and src.isEnabled()
|
|
||||||
or (
|
|
||||||
isinstance(src, without_qt5_compat_wrapper(QComboBox))
|
|
||||||
and not src.isEditable()
|
|
||||||
)
|
|
||||||
):
|
):
|
||||||
self.setOverrideCursor(QCursor(Qt.CursorShape.PointingHandCursor))
|
self.setOverrideCursor(QCursor(Qt.CursorShape.PointingHandCursor))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue