Skip to content

Commit

Permalink
Add VIM-like navigation (HJKL) in the content view.
Browse files Browse the repository at this point in the history
Patch by Frederik Gladhorn, thanks!

BUG: 174647

svn path=/trunk/KDE/kdegraphics/okular/; revision=890465
  • Loading branch information
Pino Toscano committed Nov 29, 2008
1 parent 3cb0e75 commit 1d91c23
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ui/pageview.cpp
Expand Up @@ -1293,6 +1293,8 @@ void PageView::keyPressEvent( QKeyEvent * e )
// move/scroll page by using keys
switch ( e->key() )
{
case Qt::Key_J:
case Qt::Key_K:
case Qt::Key_Down:
case Qt::Key_PageDown:
case Qt::Key_Space:
Expand All @@ -1301,12 +1303,13 @@ void PageView::keyPressEvent( QKeyEvent * e )
case Qt::Key_Backspace:
if ( e->key() == Qt::Key_Down
|| e->key() == Qt::Key_PageDown
|| e->key() == Qt::Key_J
|| ( e->key() == Qt::Key_Space && ( e->modifiers() & Qt::ShiftModifier ) != Qt::ShiftModifier ) )
{
// if in single page mode and at the bottom of the screen, go to next page
if ( Okular::Settings::viewContinuous() || verticalScrollBar()->value() < verticalScrollBar()->maximum() )
{
if ( e->key() == Qt::Key_Down )
if ( e->key() == Qt::Key_Down || e->key() == Qt::Key_J )
verticalScrollBar()->triggerAction( QScrollBar::SliderSingleStepAdd );
else
verticalScrollBar()->triggerAction( QScrollBar::SliderPageStepAdd );
Expand All @@ -1328,7 +1331,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
// if in single page mode and at the top of the screen, go to \ page
if ( Okular::Settings::viewContinuous() || verticalScrollBar()->value() > verticalScrollBar()->minimum() )
{
if ( e->key() == Qt::Key_Up )
if ( e->key() == Qt::Key_Up || e->key() == Qt::Key_K )
verticalScrollBar()->triggerAction( QScrollBar::SliderSingleStepSub );
else
verticalScrollBar()->triggerAction( QScrollBar::SliderPageStepSub );
Expand All @@ -1347,9 +1350,11 @@ void PageView::keyPressEvent( QKeyEvent * e )
}
break;
case Qt::Key_Left:
case Qt::Key_H:
horizontalScrollBar()->triggerAction( QScrollBar::SliderSingleStepSub );
break;
case Qt::Key_Right:
case Qt::Key_L:
horizontalScrollBar()->triggerAction( QScrollBar::SliderSingleStepAdd );
break;
case Qt::Key_Escape:
Expand Down

0 comments on commit 1d91c23

Please sign in to comment.