Compare commits

...

5 Commits

Author SHA1 Message Date
Jacopo De Simoi f88b9be6bb [helm] explore how to do this 6 years ago
Jacopo De Simoi 944be4d93d Use pixel events for smooth zooming 7 years ago
Jacopo De Simoi c9aeb8fbc9 Always hide horizontal scrollbar 7 years ago
Jacopo De Simoi 480f0caf0d Use ijkl-arrows rather than vim-arrows 7 years ago
Jacopo De Simoi 9c667af45b Make autoscroll faster 7 years ago
  1. 62
      ui/pageview.cpp

@ -839,11 +839,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 );
} }
@ -1823,6 +1824,16 @@ void PageView::paintEvent(QPaintEvent *pe)
pixmapPainter.drawRect( contentsRect ); pixmapPainter.drawRect( contentsRect );
} }
// 5) Layer 3: links
qDebug() << "here";
for ( PageViewItem * i : qAsConst( d->visibleItems ) )
{
const QRect & r = i->croppedGeometry();
qDebug() << r;
pixmapPainter.setPen(Qt::green );
pixmapPainter.drawRect( r );
}
// finish painting and draw contents // finish painting and draw contents
pixmapPainter.end(); pixmapPainter.end();
screenPainter.drawPixmap( contentsRect.left(), contentsRect.top(), doubleBuffer ); screenPainter.drawPixmap( contentsRect.left(), contentsRect.top(), doubleBuffer );
@ -1858,6 +1869,27 @@ void PageView::paintEvent(QPaintEvent *pe)
// 3b) Layer 1: give mouseAnnotation painting control // 3b) Layer 1: give mouseAnnotation painting control
d->mouseAnnotation->routePaint( &screenPainter, contentsRect ); d->mouseAnnotation->routePaint( &screenPainter, contentsRect );
qDebug() << "there";
for ( PageViewItem * i : qAsConst( d->visibleItems ) )
{
const QLinkedList< const Okular::ObjectRect *> orects = i->page()->objectRects( Okular::ObjectRect::Action );
if ( !orects.isEmpty() )
{
foreach ( const Okular::ObjectRect * orect, orects ) {
QRect boundingRect = orect->boundingRect(i->page()->width(),i->page()->height());
QRect uncropped = i->uncroppedGeometry();
int pageHeight = i->page()->height();
int pageWidth = i->page()->width();
QRect actualRect;
actualRect.setTop(uncropped.top()+uncropped.height()*boundingRect.top()/pageHeight);
actualRect.setBottom(uncropped.top()+uncropped.height()*boundingRect.bottom()/pageHeight);
actualRect.setLeft(uncropped.left()+uncropped.width()*boundingRect.left()/pageWidth);
actualRect.setRight(uncropped.left()+uncropped.width()*boundingRect.right()/pageWidth);
screenPainter.setPen( Qt::green );
screenPainter.drawRect( actualRect );
}
}
}
// 4) Layer 2: overlays // 4) Layer 2: overlays
if ( Okular::Settings::debugDrawBoundaries() ) if ( Okular::Settings::debugDrawBoundaries() )
{ {
@ -1955,7 +1987,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_I:
case Qt::Key_K: case Qt::Key_K:
case Qt::Key_Down: case Qt::Key_Down:
case Qt::Key_PageDown: case Qt::Key_PageDown:
@ -1964,19 +1996,19 @@ void PageView::keyPressEvent( QKeyEvent * e )
case Qt::Key_Backspace: case Qt::Key_Backspace:
if ( e->key() == Qt::Key_Down if ( e->key() == Qt::Key_Down
|| e->key() == Qt::Key_PageDown || e->key() == Qt::Key_PageDown
|| e->key() == Qt::Key_J ) || e->key() == Qt::Key_K )
{ {
bool singleStep = e->key() == Qt::Key_Down || e->key() == Qt::Key_J; bool singleStep = e->key() == Qt::Key_Down || e->key() == Qt::Key_K;
slotScrollDown( singleStep ); slotScrollDown( singleStep );
} }
else else
{ {
bool singleStep = e->key() == Qt::Key_Up || e->key() == Qt::Key_K; bool singleStep = e->key() == Qt::Key_Up || e->key() == Qt::Key_I;
slotScrollUp( singleStep ); 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
@ -3346,17 +3378,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
{ {
@ -4993,7 +5019,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