parent
3fbbd6cb3f
commit
6324908cdf
@ -193,6 +193,31 @@ void Cube::switchToPosition( const Position position )
|
||||
doSwitch( direction, nextPosition );
|
||||
}
|
||||
|
||||
void Cube::keyPressEvent( QKeyEvent* event )
|
||||
{
|
||||
Qsk::Direction direction;
|
||||
|
||||
switch( event->key() )
|
||||
{
|
||||
case Qt::Key_Up:
|
||||
direction = Qsk::TopToBottom;
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
direction = Qsk::BottomToTop;
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
direction = Qsk::LeftToRight;
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
direction = Qsk::RightToLeft;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
switchPosition( direction );
|
||||
}
|
||||
|
||||
Cube::Position Cube::currentPosition() const
|
||||
{
|
||||
return static_cast< Position >( currentIndex() );
|
||||
@ -275,6 +300,8 @@ MainItem::MainItem( QQuickItem* parent )
|
||||
|
||||
// the current item needs to be the one at the Front:
|
||||
m_cube->setCurrentItem( dashboardPage );
|
||||
|
||||
installEventFilter( this );
|
||||
}
|
||||
|
||||
void MainItem::gestureEvent( QskGestureEvent* event )
|
||||
@ -301,6 +328,19 @@ void MainItem::gestureEvent( QskGestureEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
bool MainItem::eventFilter( QObject* object, QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::KeyPress )
|
||||
{
|
||||
QCoreApplication::sendEvent( m_cube, event );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QObject::eventFilter( object, event );
|
||||
}
|
||||
}
|
||||
|
||||
bool MainItem::gestureFilter( QQuickItem* item, QEvent* event )
|
||||
{
|
||||
auto& recognizer = m_panRecognizer;
|
||||
|
@ -45,6 +45,9 @@ class Cube : public QskStackBox
|
||||
// might be different from indexChanged:
|
||||
void cubeIndexChanged( const int index );
|
||||
|
||||
protected:
|
||||
void keyPressEvent( QKeyEvent* event ) override;
|
||||
|
||||
private:
|
||||
Position currentPosition() const;
|
||||
Position neighbor( const Position position, const Qsk::Direction direction ) const;
|
||||
@ -68,6 +71,7 @@ class MainItem : public QskControl
|
||||
MainItem( QQuickItem* parent = nullptr );
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override final;
|
||||
bool gestureFilter( QQuickItem*, QEvent* ) override final;
|
||||
void gestureEvent( QskGestureEvent* ) override final;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user