]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
qt4: Don't create QMenu without parents
[vlc] / modules / gui / qt4 / main_interface.cpp
index 99e1409e1f7ed549550385b87c0f0de4b8e0ebb7..13c4555715d8485ba6bf9f04c38ac8bb55c7bec6 100644 (file)
@@ -131,7 +131,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      **/
     mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize();
     mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize();
-
+    settings->endGroup( );
 
     /**************
      * Status Bar *
@@ -254,8 +254,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     }
 
     /* Playlist */
-    int i_plVis = settings->value( "playlist-visible", 0 ).toInt();
-
+    int i_plVis = settings->value( "playlist-visible", false ).toBool();
     settings->endGroup();
 
     if( i_plVis ) togglePlaylist();
@@ -274,18 +273,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 MainInterface::~MainInterface()
 {
     /* Unsure we hide the videoWidget before destroying it */
-    if( stackCentralOldWidget == playlistWidget )
+    if( stackCentralOldWidget == videoWidget )
         showBg();
 
-    /* Save playlist state */
-    if( playlistWidget )
-    {
-        if( !isPlDocked() )
-            QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
-
-        delete playlistWidget;
-    }
-
 #ifdef WIN32
     if( himl )
         ImageList_Destroy( himl );
@@ -305,8 +295,17 @@ MainInterface::~MainInterface()
 
     /* Save states */
     settings->beginGroup( "MainWindow" );
+
     settings->setValue( "pl-dock-status", b_plDocked );
-    settings->setValue( "playlist-visible", (int)playlistVisible );
+    /* Save playlist state */
+    if( playlistWidget )
+    {
+        settings->setValue( "playlist-visible",
+                            isPlDocked() ?
+                            playlistVisible :
+                            playlistWidget->isVisible() /* FIXME */ );
+    }
+
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
 
@@ -317,8 +316,15 @@ MainInterface::~MainInterface()
 
     /* Save this size */
     QVLCTools::saveWidgetPosition(settings, this);
+
     settings->endGroup();
 
+    /* Save undocked playlist size */
+    if( playlistWidget && !isPlDocked() )
+        QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
+
+    delete playlistWidget;
+
     delete statusBar();
 
     /* Unregister callbacks */
@@ -339,11 +345,6 @@ void MainInterface::recreateToolbars()
     delete inputC;
 
     controls = new ControlsWidget( p_intf, false, this ); /* FIXME */
-    CONNECT( controls, advancedControlsToggled( bool ),
-             this, adaptGeometry() );
-    CONNECT( controls, sizeChanged(),
-             this, adaptGeometry() );
-
     inputC = new InputControlsWidget( p_intf, this );
 
     mainLayout->insertWidget( 2, inputC );
@@ -376,13 +377,11 @@ void MainInterface::createMainWidget( QSettings *settings )
     }
     mainLayout->insertWidget( 1, stackCentralW );
 
+    settings->beginGroup( "MainWindow" );
+
     /* Create the CONTROLS Widget */
     controls = new ControlsWidget( p_intf,
                    settings->value( "adv-controls", false ).toBool(), this );
-    CONNECT( controls, advancedControlsToggled( bool ),
-             this, adaptGeometry() );
-    CONNECT( controls, sizeChanged(),
-             this, adaptGeometry() );
     inputC = new InputControlsWidget( p_intf, this );
 
     mainLayout->insertWidget( 2, inputC );
@@ -396,7 +395,7 @@ void MainInterface::createMainWidget( QSettings *settings )
     visualSelector->hide();
     #endif
 
-    getSettings()->endGroup();
+    settings->endGroup();
 
     /* Enable the popup menu in the MI */
     main->setContextMenuPolicy( Qt::CustomContextMenu );
@@ -480,19 +479,6 @@ inline void MainInterface::createStatusBar()
  * Handling of sizing of the components
  **********************************************************************/
 
-/* This function is called:
-   - Advanced buttons toggled
-   - Toolbar geom changed
- */
-void MainInterface::adaptGeometry()
-{
-  resize( sizeHint() );
-
-#ifdef DEBUG_INTF
-    debug();
-#endif
-}
-
 void MainInterface::debug()
 {
 #ifdef DEBUG_INTF
@@ -540,12 +526,12 @@ inline void MainInterface::restoreStackOldWidget()
 
 void MainInterface::destroyPopupMenu()
 {
-    QVLCMenu::PopupMenu( p_intf, false );
+    QVLCMenu::PopupMenu( p_intf, false, this );
 }
 
 void MainInterface::popupMenu( const QPoint &p )
 {
-    QVLCMenu::PopupMenu( p_intf, true );
+    QVLCMenu::PopupMenu( p_intf, true, this );
 }
 
 void MainInterface::toggleFSC()
@@ -604,8 +590,9 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
     *p_id = ret;
     if( ret ) /* The videoWidget is available */
     {
-        /* ask videoWidget to show */
-        videoWidget->SetSizing( *pi_width, *pi_height );
+        /* Ask videoWidget to resize correctly, if we are in normal mode */
+        if( !isFullScreen() && !isMaximized() )
+            videoWidget->SetSizing( *pi_width, *pi_height );
 
         /* Consider the video active now */
         showVideo();
@@ -623,7 +610,8 @@ void MainInterface::releaseVideoSlot( void )
 {
     videoWidget->release();
 
-    restoreStackOldWidget();
+    if( stackCentralW->currentWidget() == videoWidget )
+        restoreStackOldWidget();
 
     /* We don't want to have a blank video to popup */
     stackCentralOldWidget = bgWidget;
@@ -638,6 +626,8 @@ int MainInterface::controlVideo( int i_query, va_list args )
     {
         unsigned int i_width  = va_arg( args, unsigned int );
         unsigned int i_height = va_arg( args, unsigned int );
+        if( isFullScreen() || isMaximized() )
+            showNormal();
         emit askVideoToResize( i_width, i_height );
         return VLC_SUCCESS;
     }
@@ -729,11 +719,13 @@ void MainInterface::dockPlaylist( bool p_docked )
     }
     else
     {
+        QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
         playlistWidget->setWindowFlags( Qt::Widget ); // Probably a Qt bug here
         // It would be logical that QStackWidget::addWidget reset the flags...
         stackCentralW->addWidget( playlistWidget );
-        stackCentralW->setCurrentWidget( playlistWidget );
+        showTab( playlistWidget );
     }
+    playlistVisible = true;
 }
 
 /*