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