]> git.sesse.net Git - vlc/commitdiff
Qt: InputSlider: wheeling on it will seek of 1% in position.
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 12 Sep 2008 20:25:29 +0000 (13:25 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 12 Sep 2008 20:26:10 +0000 (13:26 -0700)
modules/gui/qt4/util/input_slider.cpp
modules/gui/qt4/util/input_slider.hpp

index c94c63217e161c5654eb3a1c5ce99ae897632a55..053d9a2ebf8ec4512ed052d4d14e52f05cdd7480 100644 (file)
@@ -107,6 +107,22 @@ void InputSlider::mouseMoveEvent(QMouseEvent *event)
     setToolTip( psz_length );
 }
 
+void InputSlider::wheelEvent( QWheelEvent *event)
+{
+    /* Don't do anything if we are for somehow reason sliding */
+    if( !b_sliding )
+    {
+        setValue( value() + event->delta()/12 ); /* 12 = 8 * 15 / 10
+         Since delta is in 1/8 of ° and mouse have steps of 15 °
+         and that our slider is in 0.1% and we want one step to be a 1%
+         increment of position */
+        emit sliderDragged( value()/1000.0 );
+    }
+    /* We do accept because for we don't want the parent to change the sound
+       vol */
+    event->accept();
+}
+
 /* This work is derived from Amarok's work under GPLv2+
     - Mark Kretschmann
     - Gábor Lehel
index 39b5066e0c97606a34d97cf656bbd727d0b563d3..fa6214d9444adf8a13a43b41d4ea42ce4920b177 100644 (file)
 
 #include "qt4.hpp"
 
+#include <QAbstractSlider>
 #include <QSlider>
+
 #include <QMouseEvent>
+#include <QWheelEvent>
 
+/* Input Slider derived from QSlider */
 class InputSlider : public QSlider
 {
     Q_OBJECT
@@ -41,6 +45,7 @@ protected:
     virtual void mouseMoveEvent(QMouseEvent *event);
     virtual void mousePressEvent(QMouseEvent* event);
     virtual void mouseReleaseEvent(QMouseEvent* event);
+    virtual void wheelEvent(QWheelEvent *event);
 private:
     bool b_sliding;
     int inputLength;
@@ -54,8 +59,9 @@ signals:
 };
 
 
+/* Sound Slider inherited directly from QAbstractSlider */
+
 class QPaintEvent;
-#include <QAbstractSlider>
 
 class SoundSlider : public QAbstractSlider
 {