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 "QskQuick.h"
|
||||
#include "QskAspect.h"
|
||||
#include <QQuickWindow>
|
||||
#include "QskWindow.h"
|
||||
#include <QtMath>
|
||||
|
||||
QSK_QT_PRIVATE_BEGIN
|
||||
@ -141,6 +141,10 @@ namespace
|
||||
if ( doSwallow )
|
||||
{
|
||||
event->accept();
|
||||
|
||||
if ( auto w = qobject_cast< QskWindow* >( window() ) )
|
||||
w->setEventAcceptance( QskWindow::EventPropagationStopped );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -192,7 +196,9 @@ QskPopup::QskPopup( QQuickItem* parent ):
|
||||
Inherited( parent ),
|
||||
m_data( new PrivateData() )
|
||||
{
|
||||
// we need to stop event propagation
|
||||
setAcceptedMouseButtons( Qt::AllButtons );
|
||||
setWheelEnabled( true );
|
||||
|
||||
// we don't want to be resized by layout code
|
||||
setTransparentForPositioner( true );
|
||||
@ -323,9 +329,14 @@ bool QskPopup::event( QEvent* event )
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
case QEvent::HoverEnter:
|
||||
case QEvent::HoverLeave:
|
||||
{
|
||||
// swallow the event
|
||||
event->accept();
|
||||
if ( auto w = qobject_cast< QskWindow* >( window() ) )
|
||||
w->setEventAcceptance( QskWindow::EventPropagationStopped );
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -102,6 +102,7 @@ class QskWindowPrivate : public QQuickWindowPrivate
|
||||
public:
|
||||
QskWindowPrivate():
|
||||
preferredSize( -1, -1 ),
|
||||
eventAcceptance( QskWindow::EventProcessed ),
|
||||
explicitLocale( false ),
|
||||
deleteOnClose( false ),
|
||||
autoLayoutChildren( true )
|
||||
@ -114,6 +115,8 @@ public:
|
||||
// minimum/maximum constraints are offered by QWindow
|
||||
QSize preferredSize;
|
||||
|
||||
QskWindow::EventAcceptance eventAcceptance;
|
||||
|
||||
bool explicitLocale : 1;
|
||||
bool deleteOnClose : 1;
|
||||
bool autoLayoutChildren : 1;
|
||||
@ -219,6 +222,18 @@ void QskWindow::polishItems()
|
||||
|
||||
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() )
|
||||
{
|
||||
case QEvent::Show:
|
||||
@ -523,4 +538,15 @@ void 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"
|
||||
|
@ -28,6 +28,16 @@ class QSK_EXPORT QskWindow : public QQuickWindow
|
||||
using Inherited = QQuickWindow;
|
||||
|
||||
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 );
|
||||
virtual ~QskWindow();
|
||||
|
||||
@ -54,6 +64,10 @@ public:
|
||||
void setCustomRenderMode( const char* mode );
|
||||
const char* customRenderMode() const;
|
||||
|
||||
// extra flag to interprete accepted events
|
||||
void setEventAcceptance( EventAcceptance );
|
||||
EventAcceptance eventAcceptance() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void localeChanged( const QLocale& );
|
||||
void autoLayoutChildrenChanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user