Commit ba77b612 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: Seek/SoundSlider: handle hijacked released mouse state (fix #8583)

parent 0708cb56
...@@ -199,9 +199,9 @@ void SeekSlider::updateBuffering( float f_buffering_ ) ...@@ -199,9 +199,9 @@ void SeekSlider::updateBuffering( float f_buffering_ )
repaint(); repaint();
} }
void SeekSlider::mouseReleaseEvent( QMouseEvent *event ) void SeekSlider::processReleasedButton()
{ {
event->accept(); if ( !isSliding && !isJumping ) return;
isSliding = false; isSliding = false;
bool b_seekPending = seekLimitTimer->isActive(); bool b_seekPending = seekLimitTimer->isActive();
seekLimitTimer->stop(); /* We're not sliding anymore: only last seek on release */ seekLimitTimer->stop(); /* We're not sliding anymore: only last seek on release */
...@@ -210,11 +210,21 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event ) ...@@ -210,11 +210,21 @@ void SeekSlider::mouseReleaseEvent( QMouseEvent *event )
isJumping = false; isJumping = false;
return; return;
} }
QSlider::mouseReleaseEvent( event );
if( b_seekPending && isEnabled() ) if( b_seekPending && isEnabled() )
updatePos(); 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 ) void SeekSlider::mousePressEvent( QMouseEvent* event )
{ {
/* Right-click */ /* Right-click */
...@@ -273,6 +283,12 @@ void SeekSlider::mousePressEvent( QMouseEvent* event ) ...@@ -273,6 +283,12 @@ void SeekSlider::mousePressEvent( QMouseEvent* event )
void SeekSlider::mouseMoveEvent( 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 ( !isEnabled() ) return event->accept();
if( isSliding ) if( isSliding )
...@@ -546,10 +562,8 @@ void SoundSlider::mousePressEvent( QMouseEvent *event ) ...@@ -546,10 +562,8 @@ 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(); emit sliderReleased();
...@@ -558,11 +572,20 @@ void SoundSlider::mouseReleaseEvent( QMouseEvent *event ) ...@@ -558,11 +572,20 @@ void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
} }
isSliding = false; isSliding = false;
b_mouseOutside = false; b_mouseOutside = false;
} }
void SoundSlider::mouseReleaseEvent( QMouseEvent *event )
{
if( event->button() != Qt::RightButton )
processReleasedButton();
} }
void SoundSlider::mouseMoveEvent( QMouseEvent *event ) void SoundSlider::mouseMoveEvent( QMouseEvent *event )
{ {
/* handle mouserelease hijacking */
if ( isSliding && ( event->buttons() & ~Qt::RightButton ) == Qt::NoButton )
processReleasedButton();
if( isSliding ) if( isSliding )
{ {
QRect rect( paddingL - 15, -1, QRect rect( paddingL - 15, -1,
......
...@@ -71,6 +71,7 @@ protected: ...@@ -71,6 +71,7 @@ protected:
virtual QSize sizeHint() const; virtual QSize sizeHint() const;
void processReleasedButton();
bool isAnimationRunning() const; bool isAnimationRunning() const;
qreal handleOpacity() const; qreal handleOpacity() const;
void setHandleOpacity( qreal opacity ); void setHandleOpacity( qreal opacity );
...@@ -143,6 +144,8 @@ protected: ...@@ -143,6 +144,8 @@ protected:
virtual void mouseMoveEvent( QMouseEvent * ); virtual void mouseMoveEvent( QMouseEvent * );
virtual void mouseReleaseEvent( QMouseEvent * ); virtual void mouseReleaseEvent( QMouseEvent * );
void processReleasedButton();
private: private:
bool isSliding; /* Whether we are currently sliding by user action */ bool isSliding; /* Whether we are currently sliding by user action */
bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */ bool b_mouseOutside; /* Whether the mouse is outside or inside the Widget */
......
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