[vlc-devel] [PATCH] Qt: Seek/SoundSlider: handle hijacked released mouse state (fix #8583)
Francois Cartegnie
fcvlcdev at free.fr
Sat May 18 13:36:53 CEST 2013
---
modules/gui/qt4/util/input_slider.cpp | 49 +++++++++++++++++++++++++----------
modules/gui/qt4/util/input_slider.hpp | 3 +++
2 files changed, 39 insertions(+), 13 deletions(-)
diff --git a/modules/gui/qt4/util/input_slider.cpp b/modules/gui/qt4/util/input_slider.cpp
index 9ea5efe..3a92a78 100644
--- a/modules/gui/qt4/util/input_slider.cpp
+++ b/modules/gui/qt4/util/input_slider.cpp
@@ -199,9 +199,9 @@ void SeekSlider::updateBuffering( float f_buffering_ )
repaint();
}
-void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
+void SeekSlider::processReleasedButton()
{
- event->accept();
+ if ( !isSliding && !isJumping ) return;
isSliding = false;
bool b_seekPending = seekLimitTimer->isActive();
seekLimitTimer->stop(); /* We're not sliding anymore: only last seek on release */
@@ -210,11 +210,21 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
isJumping = false;
return;
}
- QSlider::mouseReleaseEvent( event );
if( b_seekPending && isEnabled() )
updatePos();
}
+void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
+{
+ if ( event->button() != Qt::LeftButton && event->button() != Qt::MidButton )
+ {
+ QSlider::mouseReleaseEvent( event );
+ return;
+ }
+ event->accept();
+ processReleasedButton();
+}
+
void SeekSlider::mousePressEvent( QMouseEvent* event )
{
/* Right-click */
@@ -273,6 +283,12 @@ void SeekSlider::mousePressEvent( QMouseEvent* event )
void SeekSlider::mouseMoveEvent( QMouseEvent *event )
{
+ if ( ! ( event->buttons() & ( Qt::LeftButton | Qt::MidButton ) ) )
+ {
+ /* Handle button release when mouserelease has been hijacked by popup */
+ processReleasedButton();
+ }
+
if ( !isEnabled() ) return event->accept();
if( isSliding )
@@ -546,23 +562,30 @@ void SoundSlider::mousePressEvent( QMouseEvent *event )
}
}
-void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
+void SoundSlider::processReleasedButton()
{
- if( event->button() != Qt::RightButton )
+ if( !b_mouseOutside && value() != i_oldvalue )
{
- if( !b_mouseOutside && value() != i_oldvalue )
- {
- emit sliderReleased();
- setValue( value() );
- emit sliderMoved( value() );
- }
- isSliding = false;
- b_mouseOutside = false;
+ emit sliderReleased();
+ setValue( value() );
+ emit sliderMoved( value() );
}
+ isSliding = false;
+ b_mouseOutside = false;
+}
+
+void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
+{
+ if( event->button() != Qt::RightButton )
+ processReleasedButton();
}
void SoundSlider::mouseMoveEvent( QMouseEvent *event )
{
+ /* handle mouserelease hijacking */
+ if ( isSliding && ( event->buttons() & ~Qt::RightButton ) == Qt::NoButton )
+ processReleasedButton();
+
if( isSliding )
{
QRect rect( paddingL - 15, -1,
diff --git a/modules/gui/qt4/util/input_slider.hpp b/modules/gui/qt4/util/input_slider.hpp
index 91986dd..00b7b19 100644
--- a/modules/gui/qt4/util/input_slider.hpp
+++ b/modules/gui/qt4/util/input_slider.hpp
@@ -71,6 +71,7 @@ protected:
virtual QSize sizeHint() const;
+ void processReleasedButton();
bool isAnimationRunning() const;
qreal handleOpacity() const;
void setHandleOpacity( qreal opacity );
@@ -143,6 +144,8 @@ protected:
virtual void mouseMoveEvent( QMouseEvent * );
virtual void mouseReleaseEvent( QMouseEvent * );
+ void processReleasedButton();
+
private:
bool isSliding; /* Whether we are currently sliding by user action */
bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
--
1.8.1.4
More information about the vlc-devel
mailing list