From 0b5b622d1a02910d63f2188727b4498992f90975 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 22 Dec 2021 10:55:48 +0100 Subject: [PATCH] minor improvements --- src/controls/QskPopup.cpp | 12 +++++++++--- src/controls/QskPopup.h | 6 +++++- src/controls/QskPopupSkinlet.h | 3 ++- src/controls/QskSubWindowSkinlet.cpp | 10 ++++++---- src/controls/QskSubWindowSkinlet.h | 2 +- src/nodes/QskSGNode.h | 9 +++++++++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index 478db4e0..d109248a 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -138,9 +138,15 @@ QskPopup::QskPopup( QQuickItem* parent ) Inherited::setVisible( false ); setSkinStateFlag( QskPopup::Closed ); - // we need to stop event propagation - setAcceptedMouseButtons( Qt::AllButtons ); - setWheelEnabled( true ); + /* + We need to stop event propagation. + + Unfortunatly derived classes can't use setAcceptedMouseButtons anymore. + Need to think about a solution TODO ... + */ + + Inherited::setAcceptedMouseButtons( Qt::AllButtons ); + Inherited::setWheelEnabled( true ); // we don't want to be resized by layout code setTransparentForPositioner( true ); diff --git a/src/controls/QskPopup.h b/src/controls/QskPopup.h index b56b244b..bbd7fb10 100644 --- a/src/controls/QskPopup.h +++ b/src/controls/QskPopup.h @@ -4,7 +4,7 @@ *****************************************************************************/ #ifndef QSK_POPUP_H -#define QSK_POPUP_H 1 +#define QSK_POPUP_H #include "QskControl.h" @@ -69,6 +69,10 @@ class QSK_EXPORT QskPopup : public QskControl bool isOpen() const; bool isFading() const; + // we always need to accept all inputs, to stop further propagation + void setAcceptedMouseButtons( Qt::MouseButtons ) = delete; + void setWheelEnabled( bool ) = delete; + public Q_SLOTS: void open(); void close(); diff --git a/src/controls/QskPopupSkinlet.h b/src/controls/QskPopupSkinlet.h index 93699256..58914939 100644 --- a/src/controls/QskPopupSkinlet.h +++ b/src/controls/QskPopupSkinlet.h @@ -19,7 +19,8 @@ class QSK_EXPORT QskPopupSkinlet : public QskSkinlet public: enum NodeRole { - OverlayRole + OverlayRole, + RoleCount }; Q_INVOKABLE QskPopupSkinlet( QskSkin* = nullptr ); diff --git a/src/controls/QskSubWindowSkinlet.cpp b/src/controls/QskSubWindowSkinlet.cpp index 9ad56f07..fe4e1e5d 100644 --- a/src/controls/QskSubWindowSkinlet.cpp +++ b/src/controls/QskSubWindowSkinlet.cpp @@ -24,21 +24,23 @@ QskSubWindowSkinlet::~QskSubWindowSkinlet() = default; QRectF QskSubWindowSkinlet::subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { + using Q = QskSubWindow; + const auto subWindow = static_cast< const QskSubWindow* >( skinnable ); - if ( subControl == QskSubWindow::Panel ) + if ( subControl == Q::Panel ) { return contentsRect; } - else if ( subControl == QskSubWindow::TitleBarPanel ) + else if ( subControl == Q::TitleBarPanel ) { return titleBarRect( subWindow, contentsRect ); } - else if ( subControl == QskSubWindow::TitleBarSymbol ) + else if ( subControl == Q::TitleBarSymbol ) { return symbolRect( subWindow, contentsRect ); } - else if ( subControl == QskSubWindow::TitleBarText ) + else if ( subControl == Q::TitleBarText ) { return titleRect( subWindow, contentsRect ); } diff --git a/src/controls/QskSubWindowSkinlet.h b/src/controls/QskSubWindowSkinlet.h index 84f1c3e4..a40a5ec6 100644 --- a/src/controls/QskSubWindowSkinlet.h +++ b/src/controls/QskSubWindowSkinlet.h @@ -19,7 +19,7 @@ class QSK_EXPORT QskSubWindowSkinlet : public QskPopupSkinlet public: enum NodeRole { - PanelRole = QskPopupSkinlet::OverlayRole + 1, + PanelRole = QskPopupSkinlet::RoleCount, TitleBarRole, SymbolRole, TitleRole diff --git a/src/nodes/QskSGNode.h b/src/nodes/QskSGNode.h index 04a389f3..51e9804c 100644 --- a/src/nodes/QskSGNode.h +++ b/src/nodes/QskSGNode.h @@ -72,6 +72,15 @@ namespace QskSGNode return node; } + + template< typename Node > + inline Node* ensureNode( QSGNode* node ) + { + if ( node == nullptr ) + node = new Node(); + + return static_cast< Node* >( node ); + } } #endif