[vlc-commits] Qt: seek slider simplifications

Ludovic Fauvet git at videolan.org
Thu Apr 21 00:58:21 CEST 2011


vlc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Wed Apr 20 22:26:18 2011 +0200| [173c6b32af97afd61db52b008fcb204496dd0342] | committer: Jean-Baptiste Kempf

Qt: seek slider simplifications

It also handles the case where the fullscreen controller is hidden while the time tooltip
is still open.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/util/input_slider.cpp |   36 +++++++++++++++-----------------
 modules/gui/qt4/util/input_slider.hpp |    3 +-
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index cfdef8e..d3fb835 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -56,13 +56,9 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
     seekLimitTimer = new QTimer( this );
     seekLimitTimer->setSingleShot( true );
 
-    /* Timer used to avoid flickering when the mouse leave the slider
-       and is over the tooltip */
-    hideTooltipTimer = new QTimer( this );
-    hideTooltipTimer->setSingleShot( true );
-
     /* Tooltip bubble */
     mTimeTooltip = new TimeTooltip( this );
+    mTimeTooltip->setMouseTracking( true );
 
     /* Properties */
     setRange( MINIMUM, MAXIMUM );
@@ -78,7 +74,6 @@ SeekSlider::SeekSlider( Qt::Orientation q, QWidget *_parent )
 
     CONNECT( this, sliderMoved( int ), this, startSeekTimer( int ) );
     CONNECT( seekLimitTimer, timeout(), this, updatePos() );
-    CONNECT( hideTooltipTimer, timeout(), mTimeTooltip, hide() );
 
     mTimeTooltip->installEventFilter( this );
 }
@@ -178,29 +173,32 @@ void SeekSlider::wheelEvent( QWheelEvent *event )
 void SeekSlider::enterEvent( QEvent *e )
 {
     /* Don't show the tooltip if the slider is disabled */
-    if ( isEnabled() )
-    {
-        hideTooltipTimer->stop();
+    if( isEnabled() )
         mTimeTooltip->show();
-    }
 }
 
 void SeekSlider::leaveEvent( QEvent *e )
 {
-    /* Wait 100ms before hiding the tooltip */
-    hideTooltipTimer->start( 100 );
+    if( !rect().contains( mapFromGlobal( QCursor::pos() ) ) )
+        mTimeTooltip->hide();
+}
+
+void SeekSlider::hideEvent( QHideEvent * )
+{
+    mTimeTooltip->hide();
 }
 
 bool SeekSlider::eventFilter( QObject *obj, QEvent *event )
 {
-    /* This eventFilter avoids a flicker that occurs if the
-       mouse cursor leaves the SeekSlider for the TimeTooltip. */
-    if ( obj == mTimeTooltip )
+    if( obj == mTimeTooltip )
     {
-        if ( event->type() == QEvent::Enter )
-            hideTooltipTimer->stop();
-        else if ( event->type() == QEvent::Leave )
-            hideTooltipTimer->start( 100 );
+        if( event->type() == QEvent::Leave ||
+            event->type() == QEvent::MouseMove )
+        {
+            QMouseEvent *e = static_cast<QMouseEvent*>( event );
+            if( !rect().contains( mapFromGlobal( e->globalPos() ) ) )
+                mTimeTooltip->hide();
+        }
         return false;
     }
     else
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index b33ab63..13be400 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -34,6 +34,7 @@
 
 class QMouseEvent;
 class QWheelEvent;
+class QHideEvent;
 class QTimer;
 
 /* Input Slider derived from QSlider */
@@ -51,6 +52,7 @@ protected:
     virtual void wheelEvent( QWheelEvent *event );
     virtual void enterEvent( QEvent * );
     virtual void leaveEvent( QEvent * );
+    virtual void hideEvent( QHideEvent * );
 
     virtual void paintEvent( QPaintEvent* event );
     virtual bool eventFilter( QObject *obj, QEvent *event );
@@ -63,7 +65,6 @@ private:
     int inputLength;        /* InputLength that can change */
     char psz_length[MSTRTIME_MAX_SIZE]; /* Used for the ToolTip */
     QTimer *seekLimitTimer;
-    QTimer *hideTooltipTimer;
     TimeTooltip *mTimeTooltip;
 
 public slots:



More information about the vlc-commits mailing list