mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pyqt6: Fix drop and hover events as well
This commit is contained in:
parent
f2c058fea3
commit
a5257b532f
@ -232,7 +232,7 @@ class ToolBar(QToolBar): # {{{
|
|||||||
# support drag&drop from/to library, from/to reader/card, enabled plugins
|
# support drag&drop from/to library, from/to reader/card, enabled plugins
|
||||||
def check_iactions_for_drag(self, event, md, func):
|
def check_iactions_for_drag(self, event, md, func):
|
||||||
if self.added_actions:
|
if self.added_actions:
|
||||||
pos = event.pos()
|
pos = event.position().toPoint()
|
||||||
for iac in itervalues(self.gui.iactions):
|
for iac in itervalues(self.gui.iactions):
|
||||||
if iac.accepts_drops:
|
if iac.accepts_drops:
|
||||||
aa = iac.qaction
|
aa = iac.qaction
|
||||||
|
@ -232,7 +232,7 @@ def dropEvent(self, event):
|
|||||||
md = event.mimeData()
|
md = event.mimeData()
|
||||||
if dnd_merge_ok(md):
|
if dnd_merge_ok(md):
|
||||||
ids = set(map(int, filter(None, bytes(md.data('application/calibre+from_library')).decode('utf-8').split(' '))))
|
ids = set(map(int, filter(None, bytes(md.data('application/calibre+from_library')).decode('utf-8').split(' '))))
|
||||||
row = self.indexAt(event.pos()).row()
|
row = self.indexAt(event.position().toPoint()).row()
|
||||||
if row > -1 and ids:
|
if row > -1 and ids:
|
||||||
book_id = self.model().id(row)
|
book_id = self.model().id(row)
|
||||||
if book_id and book_id not in ids:
|
if book_id and book_id not in ids:
|
||||||
|
@ -61,7 +61,7 @@ class HeaderView(QHeaderView): # {{{
|
|||||||
|
|
||||||
def event(self, e):
|
def event(self, e):
|
||||||
if e.type() in (QEvent.Type.HoverMove, QEvent.Type.HoverEnter):
|
if e.type() in (QEvent.Type.HoverMove, QEvent.Type.HoverEnter):
|
||||||
self.hover = self.logicalIndexAt(e.pos())
|
self.hover = self.logicalIndexAt(e.position().toPoint())
|
||||||
elif e.type() in (QEvent.Type.Leave, QEvent.Type.HoverLeave):
|
elif e.type() in (QEvent.Type.Leave, QEvent.Type.HoverLeave):
|
||||||
self.hover = -1
|
self.hover = -1
|
||||||
return QHeaderView.event(self, e)
|
return QHeaderView.event(self, e)
|
||||||
|
@ -10,7 +10,7 @@ from qt.core import (
|
|||||||
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
QAbstractItemView, QAction, QComboBox, QDialog, QDialogButtonBox, QDrag,
|
||||||
QEventLoop, QFontMetrics, QFormLayout, QFrame, QImage, QIODevice, QLineEdit,
|
QEventLoop, QFontMetrics, QFormLayout, QFrame, QImage, QIODevice, QLineEdit,
|
||||||
QMenu, QMessageBox, QModelIndex, QPalette, QSinglePointEvent, Qt, QThread,
|
QMenu, QMessageBox, QModelIndex, QPalette, QSinglePointEvent, Qt, QThread,
|
||||||
QToolButton, QEvent
|
QToolButton, QEvent, QDropEvent, QHoverEvent
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre_extensions import progress_indicator
|
from calibre_extensions import progress_indicator
|
||||||
@ -24,6 +24,10 @@ QSinglePointEvent.globalY = lambda self: self.globalPosition().toPoint().y()
|
|||||||
QSinglePointEvent.localPos = lambda self: self.position()
|
QSinglePointEvent.localPos = lambda self: self.position()
|
||||||
QSinglePointEvent.screenPos = lambda self: self.globalPosition()
|
QSinglePointEvent.screenPos = lambda self: self.globalPosition()
|
||||||
QSinglePointEvent.windowPos = lambda self: self.scenePosition()
|
QSinglePointEvent.windowPos = lambda self: self.scenePosition()
|
||||||
|
QDropEvent.pos = lambda self: self.position().toPoint()
|
||||||
|
QDropEvent.posF = lambda self: self.position()
|
||||||
|
QHoverEvent.pos = lambda self: self.position().toPoint()
|
||||||
|
QHoverEvent.posF = lambda self: self.position()
|
||||||
|
|
||||||
|
|
||||||
# Restore the removed exec_ method
|
# Restore the removed exec_ method
|
||||||
|
Loading…
x
Reference in New Issue
Block a user