Correct CTRL+wheel zoom on touchpad

When we get fine-grained scroll events we shouldn't zoom 10% on every
event but scale zooming so they add up to 10% for every wheel click.

Task-number: QTBUG-49024
Change-Id: I08ac728bf1421148680de8fbbc76054ba2cce884
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Allan Sandfeld Jensen
2015-11-30 14:37:24 +01:00
parent fb1e9bc785
commit b2f2b92713
2 changed files with 12 additions and 14 deletions

View File

@@ -5476,26 +5476,25 @@ void TextEditorWidget::wheelEvent(QWheelEvent *e)
return;
}
const int delta = e->delta();
if (delta < 0)
zoomOut();
else if (delta > 0)
zoomIn();
const float delta = e->angleDelta().y() / 120.f;
if (delta != 0)
zoomF(delta);
return;
}
QPlainTextEdit::wheelEvent(e);
}
void TextEditorWidget::zoomIn()
void TextEditorWidget::zoomF(float delta)
{
d->clearVisibleFoldedBlock();
emit requestFontZoom(10);
}
float step = 10.f * delta;
// Ensure we always zoom a minimal step in-case the resolution is more than 16x
if (step > 0 && step < 1)
step = 1;
else if (step < 0 && step > -1)
step = -1;
void TextEditorWidget::zoomOut()
{
d->clearVisibleFoldedBlock();
emit requestFontZoom(-10);
emit requestFontZoom(step);
}
void TextEditorWidget::zoomReset()