Skip to content

Commit

Permalink
ListingTextWidget: Improved scroll behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Dax89 committed May 16, 2021
1 parent 063025e commit a294673
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions widgets/listing/listingtextview/listingtextwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,21 @@ void ListingTextWidget::wheelEvent(QWheelEvent *event)
if(m_surface)
{
QPoint ndegrees = event->angleDelta() / 8;
QPoint nsteps = ndegrees / 15;
auto offset = -nsteps.y() * DOCUMENT_WHEEL_UNIT;
m_surface->scroll(m_surface->firstAddress() + offset, nsteps.x());

if(!ndegrees.isNull())
{
rd_offset offset = RD_NVAL;
int ncols = 0;

if(ndegrees.y() > 0) offset = m_surface->firstAddress() -DOCUMENT_WHEEL_UNIT;
else if(ndegrees.y() < 0) offset = m_surface->firstAddress() + DOCUMENT_WHEEL_UNIT;

if(ndegrees.x() > 0) ncols = -1;
else if(ndegrees.x() < 0) ncols = 1;

m_surface->scroll(offset, ncols);
}

event->accept();
return;
}
Expand Down

0 comments on commit a294673

Please sign in to comment.