]> git.sesse.net Git - kdenlive/commitdiff
Allow zooming the effect scene using ctrl + mouse wheel
authorTill Theato <root@ttill.de>
Sun, 17 Oct 2010 14:09:16 +0000 (14:09 +0000)
committerTill Theato <root@ttill.de>
Sun, 17 Oct 2010 14:09:16 +0000 (14:09 +0000)
svn path=/trunk/kdenlive/; revision=5017

src/monitorscene.cpp
src/monitorscene.h

index 3a305d87aea7e6706c6652f1315a4580648d5198..2d913c546d852a039f9cda3c19bd7f78a212b415 100644 (file)
@@ -127,16 +127,14 @@ void MonitorScene::slotZoomOriginal()
         m_view->centerOn(m_frameBorder);
 }
 
-void MonitorScene::slotZoomOut()
+void MonitorScene::slotZoomOut(int by)
 {
-    slotZoom(qMax(0, (int)(m_zoom * 100 - 1)));
+    slotZoom(qMax(0, (int)(m_zoom * 100 - by)));
 }
 
-void MonitorScene::slotZoomIn()
+void MonitorScene::slotZoomIn(int by)
 {
-    int newzoom = (100 * m_zoom + 0.5);
-    newzoom++;
-    slotZoom(qMin(300, newzoom));
+    slotZoom(qMin(300, (int)(m_zoom * 100 + by + 0.5)));
 }
 
 void MonitorScene::slotSetCursor(const QCursor &cursor)
@@ -178,5 +176,18 @@ void MonitorScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
         emit addKeyframe();
 }
 
+void MonitorScene::wheelEvent(QGraphicsSceneWheelEvent* event)
+{
+    if (event->modifiers() == Qt::ControlModifier) {
+        if (event->delta() > 0)
+            slotZoomIn(5);
+        else
+            slotZoomOut(5);
+
+        event->accept();
+    } else {
+        QGraphicsScene::wheelEvent(event);
+    }
+}
 
 #include "monitorscene.moc"
index 67d7c170f1c5937ea8e513ab80a7752c04b1652c..cf04b624d5510437ef6652be251e5532112762f7 100644 (file)
@@ -52,6 +52,7 @@ protected:
     virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
     /** @brief Adds a keyframe if scene is disabled. */
     virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+    virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
 
 public slots:
     /** @brief Sets the backgrounditem's pixmap to m_backgroundImage (only if a certain amount of time has passed since last update). */
@@ -64,10 +65,10 @@ public slots:
     void slotZoomFit();
     /** @brief Shows the frame at it's original size and center. */
     void slotZoomOriginal();
-    /** @brief Zooms in by 1%. */
-    void slotZoomIn();
-    /** @brief Zooms out by 1%. */
-    void slotZoomOut();
+    /** @brief Zooms in by @param by%. */
+    void slotZoomIn(int by = 1);
+    /** @brief Zooms out by @param by%. */
+    void slotZoomOut(int by = 1);
 
 private slots:
     /** @brief Sets m_backgroundImage to @param image and requests updating the background item. */