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