diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index bbd1c2300d..ea76901df3 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -102,6 +102,9 @@ information about a particular change. - QSound has been moved from QtGui to QtMultimedia +- QTabletEvent::QTabletEvent does not take a hiResGlobalPos argument anymore, + as all coordinates are floating point based now. + - QTouchEvent: * The DeviceType enum and deviceType() have been deprecated due to diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 74dc388114..3dbe5d5268 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1872,14 +1872,13 @@ QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z() */ -QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos, - const QPointF &hiResGlobalPos, int device, int pointerType, +QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos, + int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID) : QInputEvent(type, keyState), mPos(pos), mGPos(globalPos), - mHiResGlobalPos(hiResGlobalPos), mDev(device), mPointerType(pointerType), mXT(xTilt), @@ -2208,7 +2207,7 @@ QDragMoveEvent::~QDragMoveEvent() The states of the mouse buttons and keyboard modifiers at the time of the drop are specified by \a buttons and \a modifiers. */ // ### pos is in which coordinate system? -QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, +QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type) : QEvent(type), p(pos), mouseState(buttons), modState(modifiers), act(actions), diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 2fabeb5f0e..8f0d76a58d 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -183,21 +183,27 @@ public: enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse, XFreeEraser /*internal*/, RotationStylus }; enum PointerType { UnknownPointer, Pen, Cursor, Eraser }; - QTabletEvent(Type t, const QPoint &pos, const QPoint &globalPos, const QPointF &hiResGlobalPos, + QTabletEvent(Type t, const QPointF &pos, const QPointF &globalPos, int device, int pointerType, qreal pressure, int xTilt, int yTilt, qreal tangentialPressure, qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID); ~QTabletEvent(); - inline const QPoint &pos() const { return mPos; } - inline const QPoint &globalPos() const { return mGPos; } - inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; } - inline int x() const { return mPos.x(); } - inline int y() const { return mPos.y(); } - inline int globalX() const { return mGPos.x(); } - inline int globalY() const { return mGPos.y(); } - inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); } - inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); } + inline const QPoint pos() const { return mPos.toPoint(); } + inline const QPoint globalPos() const { return mGPos.toPoint(); } +#if QT_DEPRECATED_SINCE(5,0) + QT_DEPRECATED inline const QPointF &hiResGlobalPos() const { return mPos; } +#endif + + inline const QPointF &posF() const { return mPos; } + inline const QPointF &globalPosF() const { return mGPos; } + + inline int x() const { return qRound(mPos.x()); } + inline int y() const { return qRound(mPos.y()); } + inline int globalX() const { return qRound(mGPos.x()); } + inline int globalY() const { return qRound(mGPos.y()); } + inline qreal hiResGlobalX() const { return mGPos.x(); } + inline qreal hiResGlobalY() const { return mGPos.y(); } inline TabletDevice device() const { return TabletDevice(mDev); } inline PointerType pointerType() const { return PointerType(mPointerType); } inline qint64 uniqueId() const { return mUnique; } @@ -209,8 +215,7 @@ public: inline int yTilt() const { return mYT; } protected: - QPoint mPos, mGPos; - QPointF mHiResGlobalPos; + QPointF mPos, mGPos; int mDev, mPointerType, mXT, mYT, mZ; qreal mPress, mTangential, mRot; qint64 mUnique; @@ -477,11 +482,12 @@ class QMimeData; class Q_GUI_EXPORT QDropEvent : public QEvent { public: - QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data, + QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop); ~QDropEvent(); - inline const QPoint &pos() const { return p; } + inline const QPoint pos() const { return p.toPoint(); } + inline const QPointF &posF() const { return p; } inline Qt::MouseButtons mouseButtons() const { return mouseState; } inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; } @@ -497,7 +503,7 @@ public: protected: friend class QApplication; - QPoint p; + QPointF p; Qt::MouseButtons mouseState; Qt::KeyboardModifiers modState; Qt::DropActions act; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 1f76bcdc04..627b444014 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3700,11 +3700,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) { QWidget *w = static_cast(receiver); QTabletEvent *tablet = static_cast(e); - QPoint relpos = tablet->pos(); + QPointF relpos = tablet->posF(); bool eventAccepted = tablet->isAccepted(); while (w) { - QTabletEvent te(tablet->type(), relpos, tablet->globalPos(), - tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(), + QTabletEvent te(tablet->type(), relpos, tablet->globalPosF(), + tablet->device(), tablet->pointerType(), tablet->pressure(), tablet->xTilt(), tablet->yTilt(), tablet->tangentialPressure(), tablet->rotation(), tablet->z(), tablet->modifiers(), tablet->uniqueId()); @@ -3799,7 +3799,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } if (w->isWindow()) break; - dragEvent->p = w->mapToParent(dragEvent->p); + dragEvent->p = w->mapToParent(dragEvent->p.toPoint()); w = w->parentWidget(); } } @@ -3838,7 +3838,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QDropEvent *dragEvent = static_cast(e); QWidget *origReciver = static_cast(receiver); while (origReciver && w != origReciver) { - dragEvent->p = origReciver->mapToParent(dragEvent->p); + dragEvent->p = origReciver->mapToParent(dragEvent->p.toPoint()); origReciver = origReciver->parentWidget(); } } diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp index 1eaf6908c2..122730b2ba 100644 --- a/src/widgets/statemachine/qguistatemachine.cpp +++ b/src/widgets/statemachine/qguistatemachine.cpp @@ -183,10 +183,6 @@ static QEvent *cloneEvent(QEvent *e) return new QInputMethodEvent(*static_cast(e)); case QEvent::AccessibilityPrepare: return new QEvent(*e); -#ifndef QT_NO_TABLETEVENT - case QEvent::TabletMove: - return new QTabletEvent(*static_cast(e)); -#endif //QT_NO_TABLETEVENT case QEvent::LocaleChange: return new QEvent(*e); case QEvent::LanguageChange: @@ -196,8 +192,8 @@ static QEvent *cloneEvent(QEvent *e) case QEvent::Style: return new QEvent(*e); #ifndef QT_NO_TABLETEVENT + case QEvent::TabletMove: case QEvent::TabletPress: - return new QTabletEvent(*static_cast(e)); case QEvent::TabletRelease: return new QTabletEvent(*static_cast(e)); #endif //QT_NO_TABLETEVENT