Commit 8314cd6c authored by Hugo Beauzée-Luyssen's avatar 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
parent dde0b694
...@@ -350,7 +350,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -350,7 +350,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
} }
break; break;
case INPUT_SLIDER: { 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 ); SeekPoints *chapters = new SeekPoints( this, p_intf );
CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() ); CONNECT( THEMIM->getIM(), chapterChanged( bool ), chapters, update() );
slider->setChapters( chapters ); slider->setChapters( chapters );
......
...@@ -463,7 +463,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) ...@@ -463,7 +463,7 @@ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
break; break;
case INPUT_SLIDER: case INPUT_SLIDER:
{ {
SeekSlider *slider = new SeekSlider( Qt::Horizontal, this ); SeekSlider *slider = new SeekSlider( p_intf, Qt::Horizontal, this );
widget = slider; widget = slider;
} }
widgetItem->setText( qtr("Time Slider") ); widgetItem->setText( qtr("Time Slider") );
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#include "input_manager.hpp" #include "input_manager.hpp"
#include "imagehelper.hpp" #include "imagehelper.hpp"
#include <vlc_actions.h>
#include <QPaintEvent> #include <QPaintEvent>
#include <QPainter> #include <QPainter>
#include <QBitmap> #include <QBitmap>
...@@ -63,8 +65,8 @@ namespace { ...@@ -63,8 +65,8 @@ namespace {
int const FADEOUT_DELAY = 2000; int const FADEOUT_DELAY = 2000;
} }
SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static ) SeekSlider::SeekSlider( intf_thread_t *p_intf, Qt::Orientation q, QWidget *_parent, bool _static )
: QSlider( q, _parent ), b_classic( _static ), animLoading( NULL ) : QSlider( q, _parent ), p_intf( p_intf ), b_classic( _static ), animLoading( NULL )
{ {
isSliding = false; isSliding = false;
isJumping = false; isJumping = false;
...@@ -401,11 +403,10 @@ void SeekSlider::wheelEvent( QWheelEvent *event ) ...@@ -401,11 +403,10 @@ void SeekSlider::wheelEvent( QWheelEvent *event )
/* Don't do anything if we are for somehow reason sliding */ /* Don't do anything if we are for somehow reason sliding */
if( !isSliding && isEnabled() ) if( !isSliding && isEnabled() )
{ {
setValue( value() + event->delta() / 12 ); /* 12 = 8 * 15 / 10 if ( event->delta() > 0 )
Since delta is in 1/8 of ° and mouse have steps of 15 ° var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_JUMP_BACKWARD_SHORT );
and that our slider is in 0.1% and we want one step to be a 1% else
increment of position */ var_SetInteger( p_intf->obj.libvlc, "key-action", ACTIONID_JUMP_FORWARD_SHORT );
emit sliderDragged( value() / static_cast<float>( maximum() ) );
} }
event->accept(); event->accept();
} }
......
...@@ -55,7 +55,8 @@ class SeekSlider : public QSlider ...@@ -55,7 +55,8 @@ class SeekSlider : public QSlider
Q_PROPERTY(qreal handleOpacity READ handleOpacity WRITE setHandleOpacity) Q_PROPERTY(qreal handleOpacity READ handleOpacity WRITE setHandleOpacity)
Q_PROPERTY(qreal loadingProperty READ loading WRITE setLoading) Q_PROPERTY(qreal loadingProperty READ loading WRITE setLoading)
public: 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(); virtual ~SeekSlider();
void setChapters( SeekPoints * ); void setChapters( SeekPoints * );
...@@ -84,6 +85,7 @@ protected: ...@@ -84,6 +85,7 @@ protected:
int getValueFromXPos( int ); int getValueFromXPos( int );
private: private:
intf_thread_t *p_intf;
bool isSliding; /* Whether we are currently sliding by user action */ bool isSliding; /* Whether we are currently sliding by user action */
bool isJumping; /* if we requested a jump to another chapter */ bool isJumping; /* if we requested a jump to another chapter */
int inputLength; /* InputLength that can change */ int inputLength; /* InputLength that can change */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment