From 13b83d896de8b00d6a373c97917ce52553a7e451 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 29 Jun 2011 10:16:34 +0200 Subject: make QHoverEvent inherit from QInputEvent QHoverEvent is an input event and as such should also contain the current keyboard modifiers. Change-Id: Ic403a8511eb991a9c6b5132908af1d5900869361 Reviewed-on: http://codereview.qt.nokia.com/937 Reviewed-by: Qt Sanity Bot Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qapplication.cpp | 8 +++++--- src/gui/kernel/qevent.cpp | 4 ++-- src/gui/kernel/qevent.h | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 361ec6ddec..760fe789de 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2794,7 +2794,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { Q_ASSERT(instance()); - QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos)); + QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos), + QApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -2807,7 +2808,8 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { QApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1)); + QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1), + QApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } } @@ -4059,7 +4061,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) while (w) { if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff); + QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff, mouse->modifiers()); d->notify_helper(w, &he); } if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index aba848258b..946ab33e80 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -445,8 +445,8 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &pos, const QPointF &globalPos receiving widget, while \a oldPos is the previous mouse cursor's position relative to the receiving widget. */ -QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos) - : QEvent(type), p(pos), op(oldPos) +QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers) + : QInputEvent(type, modifiers), p(pos), op(oldPos) { } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 6ec9f1b9bf..0847fd6046 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -119,10 +119,10 @@ protected: Qt::MouseButtons mouseState; }; -class Q_GUI_EXPORT QHoverEvent : public QEvent +class Q_GUI_EXPORT QHoverEvent : public QInputEvent { public: - QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos); + QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier); ~QHoverEvent(); inline QPoint pos() const { return p.toPoint(); } -- cgit v1.2.3