]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Qt4: undo always-on-top hint when the video is released
[vlc] / modules / gui / qt4 / main_interface.cpp
index 620045db514a081775a1cfb5be2d6c58ad47d300..986964043079ffe6f65f39a34dff049c349c6caf 100644 (file)
@@ -133,7 +133,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      *  UI and Widgets design
      **************************/
     setVLCWindowsTitle();
-    createMainWidget( settings );
 
     /************
      * Menu Bar *
@@ -142,6 +141,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
              this, destroyPopupMenu() );
 
+    createMainWidget( settings );
     /*********************************
      * Create the Systray Management *
      *********************************/
@@ -233,16 +233,16 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Register callback for the intf-popupmenu variable */
     var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
 
+    /* Playlist */
+    int i_plVis = settings->value( "MainWindow/playlist-visible", false ).toBool();
+
+    if( i_plVis ) togglePlaylist();
+
     /**** FINAL SIZING and placement of interface */
     settings->beginGroup( "MainWindow" );
     QVLCTools::restoreWidgetPosition( settings, this, QSize(400, 100) );
-
-    /* Playlist */
-    int i_plVis = settings->value( "playlist-visible", false ).toBool();
     settings->endGroup();
 
-    if( i_plVis ) togglePlaylist();
-
     /* Final sizing and showing */
     setVisible( !b_hideAfterCreation );
 
@@ -588,6 +588,7 @@ 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 */
@@ -652,6 +653,9 @@ void MainInterface::createPlaylist()
     }
     else
     {
+#ifdef WIN32
+        playlistWidget->setParent( NULL );
+#endif
         playlistWidget->setWindowFlags( Qt::Window );
 
         /* This will restore the geometry but will not work for position,
@@ -683,6 +687,9 @@ void MainInterface::togglePlaylist()
     }
     else
     {
+#ifdef WIN32
+        playlistWidget->setParent( NULL );
+#endif
         playlistWidget->setWindowFlags( Qt::Window );
         playlistVisible = !playlistVisible;
         playlistWidget->setVisible( playlistVisible );
@@ -699,6 +706,9 @@ void MainInterface::dockPlaylist( bool p_docked )
     if( !p_docked )
     {
         stackCentralW->removeWidget( playlistWidget );
+#ifdef WIN32
+        playlistWidget->setParent( NULL );
+#endif
         playlistWidget->setWindowFlags( Qt::Window );
         QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
                 playlistWidget, QSize( 600, 300 ) );
@@ -1030,11 +1040,17 @@ 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() )
-            setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
+            newflags = oldflags | Qt::WindowStaysOnTopHint;
         else
-            setWindowFlags( windowFlags() & ~Qt::WindowStaysOnTopHint );
-        show(); /* necessary to apply window flags */
+            newflags = oldflags & ~Qt::WindowStaysOnTopHint;
+        if( newflags != oldflags )
+        {
+            setWindowFlags( newflags );
+            show(); /* necessary to apply window flags */
+        }
     }
 }