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; return;
} }
const int delta = e->delta(); const float delta = e->angleDelta().y() / 120.f;
if (delta < 0) if (delta != 0)
zoomOut(); zoomF(delta);
else if (delta > 0)
zoomIn();
return; return;
} }
QPlainTextEdit::wheelEvent(e); QPlainTextEdit::wheelEvent(e);
} }
void TextEditorWidget::zoomIn() void TextEditorWidget::zoomF(float delta)
{ {
d->clearVisibleFoldedBlock(); 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() emit requestFontZoom(step);
{
d->clearVisibleFoldedBlock();
emit requestFontZoom(-10);
} }
void TextEditorWidget::zoomReset() void TextEditorWidget::zoomReset()

View File

@@ -378,8 +378,7 @@ public:
void circularPaste(); void circularPaste();
void switchUtf8bom(); void switchUtf8bom();
void zoomIn(); void zoomF(float delta);
void zoomOut();
void zoomReset(); void zoomReset();
void cutLine(); void cutLine();