[vlc-devel] commit: Qt: InputSlider modification to close #2033. (Jean-Baptiste Kempf )
git version control
git at videolan.org
Fri Sep 12 22:38:41 CEST 2008
vlc | branch: 0.9-bugfix | Jean-Baptiste Kempf <jb at videolan.org> | Fri Sep 12 13:25:29 2008 -0700| [038ee68f1c4e9873b49bdffce88b5dfa7aee25d4] | committer: Jean-Baptiste Kempf
Qt: InputSlider modification to close #2033.
Qt: InputSlider: wheeling on it will seek of 1% in position.
(cherry picked from commit af7cf494ef8b4b50bd98260675936ad4bc08e7fc)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
Qt: Don't accept focus on the input slider. Never. Just process mouseEvents...
(cherry picked from commit 47591074fb80b37e25aa1cc10b9444aeb338cc82)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=038ee68f1c4e9873b49bdffce88b5dfa7aee25d4
---
modules/gui/qt4/util/input_slider.cpp | 17 +++++++++++++++++
modules/gui/qt4/util/input_slider.hpp | 8 +++++++-
2 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index f0d9eab..0eeb8ef 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -50,6 +50,7 @@ InputSlider::InputSlider( Qt::Orientation q,QWidget *_parent ) :
setTracking( true );
setPosition( -1.0, 0, 0 );
secstotimestr( psz_length, 0 );
+ setFocusPolicy( Qt::NoFocus );
CONNECT( this, valueChanged(int), this, userDrag( int ) );
}
@@ -110,6 +111,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
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index 39b5066..fa6214d 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -27,9 +27,13 @@
#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
{
More information about the vlc-devel
mailing list