[vlc-commits] qt: Convert seek slider wheel events to actions

Hugo Beauzée-Luyssen git at videolan.org
Fri Mar 9 11:24:45 CET 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Thu Mar  8 15:03:37 2018 +0100| [8314cd6ce6774e7086b0ed67567bea2fdeb15895] | committer: Hugo Beauzée-Luyssen

qt: Convert seek slider wheel events to actions

Fix #19790
This will also make it easier to make the jump size configurable

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8314cd6ce6774e7086b0ed67567bea2fdeb15895
---

 modules/gui/qt/components/controller.cpp |  2 +-
 modules/gui/qt/dialogs/toolbar.cpp       |  2 +-
 modules/gui/qt/util/input_slider.cpp     | 15 ++++++++-------
 modules/gui/qt/util/input_slider.hpp     |  4 +++-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules/gui/qt/components/controller.cpp b/modules/gui/qt/components/controller.cpp
index e679206df8..0ed1c65aeb 100644
--- a/modules/gui/qt/components/controller.cpp
+++ b/modules/gui/qt/components/controller.cpp
@@ -350,7 +350,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         }
         break;
     case INPUT_SLIDER: {
-        SeekSlider *slider = new SeekSlider( Qt::Horizontal, NULL, !b_shiny );
+        SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, NULL, !b_shiny );
         SeekPoints *chapters = new SeekPoints( this, p_intf );
         CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() );
         slider->setChapters( chapters );
diff --git a/modules/gui/qt/dialogs/toolbar.cpp b/modules/gui/qt/dialogs/toolbar.cpp
index b71dfe5d97..58a90f7c5b 100644
--- a/modules/gui/qt/dialogs/toolbar.cpp
+++ b/modules/gui/qt/dialogs/toolbar.cpp
@@ -463,7 +463,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
             break;
         case INPUT_SLIDER:
             {
-                SeekSlider *slider = new SeekSlider( Qt::Horizontal, this );
+                SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, this );
                 widget = slider;
             }
             widgetItem->setText( qtr("Time Slider") );
diff --git a/modules/gui/qt/util/input_slider.cpp b/modules/gui/qt/util/input_slider.cpp
index f76a784617..b612354832 100644
--- a/modules/gui/qt/util/input_slider.cpp
+++ b/modules/gui/qt/util/input_slider.cpp
@@ -35,6 +35,8 @@
 #include "input_manager.hpp"
 #include "imagehelper.hpp"
 
+#include <vlc_actions.h>
+
 #include <QPaintEvent>
 #include <QPainter>
 #include <QBitmap>
@@ -63,8 +65,8 @@ namespace {
     int const FADEOUT_DELAY = 2000;
 }
 
-SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
-          : QSlider( q, _parent ), b_classic( _static ), animLoading( NULL )
+SeekSlider::SeekSlider( intf_thread_t *p_intf, Qt::Orientation q, QWidget *_parent, bool _static )
+          : QSlider( q, _parent ), p_intf( p_intf ), b_classic( _static ), animLoading( NULL )
 {
     isSliding = false;
     isJumping = false;
@@ -401,11 +403,10 @@ void SeekSlider::wheelEvent( QWheelEvent *event )
     /* Don't do anything if we are for somehow reason sliding */
     if( !isSliding && isEnabled() )
     {
-        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() / static_cast<float>( maximum() ) );
+        if ( event->delta() > 0 )
+            var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
+        else
+            var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
     }
     event->accept();
 }
diff --git a/modules/gui/qt/util/input_slider.hpp b/modules/gui/qt/util/input_slider.hpp
index 2c593603b4..aad65ce4d4 100644
--- a/modules/gui/qt/util/input_slider.hpp
+++ b/modules/gui/qt/util/input_slider.hpp
@@ -55,7 +55,8 @@ class SeekSlider : public QSlider
     Q_PROPERTY(qreal handleOpacity READ handleOpacity WRITE setHandleOpacity)
     Q_PROPERTY(qreal loadingProperty READ loading WRITE setLoading)
 public:
-    SeekSlider( Qt::Orientation q, QWidget *_parent = 0, bool _classic = false );
+    SeekSlider( intf_thread_t *p_intf, Qt::Orientation q, QWidget *_parent = 0,
+                bool _classic = false );
     virtual ~SeekSlider();
     void setChapters( SeekPoints * );
 
@@ -84,6 +85,7 @@ protected:
     int   getValueFromXPos( int );
 
 private:
+    intf_thread_t *p_intf;
     bool isSliding;        /* Whether we are currently sliding by user action */
     bool isJumping;              /* if we requested a jump to another chapter */
     int inputLength;                           /* InputLength that can change */



More information about the vlc-commits mailing list