Compare commits

...

5 Commits

Author SHA1 Message Date
Jacopo De Simoi 2d9e6c4b24 Fix Up/Down scrolling 6 years ago
Jacopo De Simoi 99c94bdcb7 Use pixel events for smooth zooming 6 years ago
Jacopo De Simoi 68d65b4101 Always hide horizontal scrollbar 6 years ago
Jacopo De Simoi 6c521b09c8 Use ijkl-arrows rather than vim-arrows 6 years ago
Jacopo De Simoi bd20d86aba Make autoscroll faster 6 years ago
  1. 41
      ui/pageview.cpp

@ -853,11 +853,12 @@ void PageView::displayMessage( const QString & message, const QString & details,
void PageView::reparseConfig() void PageView::reparseConfig()
{ {
// set the scroll bars policies // set the scroll bars policies
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
Qt::ScrollBarPolicy scrollBarMode = Okular::Settings::showScrollBars() ? Qt::ScrollBarPolicy scrollBarMode = Okular::Settings::showScrollBars() ?
Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff; Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff;
if ( horizontalScrollBarPolicy() != scrollBarMode ) if ( horizontalScrollBarPolicy() != scrollBarMode )
{ {
setHorizontalScrollBarPolicy( scrollBarMode ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); //setHorizontalScrollBarPolicy( scrollBarMode );
setVerticalScrollBarPolicy( scrollBarMode ); setVerticalScrollBarPolicy( scrollBarMode );
} }
@ -2015,7 +2016,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
// move/scroll page by using keys // move/scroll page by using keys
switch ( e->key() ) switch ( e->key() )
{ {
case Qt::Key_J: case Qt::Key_K:
case Qt::Key_Down: case Qt::Key_Down:
slotScrollDown( true /* singleStep */ ); slotScrollDown( true /* singleStep */ );
break; break;
@ -2024,18 +2025,28 @@ void PageView::keyPressEvent( QKeyEvent * e )
slotScrollDown(); slotScrollDown();
break; break;
case Qt::Key_K: case Qt::Key_I:
case Qt::Key_Up: case Qt::Key_Up:
slotScrollUp( true /* singleStep */ ); slotScrollUp( true /* singleStep */ );
break; break;
case Qt::Key_PageUp: case Qt::Key_PageUp:
case Qt::Key_Backspace: case Qt::Key_Backspace:
slotScrollUp(); if ( e->key() == Qt::Key_Down
|| e->key() == Qt::Key_PageDown
|| e->key() == Qt::Key_K )
{
bool singleStep = e->key() == Qt::Key_Down || e->key() == Qt::Key_K;
slotScrollDown( singleStep );
}
else
{
bool singleStep = e->key() == Qt::Key_Up || e->key() == Qt::Key_I;
slotScrollUp( singleStep );
}
break; break;
case Qt::Key_Left: case Qt::Key_Left:
case Qt::Key_H: case Qt::Key_J:
if ( horizontalScrollBar()->maximum() == 0 ) if ( horizontalScrollBar()->maximum() == 0 )
{ {
//if we cannot scroll we go to the previous page vertically //if we cannot scroll we go to the previous page vertically
@ -3405,17 +3416,11 @@ void PageView::wheelEvent( QWheelEvent *e )
vScroll = verticalScrollBar()->value(); vScroll = verticalScrollBar()->value();
e->accept(); e->accept();
if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) { if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) {
d->controlWheelAccumulatedDelta += delta; d->zoomFactor *= exp( (double)delta / 120.0 );
if ( d->controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep ) d->blockPixmapsRequest = true;
{ updateZoom( ZoomRefreshCurrent );
slotZoomOut(); d->blockPixmapsRequest = false;
d->controlWheelAccumulatedDelta = 0; viewport()->repaint();
}
else if ( d->controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep )
{
slotZoomIn();
d->controlWheelAccumulatedDelta = 0;
}
} }
else else
{ {
@ -5062,7 +5067,7 @@ void PageView::slotAutoScroll()
// compute delay between timer ticks and scroll amount per tick // compute delay between timer ticks and scroll amount per tick
int index = abs( d->scrollIncrement ) - 1; // 0..9 int index = abs( d->scrollIncrement ) - 1; // 0..9
const int scrollDelay[10] = { 200, 100, 50, 30, 20, 30, 25, 20, 30, 20 }; const int scrollDelay[10] = { 100, 50, 25, 15, 10, 15, 12, 10, 15, 10 };
const int scrollOffset[10] = { 1, 1, 1, 1, 1, 2, 2, 2, 4, 4 }; const int scrollOffset[10] = { 1, 1, 1, 1, 1, 2, 2, 2, 4, 4 };
d->autoScrollTimer->start( scrollDelay[ index ] ); d->autoScrollTimer->start( scrollDelay[ index ] );
int delta = d->scrollIncrement > 0 ? scrollOffset[ index ] : -scrollOffset[ index ]; int delta = d->scrollIncrement > 0 ? scrollOffset[ index ] : -scrollOffset[ index ];

Loading…
Cancel
Save