workaround added ( extra flahg in QskWindow ) to work around the missing
NoMousePropagation attribute
This commit is contained in:
parent
9320b5c5be
commit
370800d9c8
@ -6,7 +6,7 @@
|
|||||||
#include "QskPopup.h"
|
#include "QskPopup.h"
|
||||||
#include "QskQuick.h"
|
#include "QskQuick.h"
|
||||||
#include "QskAspect.h"
|
#include "QskAspect.h"
|
||||||
#include <QQuickWindow>
|
#include "QskWindow.h"
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
|
|
||||||
QSK_QT_PRIVATE_BEGIN
|
QSK_QT_PRIVATE_BEGIN
|
||||||
@ -141,6 +141,10 @@ namespace
|
|||||||
if ( doSwallow )
|
if ( doSwallow )
|
||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
|
if ( auto w = qobject_cast< QskWindow* >( window() ) )
|
||||||
|
w->setEventAcceptance( QskWindow::EventPropagationStopped );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +196,9 @@ QskPopup::QskPopup( QQuickItem* parent ):
|
|||||||
Inherited( parent ),
|
Inherited( parent ),
|
||||||
m_data( new PrivateData() )
|
m_data( new PrivateData() )
|
||||||
{
|
{
|
||||||
|
// we need to stop event propagation
|
||||||
setAcceptedMouseButtons( Qt::AllButtons );
|
setAcceptedMouseButtons( Qt::AllButtons );
|
||||||
|
setWheelEnabled( true );
|
||||||
|
|
||||||
// we don't want to be resized by layout code
|
// we don't want to be resized by layout code
|
||||||
setTransparentForPositioner( true );
|
setTransparentForPositioner( true );
|
||||||
@ -323,9 +329,14 @@ bool QskPopup::event( QEvent* event )
|
|||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress:
|
||||||
case QEvent::KeyRelease:
|
case QEvent::KeyRelease:
|
||||||
|
case QEvent::HoverEnter:
|
||||||
|
case QEvent::HoverLeave:
|
||||||
{
|
{
|
||||||
// swallow the event
|
// swallow the event
|
||||||
event->accept();
|
event->accept();
|
||||||
|
if ( auto w = qobject_cast< QskWindow* >( window() ) )
|
||||||
|
w->setEventAcceptance( QskWindow::EventPropagationStopped );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -102,6 +102,7 @@ class QskWindowPrivate : public QQuickWindowPrivate
|
|||||||
public:
|
public:
|
||||||
QskWindowPrivate():
|
QskWindowPrivate():
|
||||||
preferredSize( -1, -1 ),
|
preferredSize( -1, -1 ),
|
||||||
|
eventAcceptance( QskWindow::EventProcessed ),
|
||||||
explicitLocale( false ),
|
explicitLocale( false ),
|
||||||
deleteOnClose( false ),
|
deleteOnClose( false ),
|
||||||
autoLayoutChildren( true )
|
autoLayoutChildren( true )
|
||||||
@ -114,6 +115,8 @@ public:
|
|||||||
// minimum/maximum constraints are offered by QWindow
|
// minimum/maximum constraints are offered by QWindow
|
||||||
QSize preferredSize;
|
QSize preferredSize;
|
||||||
|
|
||||||
|
QskWindow::EventAcceptance eventAcceptance;
|
||||||
|
|
||||||
bool explicitLocale : 1;
|
bool explicitLocale : 1;
|
||||||
bool deleteOnClose : 1;
|
bool deleteOnClose : 1;
|
||||||
bool autoLayoutChildren : 1;
|
bool autoLayoutChildren : 1;
|
||||||
@ -219,6 +222,18 @@ void QskWindow::polishItems()
|
|||||||
|
|
||||||
bool QskWindow::event( QEvent* event )
|
bool QskWindow::event( QEvent* event )
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Qt/Quick is lacking a flag like Qt::WA_NoMousePropagation, so
|
||||||
|
the only way to stop propagating of input events is to accept
|
||||||
|
the event. Then the window can't decide anymore if someone was
|
||||||
|
interested and when to do some fallback handling.
|
||||||
|
To improve the situation we add an extra flag in QskWindow,
|
||||||
|
while the right class to solve this shortcoming would be QQuickWindow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Q_D( QskWindow );
|
||||||
|
d->eventAcceptance = EventProcessed;
|
||||||
|
|
||||||
switch( event->type() )
|
switch( event->type() )
|
||||||
{
|
{
|
||||||
case QEvent::Show:
|
case QEvent::Show:
|
||||||
@ -523,4 +538,15 @@ void QskWindow::enforceSkin()
|
|||||||
disconnect( this, &QQuickWindow::afterAnimating, this, &QskWindow::enforceSkin );
|
disconnect( this, &QQuickWindow::afterAnimating, this, &QskWindow::enforceSkin );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskWindow::setEventAcceptance( EventAcceptance acceptance )
|
||||||
|
{
|
||||||
|
d_func()->eventAcceptance = acceptance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QskWindow::EventAcceptance QskWindow::eventAcceptance() const
|
||||||
|
{
|
||||||
|
return d_func()->eventAcceptance;
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_QskWindow.cpp"
|
#include "moc_QskWindow.cpp"
|
||||||
|
@ -28,6 +28,16 @@ class QSK_EXPORT QskWindow : public QQuickWindow
|
|||||||
using Inherited = QQuickWindow;
|
using Inherited = QQuickWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum EventAcceptance
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Qt/Quick has no way to stop propagating input events
|
||||||
|
beside accepting it ( like NoMousePropagation
|
||||||
|
*/
|
||||||
|
EventProcessed = 0,
|
||||||
|
EventPropagationStopped = 1
|
||||||
|
};
|
||||||
|
|
||||||
QskWindow( QWindow* parent = nullptr );
|
QskWindow( QWindow* parent = nullptr );
|
||||||
virtual ~QskWindow();
|
virtual ~QskWindow();
|
||||||
|
|
||||||
@ -54,6 +64,10 @@ public:
|
|||||||
void setCustomRenderMode( const char* mode );
|
void setCustomRenderMode( const char* mode );
|
||||||
const char* customRenderMode() const;
|
const char* customRenderMode() const;
|
||||||
|
|
||||||
|
// extra flag to interprete accepted events
|
||||||
|
void setEventAcceptance( EventAcceptance );
|
||||||
|
EventAcceptance eventAcceptance() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void localeChanged( const QLocale& );
|
void localeChanged( const QLocale& );
|
||||||
void autoLayoutChildrenChanged();
|
void autoLayoutChildrenChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user