if hover events are accepted, intercept them too
This commit is contained in:
parent
4426b4e089
commit
0a73ce2850
@ -24,6 +24,7 @@
|
|||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -83,6 +84,22 @@ void MouseEventListener::hoverLeaveEvent(QHoverEvent *event)
|
|||||||
emit containsMouseChanged(false);
|
emit containsMouseChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MouseEventListener::hoverMoveEvent(QHoverEvent * event)
|
||||||
|
{
|
||||||
|
if (m_lastEvent == event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickWindow *w = window();
|
||||||
|
QPoint screenPos = QPoint();
|
||||||
|
if (w) {
|
||||||
|
w->mapToGlobal(event->pos());
|
||||||
|
}
|
||||||
|
|
||||||
|
KDeclarativeMouseEvent dme(event->pos().x(), event->pos().y(), screenPos.x(), screenPos.y(), Qt::NoButton, Qt::NoButton, event->modifiers());
|
||||||
|
emit positionChanged(&dme);
|
||||||
|
}
|
||||||
|
|
||||||
bool MouseEventListener::containsMouse() const
|
bool MouseEventListener::containsMouse() const
|
||||||
{
|
{
|
||||||
return m_containsMouse;
|
return m_containsMouse;
|
||||||
@ -185,6 +202,26 @@ bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
|
|||||||
m_pressAndHoldTimer->start(PressAndHoldDelay);
|
m_pressAndHoldTimer->start(PressAndHoldDelay);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QEvent::HoverMove: {
|
||||||
|
if (!acceptHoverEvents()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_lastEvent = event;
|
||||||
|
QHoverEvent *he = static_cast<QHoverEvent *>(event);
|
||||||
|
const QPointF myPos = item->mapToItem(this, he->pos());
|
||||||
|
|
||||||
|
QQuickWindow *w = window();
|
||||||
|
QPoint screenPos = QPoint();
|
||||||
|
if (w) {
|
||||||
|
w->mapToGlobal(myPos.toPoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
KDeclarativeMouseEvent dme(myPos.x(), myPos.y(), screenPos.x(), screenPos.y(), Qt::NoButton, Qt::NoButton, he->modifiers());
|
||||||
|
//qDebug() << "positionChanged..." << dme.x() << dme.y();
|
||||||
|
m_pressAndHoldEvent = new KDeclarativeMouseEvent(myPos.x(), myPos.y(), screenPos.x(), screenPos.y(), Qt::NoButton, Qt::NoButton, he->modifiers());
|
||||||
|
emit positionChanged(&dme);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QEvent::MouseMove: {
|
case QEvent::MouseMove: {
|
||||||
m_lastEvent = event;
|
m_lastEvent = event;
|
||||||
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
QMouseEvent *me = static_cast<QMouseEvent *>(event);
|
||||||
|
@ -146,6 +146,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void hoverEnterEvent(QHoverEvent *event);
|
void hoverEnterEvent(QHoverEvent *event);
|
||||||
void hoverLeaveEvent(QHoverEvent *event);
|
void hoverLeaveEvent(QHoverEvent *event);
|
||||||
|
void hoverMoveEvent(QHoverEvent * event);
|
||||||
void mousePressEvent(QMouseEvent *event);
|
void mousePressEvent(QMouseEvent *event);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
void mouseReleaseEvent(QMouseEvent *event);
|
void mouseReleaseEvent(QMouseEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user