forked from qt-creator/qt-creator
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:
@@ -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()
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user