keyEvents
This commit is contained in:
parent
8015580f55
commit
22373861e5
|
@ -280,7 +280,7 @@ QskDrawer::QskDrawer( QQuickItem* parentItem )
|
|||
m_data->resetListener( this );
|
||||
|
||||
connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading );
|
||||
connect( this, &QskPopup::fadingChanged, this, &QQuickItem::setClip );
|
||||
connect( this, &QskPopup::fadingChanged, this, &QskDrawer::setIntermediate );
|
||||
}
|
||||
|
||||
QskDrawer::~QskDrawer()
|
||||
|
@ -350,6 +350,64 @@ qreal QskDrawer::dragMargin() const
|
|||
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 )
|
||||
{
|
||||
if ( event->gesture()->type() == QskGesture::Pan )
|
||||
|
@ -463,4 +521,18 @@ QRectF QskDrawer::clipRect() const
|
|||
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"
|
||||
|
|
|
@ -42,6 +42,7 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||
QRectF layoutRectForSize( const QSizeF& ) const override;
|
||||
|
||||
QRectF clipRect() const override;
|
||||
QRectF focusIndicatorRect() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void edgeChanged( Qt::Edge );
|
||||
|
@ -51,11 +52,14 @@ class QSK_EXPORT QskDrawer : public QskPopup
|
|||
protected:
|
||||
void itemChange( ItemChange, const ItemChangeData& ) override;
|
||||
void gestureEvent( QskGestureEvent* ) override;
|
||||
void keyPressEvent( QKeyEvent* ) override;
|
||||
|
||||
private:
|
||||
void setFading( bool );
|
||||
void setFadingClip( bool );
|
||||
|
||||
void setIntermediate( bool );
|
||||
|
||||
class PrivateData;
|
||||
std::unique_ptr< PrivateData > m_data;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue