From 370800d9c87c28cd0d9a345a96f0c2b2aa2b33bf Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 25 Jun 2018 12:36:15 +0200 Subject: [PATCH] workaround added ( extra flahg in QskWindow ) to work around the missing NoMousePropagation attribute --- src/controls/QskPopup.cpp | 13 ++++++++++++- src/controls/QskWindow.cpp | 26 ++++++++++++++++++++++++++ src/controls/QskWindow.h | 14 ++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index 3ff5a196..fb267e3b 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -6,7 +6,7 @@ #include "QskPopup.h" #include "QskQuick.h" #include "QskAspect.h" -#include +#include "QskWindow.h" #include 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: diff --git a/src/controls/QskWindow.cpp b/src/controls/QskWindow.cpp index 490ac215..7600b74a 100644 --- a/src/controls/QskWindow.cpp +++ b/src/controls/QskWindow.cpp @@ -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" diff --git a/src/controls/QskWindow.h b/src/controls/QskWindow.h index f581e7b1..70c8c635 100644 --- a/src/controls/QskWindow.h +++ b/src/controls/QskWindow.h @@ -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();