Commit d278550e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

qt: handle video widget cursor automatically (refs #18661)

parent a21fc097
......@@ -88,6 +88,12 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i, QWidget* p_parent )
layout->setContentsMargins( 0, 0, 0, 0 );
stable = NULL;
p_window = NULL;
cursorTimer = new QTimer( this );
cursorTimer->setSingleShot( true );
connect( cursorTimer, SIGNAL(timeout()), this, SLOT(hideCursor()) );
cursorTimeout = var_InheritInteger( _p_i, "mouse-hide-timeout" );
show();
}
......@@ -297,6 +303,17 @@ void VideoWidget::resizeEvent( QResizeEvent *event )
reportSize();
}
void VideoWidget::hideCursor()
{
setCursor( Qt::BlankCursor );
}
void VideoWidget::showCursor()
{
setCursor( Qt::ArrowCursor );
cursorTimer->start( cursorTimeout );
}
int VideoWidget::qtMouseButton2VLC( Qt::MouseButton qtButton )
{
if( p_window == NULL )
......@@ -320,6 +337,7 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event )
if( vlc_button >= 0 )
{
vout_window_ReportMouseReleased( p_window, vlc_button );
showCursor();
event->accept();
}
else
......@@ -332,6 +350,7 @@ void VideoWidget::mousePressEvent( QMouseEvent* event )
if( vlc_button >= 0 )
{
vout_window_ReportMousePressed( p_window, vlc_button );
showCursor();
event->accept();
}
else
......@@ -350,6 +369,7 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event )
current_pos *= devicePixelRatio();
#endif
vout_window_ReportMouseMoved( p_window, current_pos.x(), current_pos.y() );
showCursor();
event->accept();
}
else
......@@ -362,6 +382,7 @@ void VideoWidget::mouseDoubleClickEvent( QMouseEvent *event )
if( vlc_button >= 0 )
{
vout_window_ReportMouseDoubleClick( p_window, vlc_button );
showCursor();
event->accept();
}
else
......
......@@ -47,6 +47,7 @@
class QMenu;
class QSlider;
class QTimer;
class QWidgetAction;
class SpeedControlWidget;
struct vout_window_t;
......@@ -84,14 +85,20 @@ private:
QWidget *stable;
QLayout *layout;
QTimer *cursorTimer;
int cursorTimeout;
void reportSize();
void showCursor();
signals:
void sizeChanged( int, int );
public slots:
void setSize( unsigned int, unsigned int );
private slots:
void hideCursor();
};
/******************** Background Widget ****************/
......
......@@ -222,8 +222,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( this, askVideoSetFullScreen( bool ),
this, setVideoFullScreen( bool ) );
CONNECT( this, askHideMouse( bool ),
this, setHideMouse( bool ) );
}
CONNECT( THEDP, toolBarConfUpdated(), this, toolBarConfUpdated() );
......@@ -930,11 +928,6 @@ void MainInterface::setVideoFullScreen( bool fs )
videoWidget->sync();
}
void MainInterface::setHideMouse( bool hide )
{
videoWidget->setCursor( hide ? Qt::BlankCursor : Qt::ArrowCursor );
}
/* Slot to change the video always-on-top flag.
* Emit askVideoOnTop() to invoke this from other thread. */
void MainInterface::setVideoOnTop( bool on_top )
......@@ -1000,13 +993,6 @@ int MainInterface::controlVideo( int i_query, va_list args )
emit askVideoSetFullScreen( b_fs );
return VLC_SUCCESS;
}
case VOUT_WINDOW_HIDE_MOUSE:
{
bool b_hide = va_arg( args, int );
emit askHideMouse( b_hide );
return VLC_SUCCESS;
}
default:
msg_Warn( p_intf, "unsupported control query" );
return VLC_EGENERIC;
......
......@@ -262,7 +262,6 @@ protected slots:
void setVideoSize( unsigned int, unsigned int );
void videoSizeChanged( int, int );
virtual void setVideoFullScreen( bool );
void setHideMouse( bool );
void setVideoOnTop( bool );
void setBoss();
void setRaise();
......@@ -279,7 +278,6 @@ signals:
void askReleaseVideo( );
void askVideoToResize( unsigned int, unsigned int );
void askVideoSetFullScreen( bool );
void askHideMouse( bool );
void askVideoOnTop( bool );
void minimalViewToggled( bool );
void fullscreenInterfaceToggled( bool );
......
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