avoid Qt5/6 incompatbilities
This commit is contained in:
parent
bddbf2e1b8
commit
1228518e6a
@ -63,6 +63,24 @@ QPointF qskMouseScenePosition( const QMouseEvent* event )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointF qskWheelPosition( const QWheelEvent* event )
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
||||||
|
return event->position();
|
||||||
|
#else
|
||||||
|
return event->posF();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF qskHoverPosition( const QHoverEvent* event )
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 )
|
||||||
|
return event->position();
|
||||||
|
#else
|
||||||
|
return event->posF();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QskEvent::QskEvent( QskEvent::Type type )
|
QskEvent::QskEvent( QskEvent::Type type )
|
||||||
: QEvent( static_cast< QEvent::Type >( type ) )
|
: QEvent( static_cast< QEvent::Type >( type ) )
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,10 @@ class QskGesture;
|
|||||||
class QskPopup;
|
class QskPopup;
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
|
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
|
class QWheelEvent;
|
||||||
|
class QHoverEvent;
|
||||||
|
|
||||||
class QSK_EXPORT QskEvent : public QEvent
|
class QSK_EXPORT QskEvent : public QEvent
|
||||||
{
|
{
|
||||||
@ -123,5 +126,7 @@ QSK_EXPORT int qskFocusChainIncrement( const QEvent* );
|
|||||||
// some helper to work around Qt version incompatibilities
|
// some helper to work around Qt version incompatibilities
|
||||||
QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
|
QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
|
||||||
QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
|
QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
|
||||||
|
QSK_EXPORT QPointF qskWheelPosition( const QWheelEvent* );
|
||||||
|
QSK_EXPORT QPointF qskHoverPosition( const QHoverEvent* );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include "QskInputGrabber.h"
|
#include "QskInputGrabber.h"
|
||||||
#include "QskWindow.h"
|
#include "QskWindow.h"
|
||||||
|
#include "QskEvent.h"
|
||||||
|
|
||||||
#include <qpointer.h>
|
#include <qpointer.h>
|
||||||
|
|
||||||
@ -151,26 +152,21 @@ bool QskInputGrabber::event( QEvent* event )
|
|||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
{
|
{
|
||||||
const auto ev = static_cast< QMouseEvent* >( event );
|
const auto mouseEvent = static_cast< QMouseEvent* >( event );
|
||||||
doBlock = isBlocking( ev->localPos() );
|
doBlock = isBlocking( qskMousePosition( mouseEvent ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QEvent::Wheel:
|
case QEvent::Wheel:
|
||||||
{
|
{
|
||||||
const auto ev = static_cast< QWheelEvent* >( event );
|
const auto wheelEvent = static_cast< QWheelEvent* >( event );
|
||||||
|
doBlock = isBlocking( qskWheelPosition( wheelEvent ) );
|
||||||
#if QT_VERSION < 0x050e00
|
|
||||||
doBlock = isBlocking( ev->posF() );
|
|
||||||
#else
|
|
||||||
doBlock = isBlocking( ev->position() );
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QEvent::HoverEnter:
|
case QEvent::HoverEnter:
|
||||||
case QEvent::HoverLeave:
|
case QEvent::HoverLeave:
|
||||||
{
|
{
|
||||||
const auto ev = static_cast< QHoverEvent* >( event );
|
const auto ev = static_cast< QHoverEvent* >( event );
|
||||||
doBlock = isBlocking( ev->posF() );
|
doBlock = isBlocking( qskHoverPosition( ev ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "QskScrollView.h"
|
#include "QskScrollView.h"
|
||||||
#include "QskAnimationHint.h"
|
#include "QskAnimationHint.h"
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
|
#include "QskEvent.h"
|
||||||
|
|
||||||
QSK_SUBCONTROL( QskScrollView, Panel )
|
QSK_SUBCONTROL( QskScrollView, Panel )
|
||||||
QSK_SUBCONTROL( QskScrollView, Viewport )
|
QSK_SUBCONTROL( QskScrollView, Viewport )
|
||||||
@ -17,15 +18,6 @@ QSK_SUBCONTROL( QskScrollView, VerticalScrollHandle )
|
|||||||
QSK_SYSTEM_STATE( QskScrollView, VerticalHandlePressed, QskAspect::FirstSystemState << 1 )
|
QSK_SYSTEM_STATE( QskScrollView, VerticalHandlePressed, QskAspect::FirstSystemState << 1 )
|
||||||
QSK_SYSTEM_STATE( QskScrollView, HorizontalHandlePressed, QskAspect::FirstSystemState << 2 )
|
QSK_SYSTEM_STATE( QskScrollView, HorizontalHandlePressed, QskAspect::FirstSystemState << 2 )
|
||||||
|
|
||||||
static inline QPointF qskMousePosition( const QMouseEvent* event )
|
|
||||||
{
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
||||||
return event->position();
|
|
||||||
#else
|
|
||||||
return event->localPos();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
class QskScrollView::PrivateData
|
class QskScrollView::PrivateData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -221,12 +213,11 @@ QPointF QskScrollView::scrollOffset( const QWheelEvent* event ) const
|
|||||||
{
|
{
|
||||||
QPointF offset;
|
QPointF offset;
|
||||||
|
|
||||||
|
const auto wheelPos = qskWheelPosition( event );
|
||||||
|
|
||||||
#if QT_VERSION < 0x050e00
|
#if QT_VERSION < 0x050e00
|
||||||
const auto wheelPos = event->posF();
|
|
||||||
const auto wheelDelta = event->delta();
|
const auto wheelDelta = event->delta();
|
||||||
#else
|
#else
|
||||||
const auto wheelPos = event->position();
|
|
||||||
|
|
||||||
const QPoint delta = event->angleDelta();
|
const QPoint delta = event->angleDelta();
|
||||||
const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) )
|
const int wheelDelta = ( qAbs( delta.x() ) > qAbs( delta.y() ) )
|
||||||
? delta.x() : delta.y();
|
? delta.x() : delta.y();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user