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 )
}
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 );
......
......@@ -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") );
......
......@@ -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();
}
......
......@@ -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 */
......
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