keyEvents
This commit is contained in:
parent
8015580f55
commit
22373861e5
|
@ -280,7 +280,7 @@ QskDrawer::QskDrawer( QQuickItem* parentItem )
|
||||||
m_data->resetListener( this );
|
m_data->resetListener( this );
|
||||||
|
|
||||||
connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading );
|
connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading );
|
||||||
connect( this, &QskPopup::fadingChanged, this, &QQuickItem::setClip );
|
connect( this, &QskPopup::fadingChanged, this, &QskDrawer::setIntermediate );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskDrawer::~QskDrawer()
|
QskDrawer::~QskDrawer()
|
||||||
|
@ -350,6 +350,64 @@ qreal QskDrawer::dragMargin() const
|
||||||
return m_data->dragMargin;
|
return m_data->dragMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskDrawer::keyPressEvent( QKeyEvent* event )
|
||||||
|
{
|
||||||
|
if ( isOpen() )
|
||||||
|
{
|
||||||
|
bool doClose = false;
|
||||||
|
|
||||||
|
const auto key = event->key();
|
||||||
|
|
||||||
|
switch( key )
|
||||||
|
{
|
||||||
|
case Qt::Key_Escape:
|
||||||
|
case Qt::Key_Cancel:
|
||||||
|
{
|
||||||
|
doClose = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
Do we want to have this - and what about opening with
|
||||||
|
the same keys ???
|
||||||
|
*/
|
||||||
|
case Qt::Key_Up:
|
||||||
|
case Qt::Key_Down:
|
||||||
|
case Qt::Key_Left:
|
||||||
|
case Qt::Key_Right:
|
||||||
|
{
|
||||||
|
switch( m_data->edge )
|
||||||
|
{
|
||||||
|
case Qt::TopEdge:
|
||||||
|
doClose = ( key == Qt::Key_Up );
|
||||||
|
break;
|
||||||
|
case Qt::BottomEdge:
|
||||||
|
doClose = ( key == Qt::Key_Down );
|
||||||
|
break;
|
||||||
|
case Qt::LeftEdge:
|
||||||
|
doClose = ( key == Qt::Key_Left );
|
||||||
|
break;
|
||||||
|
case Qt::RightEdge:
|
||||||
|
doClose = ( key == Qt::Key_Right );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( doClose )
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Inherited::keyPressEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
void QskDrawer::gestureEvent( QskGestureEvent* event )
|
void QskDrawer::gestureEvent( QskGestureEvent* event )
|
||||||
{
|
{
|
||||||
if ( event->gesture()->type() == QskGesture::Pan )
|
if ( event->gesture()->type() == QskGesture::Pan )
|
||||||
|
@ -463,4 +521,18 @@ QRectF QskDrawer::clipRect() const
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskDrawer::setIntermediate( bool on )
|
||||||
|
{
|
||||||
|
setClip( on );
|
||||||
|
Q_EMIT focusIndicatorRectChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF QskDrawer::focusIndicatorRect() const
|
||||||
|
{
|
||||||
|
if ( isFading() )
|
||||||
|
return QRectF();
|
||||||
|
|
||||||
|
return Inherited::focusIndicatorRect();
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_QskDrawer.cpp"
|
#include "moc_QskDrawer.cpp"
|
||||||
|
|
|
@ -42,6 +42,7 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||||
|
|
||||||
QRectF clipRect() const override;
|
QRectF clipRect() const override;
|
||||||
|
QRectF focusIndicatorRect() const override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void edgeChanged( Qt::Edge );
|
void edgeChanged( Qt::Edge );
|
||||||
|
@ -51,11 +52,14 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
||||||
protected:
|
protected:
|
||||||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||||
void gestureEvent( QskGestureEvent* ) override;
|
void gestureEvent( QskGestureEvent* ) override;
|
||||||
|
void keyPressEvent( QKeyEvent* ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setFading( bool );
|
void setFading( bool );
|
||||||
void setFadingClip( bool );
|
void setFadingClip( bool );
|
||||||
|
|
||||||
|
void setIntermediate( bool );
|
||||||
|
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
std::unique_ptr< PrivateData > m_data;
|
std::unique_ptr< PrivateData > m_data;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue