Skip to content

Commit 7c83cf0

Browse files
authored
Merge pull request #4317 from OpenShot/fix-zoom
Allow mousewheel zoom on webengine
2 parents 235bef1 + c60a54e commit 7c83cf0

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

src/timeline/js/directives/ruler.js

+17
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ App.directive("tlScrollableTracks", function () {
4545
restrict: "A",
4646
link: function (scope, element, attrs) {
4747

48+
/**
49+
* if ctrl is held, scroll in or out.
50+
* Implimentation copied from zoomSlider zoomIn zoomOut
51+
*/
52+
element.on("wheel",function (e) {
53+
if (e.ctrlKey) {
54+
e.preventDefault(); // Don't scroll like a browser
55+
if (e.originalEvent.deltaY > 0) { // Scroll down: Zoom out
56+
/*global timeline*/
57+
timeline.zoomOut();
58+
} else { // Scroll Up: Zoom in
59+
/*global timeline*/
60+
timeline.zoomIn();
61+
}
62+
}
63+
});
64+
4865
// Sync ruler to track scrolling
4966
element.on("scroll", function () {
5067
//set amount scrolled

src/windows/views/webview.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -2745,6 +2745,14 @@ def qt_log(self, level="INFO", message=None):
27452745
level = levels.get(level, logging.INFO)
27462746
self.log_fn(level, message)
27472747

2748+
@pyqtSlot()
2749+
def zoomIn(self):
2750+
get_app().window.sliderZoomWidget.zoomIn()
2751+
2752+
@pyqtSlot()
2753+
def zoomOut(self):
2754+
get_app().window.sliderZoomWidget.zoomOut()
2755+
27482756
def update_scroll(self, newScroll):
27492757
"""Force a scroll event on the timeline (i.e. the zoom slider is moving, so we need to scroll the timeline)"""
27502758
# Get access to timeline scope and set scale to new computed value
@@ -2776,20 +2784,6 @@ def update_zoom(self, newScale):
27762784
get_app().updates.update(["scale"], newScale)
27772785
get_app().updates.ignore_history = False
27782786

2779-
# Capture wheel event to alter zoom slider control
2780-
def wheelEvent(self, event):
2781-
if event.modifiers() & Qt.ControlModifier:
2782-
event.accept()
2783-
2784-
# Modify zooms factor
2785-
if event.angleDelta().y() > 0:
2786-
get_app().window.sliderZoomWidget.zoomIn()
2787-
else:
2788-
get_app().window.sliderZoomWidget.zoomOut()
2789-
2790-
else:
2791-
super().wheelEvent(event)
2792-
27932787
# An item is being dragged onto the timeline (mouse is entering the timeline now)
27942788
def dragEnterEvent(self, event):
27952789

0 commit comments

Comments
 (0)