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 )
connect( this, SIGNAL(askReleaseVideo( void )),
this, SLOT(releaseVideoSlot( void )),
Qt::BlockingQueuedConnection );
CONNECT( this, askVideoOnTop(bool), this, setVideoOnTop(bool));
if( videoWidget )
{
......@@ -531,21 +532,6 @@ void MainInterface::toggleFSC()
* 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:
* 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,
void MainInterface::releaseVideo( void )
{
emit askReleaseVideo();
QApplication::postEvent( this, new SetVideoOnTopQtEvent( false ) );
}
/* Function that is CONNECTED to the previous emit */
void MainInterface::releaseVideoSlot( void )
{
videoWidget->release();
setVideoOnTop( false );
if( stackCentralW->currentWidget() == videoWidget )
restoreStackOldWidget();
......@@ -603,6 +589,24 @@ void MainInterface::releaseVideoSlot( void )
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 */
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 on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
QApplication::postEvent( this, new SetVideoOnTopQtEvent( on_top ) );
emit askVideoOnTop( on_top != 0 );
return VLC_SUCCESS;
}
case VOUT_WINDOW_SET_FULLSCREEN:
......@@ -1035,25 +1040,6 @@ void MainInterface::dragLeaveEvent(QDragLeaveEvent *event)
/************************************************************************
* 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 )
{
handleKeyPress( e );
......
......@@ -97,7 +97,6 @@ protected:
virtual void dragMoveEvent( QDragMoveEvent * );
virtual void dragLeaveEvent( QDragLeaveEvent * );
virtual void closeEvent( QCloseEvent *);
virtual void customEvent( QEvent *);
virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * );
......@@ -215,6 +214,7 @@ private slots:
else resize( size() - stackCentralW->size() + QSize( w, h ) );
debug(); }
void setVideoOnTop( bool );
signals:
void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
......@@ -222,6 +222,7 @@ signals:
void askReleaseVideo( );
void askVideoToResize( unsigned int, unsigned int );
void askVideoSetFullScreen( 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