QskDrawer::setInteractive added
This commit is contained in:
parent
79924aeebe
commit
c57f0adfb0
|
@ -26,6 +26,12 @@ QSK_QT_PRIVATE_END
|
|||
*/
|
||||
QSK_SUBCONTROL( QskDrawer, Panel )
|
||||
|
||||
static inline qreal qskDefaultDragMargin()
|
||||
{
|
||||
// a skin hint ???
|
||||
return QGuiApplication::styleHints()->startDragDistance();
|
||||
}
|
||||
|
||||
static void qskCatchMouseEvents( QQuickItem* item )
|
||||
{
|
||||
#if 1
|
||||
|
@ -239,8 +245,7 @@ class QskDrawer::PrivateData
|
|||
GestureRecognizer* gestureRecognizer = nullptr;
|
||||
GeometryListener* listener = nullptr;
|
||||
|
||||
// a skin hint ???
|
||||
qreal dragMargin = QGuiApplication::styleHints()->startDragDistance();
|
||||
qreal dragMargin = qskDefaultDragMargin();
|
||||
};
|
||||
|
||||
QskDrawer::QskDrawer( QQuickItem* parentItem )
|
||||
|
@ -252,6 +257,7 @@ QskDrawer::QskDrawer( QQuickItem* parentItem )
|
|||
#endif
|
||||
|
||||
setAutoLayoutChildren( true );
|
||||
setInteractive( true );
|
||||
|
||||
setPopupFlag( PopupFlag::CloseOnPressOutside, true );
|
||||
setFaderAspect( Panel | QskAspect::Position | QskAspect::Metric );
|
||||
|
@ -263,13 +269,7 @@ QskDrawer::QskDrawer( QQuickItem* parentItem )
|
|||
*/
|
||||
setPlacementPolicy( QskPlacementPolicy::Ignore );
|
||||
if ( parentItem )
|
||||
{
|
||||
m_data->listener = new GeometryListener( parentItem, this );
|
||||
qskCatchMouseEvents( parentItem );
|
||||
}
|
||||
|
||||
m_data->gestureRecognizer = new GestureRecognizer( this );
|
||||
|
||||
|
||||
connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading );
|
||||
|
||||
|
@ -302,6 +302,32 @@ void QskDrawer::setEdge( Qt::Edge edge )
|
|||
edgeChanged( edge );
|
||||
}
|
||||
|
||||
void QskDrawer::setInteractive( bool on )
|
||||
{
|
||||
if ( on == isInteractive() )
|
||||
return;
|
||||
|
||||
if ( on )
|
||||
{
|
||||
m_data->gestureRecognizer = new GestureRecognizer( this );
|
||||
if ( parentItem() )
|
||||
qskCatchMouseEvents( parentItem() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// how to revert qskCatchMouseEvents properly ???
|
||||
delete m_data->gestureRecognizer;
|
||||
m_data->gestureRecognizer = nullptr;
|
||||
}
|
||||
|
||||
Q_EMIT interactiveChanged( on );
|
||||
}
|
||||
|
||||
bool QskDrawer::isInteractive() const
|
||||
{
|
||||
return m_data->gestureRecognizer != nullptr;
|
||||
}
|
||||
|
||||
void QskDrawer::setDragMargin( qreal margin )
|
||||
{
|
||||
margin = std::max( margin, 0.0 );
|
||||
|
@ -313,6 +339,11 @@ void QskDrawer::setDragMargin( qreal margin )
|
|||
}
|
||||
}
|
||||
|
||||
void QskDrawer::resetDragMargin()
|
||||
{
|
||||
setDragMargin( qskDefaultDragMargin() );
|
||||
}
|
||||
|
||||
qreal QskDrawer::dragMargin() const
|
||||
{
|
||||
return m_data->dragMargin;
|
||||
|
@ -361,7 +392,7 @@ void QskDrawer::itemChange( QQuickItem::ItemChange change,
|
|||
{
|
||||
case QQuickItem::ItemParentHasChanged:
|
||||
{
|
||||
if ( parentItem() )
|
||||
if ( parentItem() && isInteractive() )
|
||||
qskCatchMouseEvents( parentItem() );
|
||||
|
||||
Q_FALLTHROUGH();
|
||||
|
|
|
@ -18,7 +18,10 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||
Q_PROPERTY( Qt::Edge edge READ edge WRITE setEdge NOTIFY edgeChanged )
|
||||
|
||||
Q_PROPERTY( qreal dragMargin READ dragMargin
|
||||
WRITE setDragMargin NOTIFY dragMarginChanged )
|
||||
WRITE setDragMargin RESET resetDragMargin NOTIFY dragMarginChanged )
|
||||
|
||||
Q_PROPERTY( bool interactive READ isInteractive
|
||||
WRITE setInteractive NOTIFY interactiveChanged )
|
||||
|
||||
public:
|
||||
QSK_SUBCONTROLS( Panel )
|
||||
|
@ -29,7 +32,11 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||
void setEdge( Qt::Edge );
|
||||
Qt::Edge edge() const;
|
||||
|
||||
void setInteractive( bool );
|
||||
bool isInteractive() const;
|
||||
|
||||
void setDragMargin( qreal );
|
||||
void resetDragMargin();
|
||||
qreal dragMargin() const;
|
||||
|
||||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||
|
@ -37,6 +44,7 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||
Q_SIGNALS:
|
||||
void edgeChanged( Qt::Edge );
|
||||
void dragMarginChanged( qreal );
|
||||
void interactiveChanged( bool );
|
||||
|
||||
protected:
|
||||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||
|
|
Loading…
Reference in New Issue