mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Put the methods in QMouseEvent that PyQt6 removed back
This commit is contained in:
parent
21d4a3b7cb
commit
1d2cdda5d0
@ -19,6 +19,7 @@ from qt.core import (
|
|||||||
)
|
)
|
||||||
from threading import Lock, RLock
|
from threading import Lock, RLock
|
||||||
|
|
||||||
|
import calibre.gui2.pyqt6_compat as pqc
|
||||||
from calibre import as_unicode, prints
|
from calibre import as_unicode, prints
|
||||||
from calibre.constants import (
|
from calibre.constants import (
|
||||||
DEBUG, __appname__ as APP_UID, __version__, config_dir, filesystem_encoding,
|
DEBUG, __appname__ as APP_UID, __version__, config_dir, filesystem_encoding,
|
||||||
@ -39,6 +40,7 @@ from calibre.utils.localization import get_lang
|
|||||||
from polyglot import queue
|
from polyglot import queue
|
||||||
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
from polyglot.builtins import iteritems, itervalues, string_or_bytes
|
||||||
|
|
||||||
|
del pqc
|
||||||
try:
|
try:
|
||||||
NO_URL_FORMATTING = QUrl.UrlFormattingOption.None_
|
NO_URL_FORMATTING = QUrl.UrlFormattingOption.None_
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QApplication, QEvent, QMouseEvent, QObject, QPointF, QScroller, Qt, QInputDevice,
|
QApplication, QEvent, QInputDevice, QMouseEvent, QObject, QPointF,
|
||||||
pyqtSignal
|
QPointingDevice, QScroller, Qt, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
@ -174,7 +174,7 @@ class GestureManager(QObject):
|
|||||||
return
|
return
|
||||||
etype = ev.type()
|
etype = ev.type()
|
||||||
if etype in (QEvent.Type.MouseButtonPress, QEvent.Type.MouseMove, QEvent.Type.MouseButtonRelease, QEvent.Type.MouseButtonDblClick):
|
if etype in (QEvent.Type.MouseButtonPress, QEvent.Type.MouseMove, QEvent.Type.MouseButtonRelease, QEvent.Type.MouseButtonDblClick):
|
||||||
if ev.source() in (Qt.MouseEventSource.MouseEventSynthesizedBySystem, Qt.MouseEventSource.MouseEventSynthesizedByQt):
|
if ev.pointingDevice().pointerType() is QPointingDevice.PointerType.Finger:
|
||||||
# swallow fake mouse events generated from touch events
|
# swallow fake mouse events generated from touch events
|
||||||
ev.ignore()
|
ev.ignore()
|
||||||
return False
|
return False
|
||||||
|
20
src/calibre/gui2/pyqt6_compat.py
Normal file
20
src/calibre/gui2/pyqt6_compat.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
# License: GPL v3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
# Workaround a bunch of brain dead changes in PyQt6 that break backwards compat
|
||||||
|
# for no good reason. Since we have a huge body of poorly maintained third
|
||||||
|
# party plugin code, we NEED backward compat.
|
||||||
|
|
||||||
|
from qt.core import QSinglePointEvent
|
||||||
|
|
||||||
|
|
||||||
|
# Restore removed functions from QMouseEvent
|
||||||
|
QSinglePointEvent.x = lambda self: int(self.position().x())
|
||||||
|
QSinglePointEvent.y = lambda self: int(self.position().y())
|
||||||
|
QSinglePointEvent.globalPos = lambda self: self.globalPosition.toPoint()
|
||||||
|
QSinglePointEvent.globalX = lambda self: self.globalPosition.toPoint().x()
|
||||||
|
QSinglePointEvent.globalY = lambda self: self.globalPosition.toPoint().y()
|
||||||
|
QSinglePointEvent.localPos = lambda self: self.position()
|
||||||
|
QSinglePointEvent.screenPos = lambda self: self.globalPosition()
|
||||||
|
QSinglePointEvent.windowPos = lambda self: self.scenePosition()
|
Loading…
x
Reference in New Issue
Block a user