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

Qt4: convert on top event to signal/slot model

parent ac1b335c
...@@ -204,6 +204,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -204,6 +204,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
connect( this, SIGNAL(askReleaseVideo( void )), connect( this, SIGNAL(askReleaseVideo( void )),
this, SLOT(releaseVideoSlot( void )), this, SLOT(releaseVideoSlot( void )),
Qt::BlockingQueuedConnection ); Qt::BlockingQueuedConnection );
CONNECT( this, askVideoOnTop(bool), this, setVideoOnTop(bool));
if( videoWidget ) if( videoWidget )
{ {
...@@ -531,21 +532,6 @@ void MainInterface::toggleFSC() ...@@ -531,21 +532,6 @@ void MainInterface::toggleFSC()
* Video Handling * Video Handling
****************************************************************************/ ****************************************************************************/
/* This event is used to deal with the fullscreen and always on top
issue conflict (bug in wx) */
class SetVideoOnTopQtEvent : public QEvent
{
public:
SetVideoOnTopQtEvent( bool _onTop ) :
QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
{}
bool OnTop() const { return onTop; }
private:
bool onTop;
};
/** /**
* NOTE: * NOTE:
* You must not change the state of this object or other Qt4 UI objects, * You must not change the state of this object or other Qt4 UI objects,
...@@ -588,13 +574,13 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -588,13 +574,13 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
void MainInterface::releaseVideo( void ) void MainInterface::releaseVideo( void )
{ {
emit askReleaseVideo(); emit askReleaseVideo();
QApplication::postEvent( this, new SetVideoOnTopQtEvent( false ) );
} }
/* Function that is CONNECTED to the previous emit */ /* Function that is CONNECTED to the previous emit */
void MainInterface::releaseVideoSlot( void ) void MainInterface::releaseVideoSlot( void )
{ {
videoWidget->release(); videoWidget->release();
setVideoOnTop( false );
if( stackCentralW->currentWidget() == videoWidget ) if( stackCentralW->currentWidget() == videoWidget )
restoreStackOldWidget(); restoreStackOldWidget();
...@@ -603,6 +589,24 @@ void MainInterface::releaseVideoSlot( void ) ...@@ -603,6 +589,24 @@ void MainInterface::releaseVideoSlot( void )
stackCentralOldWidget = bgWidget; stackCentralOldWidget = bgWidget;
} }
/* Slot to change the video always-on-top flag.
* Emit askVideoOnTop() to invoke this from other thread. */
void MainInterface::setVideoOnTop( bool on_top )
{
Qt::WindowFlags oldflags = windowFlags(), newflags;
if( on_top )
newflags = oldflags | Qt::WindowStaysOnTopHint;
else
newflags = oldflags & ~Qt::WindowStaysOnTopHint;
if( newflags != oldflags )
{
setWindowFlags( newflags );
show(); /* necessary to apply window flags */
}
}
/* Asynchronous call from WindowControl function */ /* Asynchronous call from WindowControl function */
int MainInterface::controlVideo( int i_query, va_list args ) int MainInterface::controlVideo( int i_query, va_list args )
{ {
...@@ -621,7 +625,8 @@ int MainInterface::controlVideo( int i_query, va_list args ) ...@@ -621,7 +625,8 @@ int MainInterface::controlVideo( int i_query, va_list args )
{ {
unsigned i_arg = va_arg( args, unsigned ); unsigned i_arg = va_arg( args, unsigned );
unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE; unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
QApplication::postEvent( this, new SetVideoOnTopQtEvent( on_top ) );
emit askVideoOnTop( on_top != 0 );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
case VOUT_WINDOW_SET_FULLSCREEN: case VOUT_WINDOW_SET_FULLSCREEN:
...@@ -1035,25 +1040,6 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event) ...@@ -1035,25 +1040,6 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
/************************************************************************ /************************************************************************
* Events stuff * Events stuff
************************************************************************/ ************************************************************************/
void MainInterface::customEvent( QEvent *event )
{
if ( event->type() == (int)SetVideoOnTopEvent_Type )
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
Qt::WindowFlags oldflags = windowFlags(), newflags;
if( p_event->OnTop() )
newflags = oldflags | Qt::WindowStaysOnTopHint;
else
newflags = oldflags & ~Qt::WindowStaysOnTopHint;
if( newflags != oldflags )
{
setWindowFlags( newflags );
show(); /* necessary to apply window flags */
}
}
}
void MainInterface::keyPressEvent( QKeyEvent *e ) void MainInterface::keyPressEvent( QKeyEvent *e )
{ {
handleKeyPress( e ); handleKeyPress( e );
......
...@@ -97,7 +97,6 @@ protected: ...@@ -97,7 +97,6 @@ protected:
virtual void dragMoveEvent( QDragMoveEvent * ); virtual void dragMoveEvent( QDragMoveEvent * );
virtual void dragLeaveEvent( QDragLeaveEvent * ); virtual void dragLeaveEvent( QDragLeaveEvent * );
virtual void closeEvent( QCloseEvent *); virtual void closeEvent( QCloseEvent *);
virtual void customEvent( QEvent *);
virtual void keyPressEvent( QKeyEvent *); virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * ); virtual void wheelEvent( QWheelEvent * );
...@@ -215,6 +214,7 @@ private slots: ...@@ -215,6 +214,7 @@ private slots:
else resize( size() - stackCentralW->size() + QSize( w, h ) ); else resize( size() - stackCentralW->size() + QSize( w, h ) );
debug(); } debug(); }
void setVideoOnTop( bool );
signals: signals:
void askGetVideo( WId *p_id, int *pi_x, int *pi_y, void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
...@@ -222,6 +222,7 @@ signals: ...@@ -222,6 +222,7 @@ signals:
void askReleaseVideo( ); void askReleaseVideo( );
void askVideoToResize( unsigned int, unsigned int ); void askVideoToResize( unsigned int, unsigned int );
void askVideoSetFullScreen( bool ); void askVideoSetFullScreen( bool );
void askVideoOnTop( bool );
void minimalViewToggled( bool ); void minimalViewToggled( bool );
void fullscreenInterfaceToggled( 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