[vlc-commits] Qt: SeekSlider: non seekable must be non interactive

Francois Cartegnie git at videolan.org
Sat Jun 23 13:57:16 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Jun 23 13:52:24 2012 +0200| [1c9e44023236da66c535fbafeac76a5c86d296dd] | committer: Francois Cartegnie

Qt: SeekSlider: non seekable must be non interactive

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

 modules/gui/qt4/components/controller.cpp |    3 +++
 modules/gui/qt4/input_manager.cpp         |    5 +++++
 modules/gui/qt4/input_manager.hpp         |    1 +
 modules/gui/qt4/util/input_slider.cpp     |   16 ++++++++++------
 modules/gui/qt4/util/input_slider.hpp     |    2 ++
 5 files changed, 21 insertions(+), 6 deletions(-)

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



More information about the vlc-commits mailing list