Commit 1c9e4402 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: SeekSlider: non seekable must be non interactive

parent 6598d092
...@@ -359,6 +359,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options ) ...@@ -359,6 +359,9 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
THEMIM->getIM(), sliderUpdate( float ) ); THEMIM->getIM(), sliderUpdate( float ) );
CONNECT( THEMIM->getIM(), cachingChanged( float ), CONNECT( THEMIM->getIM(), cachingChanged( float ),
slider, updateBuffering( float ) ); slider, updateBuffering( float ) );
/* Give hint to disable slider's interactivity when useless */
CONNECT( THEMIM->getIM(), inputCanSeek( bool ),
slider, setSeekable( bool ) );
widget = slider; widget = slider;
} }
break; break;
......
...@@ -426,6 +426,11 @@ void InputManager::UpdateNavigation() ...@@ -426,6 +426,11 @@ void InputManager::UpdateNavigation()
} }
else else
emit chapterChanged( false ); emit chapterChanged( false );
if( hasInput() )
emit inputCanSeek( var_GetBool( p_input, "can-seek" ) );
else
emit inputCanSeek( false );
} }
void InputManager::UpdateStatus() void InputManager::UpdateStatus()
......
...@@ -218,6 +218,7 @@ signals: ...@@ -218,6 +218,7 @@ signals:
/// Used to signal whether we should show navigation buttons /// Used to signal whether we should show navigation buttons
void titleChanged( bool ); void titleChanged( bool );
void chapterChanged( bool ); void chapterChanged( bool );
void inputCanSeek( bool );
/// Statistics are updated /// Statistics are updated
void statisticsUpdated( input_item_t* ); void statisticsUpdated( input_item_t* );
void infoChanged( input_item_t* ); void infoChanged( input_item_t* );
......
...@@ -62,6 +62,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static ) ...@@ -62,6 +62,7 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent, bool _static )
mHandleOpacity = 1.0; mHandleOpacity = 1.0;
chapters = NULL; chapters = NULL;
mHandleLength = -1; mHandleLength = -1;
b_seekable = true;
// prepare some static colors // prepare some static colors
QPalette p = palette(); QPalette p = palette();
...@@ -166,7 +167,7 @@ void SeekSlider::setPosition( float pos, int64_t time, int length ) ...@@ -166,7 +167,7 @@ void SeekSlider::setPosition( float pos, int64_t time, int length )
isSliding = false; isSliding = false;
} }
else else
setEnabled( true ); setEnabled( b_seekable );
if( !isSliding ) if( !isSliding )
setValue( (int)( pos * 1000.0 ) ); setValue( (int)( pos * 1000.0 ) );
...@@ -205,15 +206,16 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event ) ...@@ -205,15 +206,16 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
return; return;
} }
QSlider::mouseReleaseEvent( event ); QSlider::mouseReleaseEvent( event );
if( b_seekPending ) if( b_seekPending && isEnabled() )
updatePos(); updatePos();
} }
void SeekSlider::mousePressEvent( QMouseEvent* event ) void SeekSlider::mousePressEvent( QMouseEvent* event )
{ {
/* Right-click */ /* Right-click */
if( event->button() != Qt::LeftButton && if ( !isEnabled() ||
event->button() != Qt::MidButton ) ( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
)
{ {
QSlider::mousePressEvent( event ); QSlider::mousePressEvent( event );
return; return;
...@@ -266,6 +268,8 @@ void SeekSlider::mousePressEvent( QMouseEvent* event ) ...@@ -266,6 +268,8 @@ void SeekSlider::mousePressEvent( QMouseEvent* event )
void SeekSlider::mouseMoveEvent( QMouseEvent *event ) void SeekSlider::mouseMoveEvent( QMouseEvent *event )
{ {
if ( !isEnabled() ) return event->accept();
if( isSliding ) if( isSliding )
{ {
setValue( QStyle::sliderValueFromPosition( MINIMUM, MAXIMUM, event->x() - handleLength() / 2, width() - handleLength(), false) ); setValue( QStyle::sliderValueFromPosition( MINIMUM, MAXIMUM, event->x() - handleLength() / 2, width() - handleLength(), false) );
...@@ -308,7 +312,7 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event ) ...@@ -308,7 +312,7 @@ void SeekSlider::mouseMoveEvent( QMouseEvent *event )
void SeekSlider::wheelEvent( QWheelEvent *event ) 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 ) if( !isSliding && isEnabled() )
{ {
setValue( value() + event->delta() / 12 ); /* 12 = 8 * 15 / 10 setValue( value() + event->delta() / 12 ); /* 12 = 8 * 15 / 10
Since delta is in 1/8 of ° and mouse have steps of 15 ° Since delta is in 1/8 of ° and mouse have steps of 15 °
...@@ -324,7 +328,7 @@ void SeekSlider::enterEvent( QEvent * ) ...@@ -324,7 +328,7 @@ void SeekSlider::enterEvent( QEvent * )
/* Cancel the fade-out timer */ /* Cancel the fade-out timer */
hideHandleTimer->stop(); hideHandleTimer->stop();
/* Only start the fade-in if needed */ /* Only start the fade-in if needed */
if( animHandle->direction() != QAbstractAnimation::Forward ) if( isEnabled() && animHandle->direction() != QAbstractAnimation::Forward )
{ {
/* If pause is called while not running Qt will complain */ /* If pause is called while not running Qt will complain */
if( animHandle->state() == QAbstractAnimation::Running ) if( animHandle->state() == QAbstractAnimation::Running )
......
...@@ -85,6 +85,7 @@ private: ...@@ -85,6 +85,7 @@ private:
float f_buffering; float f_buffering;
SeekPoints* chapters; SeekPoints* chapters;
bool b_classic; bool b_classic;
bool b_seekable;
int mHandleLength; int mHandleLength;
/* Colors & gradients */ /* Colors & gradients */
...@@ -102,6 +103,7 @@ private: ...@@ -102,6 +103,7 @@ private:
public slots: public slots:
void setPosition( float, int64_t, int ); void setPosition( float, int64_t, int );
void setSeekable( bool b ) { b_seekable = b ; }
void updateBuffering( float ); void updateBuffering( float );
void hideHandle(); void hideHandle();
......
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