diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-30 16:21:58 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-11-30 15:32:20 +0000 |
commit | eac395fed121d09e39abcb322c508aa49c467074 (patch) | |
tree | aaba35b7652c73d081f883856f40965dced90260 | |
parent | 86a8bcede091d0afe15c26b6fb2efcbf5989c13b (diff) |
Update examples to deal correctly with fine-grained wheel events
Zooming in large steps on every wheel-events breaks with fine-grained
wheel events like we get on touch-pads. We should therefore not
encourage that in our examples.
Change-Id: Ie2e70b91c66c73f12ef1f6cd55c8610ae70b36ed
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r-- | examples/quick/mousearea/mousearea-wheel-example.qml | 7 | ||||
-rw-r--r-- | src/quick/items/qquickevents.cpp | 5 |
2 files changed, 4 insertions, 8 deletions
diff --git a/examples/quick/mousearea/mousearea-wheel-example.qml b/examples/quick/mousearea/mousearea-wheel-example.qml index ca6518ec4b..861639811c 100644 --- a/examples/quick/mousearea/mousearea-wheel-example.qml +++ b/examples/quick/mousearea/mousearea-wheel-example.qml @@ -64,10 +64,9 @@ Rectangle { anchors.fill: parent onWheel: { if (wheel.modifiers & Qt.ControlModifier) { - if (wheel.angleDelta.y > 0) - parent.scaleFactor += 0.2; - else if (parent.scaleFactor - 0.2 >= 0.2) - parent.scaleFactor -= 0.2; + parent.scaleFactor += 0.2 * wheel.angleDelta.y / 120; + if (parent.scaleFactor < 0) + parent.scaleFactor = 0; } } } diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index 520b9d46bb..88deefbd9a 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -352,10 +352,7 @@ Item { MouseArea { onWheel: { if (wheel.modifiers & Qt.ControlModifier) { - if (wheel.angleDelta.y > 0) - zoomIn(); - else - zoomOut(); + adjustZoom(wheel.angleDelta.y / 120); } } } |