Commit b2f2b927 authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen
Browse files

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: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent fb1e9bc7
......@@ -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);
}
void TextEditorWidget::zoomOut()
{
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;
emit requestFontZoom(step);
}
void TextEditorWidget::zoomReset()
......
......@@ -378,8 +378,7 @@ public:
void circularPaste();
void switchUtf8bom();
void zoomIn();
void zoomOut();
void zoomF(float delta);
void zoomReset();
void cutLine();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment