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. 64
      ui/pageview.cpp

@ -839,11 +839,12 @@ void PageView::displayMessage( const QString & message, const QString & details,
void PageView::reparseConfig()
{
// set the scroll bars policies
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
Qt::ScrollBarPolicy scrollBarMode = Okular::Settings::showScrollBars() ?
Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff;
if ( horizontalScrollBarPolicy() != scrollBarMode )
{
setHorizontalScrollBarPolicy( scrollBarMode );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); //setHorizontalScrollBarPolicy( scrollBarMode );
setVerticalScrollBarPolicy( scrollBarMode );
}
@ -1823,6 +1824,16 @@ void PageView::paintEvent(QPaintEvent *pe)
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
pixmapPainter.end();
screenPainter.drawPixmap( contentsRect.left(), contentsRect.top(), doubleBuffer );
@ -1858,6 +1869,27 @@ void PageView::paintEvent(QPaintEvent *pe)
// 3b) Layer 1: give mouseAnnotation painting control
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
if ( Okular::Settings::debugDrawBoundaries() )
{
@ -1955,7 +1987,7 @@ void PageView::keyPressEvent( QKeyEvent * e )
// move/scroll page by using keys
switch ( e->key() )
{
case Qt::Key_J:
case Qt::Key_I:
case Qt::Key_K:
case Qt::Key_Down:
case Qt::Key_PageDown:
@ -1964,19 +1996,19 @@ 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_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 );
}
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 );
}
break;
case Qt::Key_Left:
case Qt::Key_H:
case Qt::Key_J:
if ( horizontalScrollBar()->maximum() == 0 )
{
//if we cannot scroll we go to the previous page vertically
@ -3346,17 +3378,11 @@ void PageView::wheelEvent( QWheelEvent *e )
vScroll = verticalScrollBar()->value();
e->accept();
if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) {
d->controlWheelAccumulatedDelta += delta;
if ( d->controlWheelAccumulatedDelta <= -QWheelEvent::DefaultDeltasPerStep )
{
slotZoomOut();
d->controlWheelAccumulatedDelta = 0;
}
else if ( d->controlWheelAccumulatedDelta >= QWheelEvent::DefaultDeltasPerStep )
{
slotZoomIn();
d->controlWheelAccumulatedDelta = 0;
}
d->zoomFactor *= exp( (double)delta / 120.0 );
d->blockPixmapsRequest = true;
updateZoom( ZoomRefreshCurrent );
d->blockPixmapsRequest = false;
viewport()->repaint();
}
else
{
@ -3821,7 +3847,7 @@ void PageView::selectionStart( const QPoint & pos, const QColor & color, bool /*
void PageView::scrollPosIntoView( const QPoint & pos )
{
// this number slows the speed of the page by its value, chosen not to be too fast or too slow, the actual speed is determined from the mouse position, not critical
const int damping=6;
const int damping=6;
if (pos.x() < horizontalScrollBar()->value()) d->dragScrollVector.setX((pos.x() - horizontalScrollBar()->value())/damping);
else if (horizontalScrollBar()->value() + viewport()->width() < pos.x()) d->dragScrollVector.setX((pos.x() - horizontalScrollBar()->value() - viewport()->width())/damping);
@ -4993,7 +5019,7 @@ void PageView::slotAutoScroll()
// compute delay between timer ticks and scroll amount per tick
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 };
d->autoScrollTimer->start( scrollDelay[ index ] );
int delta = d->scrollIncrement > 0 ? scrollOffset[ index ] : -scrollOffset[ index ];

Loading…
Cancel
Save