]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Fix the activation or not of advanced buttons in fullscreen controller
[vlc] / modules / gui / qt4 / main_interface.cpp
index a7dcbf0c6c9be8822da7b748a185866abfe3e7e3..0ee6864c308b03d84955c1c9fc91552e2b4fed1e 100644 (file)
@@ -81,13 +81,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     /* Variables initialisation */
     // need_components_update = false;
-    bgWidget = NULL;
-    videoWidget = NULL;
-    playlistWidget = NULL;
-    sysTray = NULL;
-    videoIsActive = false;
-    playlistVisible = false;
-    input_name = "";
+    bgWidget             = NULL;
+    videoWidget          = NULL;
+    playlistWidget       = NULL;
+    sysTray              = NULL;
+    videoIsActive        = false;
+    playlistVisible      = false;
+    input_name           = "";
+    fullscreenControls   = NULL;
 
     /* Ask for privacy */
     askForPrivacy();
@@ -109,7 +110,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
 
     /* Set the other interface settings */
-    settings = new QSettings( "vlc", "vlc-qt-interface" );
+    settings = getSettings();
     settings->beginGroup( "MainWindow" );
 
     //TODO: I don't like that code
@@ -222,14 +223,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 
     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
 
-    CONNECT( controls, advancedControlsToggled( bool ),
-             this, doComponentsUpdate() );
-
-    CONNECT( fullscreenControls, advancedControlsToggled( bool ),
-             this, doComponentsUpdate() );
-
     /* Size and placement of interface */
-    QVLCTools::restoreWidgetPosition(settings,this,QSize(350,60));
+    QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
 
 
     /* Playlist */
@@ -255,7 +250,7 @@ MainInterface::~MainInterface()
     msg_Dbg( p_intf, "Destroying the main interface" );
 
     if( playlistWidget )
-        playlistWidget->savingSettings( settings );
+        playlistWidget->savingSettings();
 
     settings->beginGroup( "MainWindow" );
 
@@ -271,7 +266,6 @@ MainInterface::~MainInterface()
         settings->setValue( "backgroundSize", bgWidget->size() );
 
     settings->endGroup();
-    delete settings;
 
     var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
 
@@ -298,10 +292,13 @@ inline void MainInterface::createStatusBar()
     timeLabel = new TimeLabel;
     timeLabel->setText( " --:--/--:-- " );
     timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+    timeLabel->setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
     nameLabel = new QLabel;
     nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
                                       | Qt::TextSelectableByKeyboard );
     speedLabel = new SpeedLabel( p_intf, "1.00x" );
+    speedLabel->setToolTip(
+            qtr( "Current playback speed.\nRight click to adjust" ) );
     speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
 
     /* Styling those labels */
@@ -387,12 +384,18 @@ void MainInterface::handleMainUi( QSettings *settings )
     controls = new ControlsWidget( p_intf, this,
                    settings->value( "adv-controls", false ).toBool(),
                    b_shiny );
+    CONNECT( controls, advancedControlsToggled( bool ),
+             this, doComponentsUpdate() );
 
     /* Create the FULLSCREEN CONTROLS Widget */
-    /* bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); */
-    fullscreenControls = new FullscreenControllerWidget( p_intf, this,
-                   settings->value( "adv-controls", false ).toBool(),
-                   b_shiny );
+    if( config_GetInt( p_intf, "qt-fs-controller" ) )
+    {
+        fullscreenControls = new FullscreenControllerWidget( p_intf, this,
+                settings->value( "adv-controls", false ).toBool(),
+                b_shiny );
+        CONNECT( fullscreenControls, advancedControlsToggled( bool ),
+                this, doComponentsUpdate() );
+    }
 
     /* Add the controls Widget to the main Widget */
     mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom );
@@ -413,18 +416,21 @@ void MainInterface::handleMainUi( QSettings *settings )
     visualSelector->hide();
     #endif
 
-    /* And video Outputs */
-    if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
-        i_visualmode == QT_MINIMAL_MODE )
+    /* Bg Cone */
+    bgWidget = new BackgroundWidget( p_intf );
+    bgWidget->resize(
+            settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
+    bgWidget->updateGeometry();
+    mainLayout->insertWidget( 0, bgWidget );
+    CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
+
+    if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
+        i_visualmode != QT_MINIMAL_MODE )
     {
-        bgWidget = new BackgroundWidget( p_intf );
-        bgWidget->resize(
-             settings->value( "backgroundSize", QSize( 300, 150 ) ).toSize() );
-        bgWidget->updateGeometry();
-        mainLayout->insertWidget( 0, bgWidget );
-        CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() );
+        bgWidget->hide();
     }
 
+    /* And video Outputs */
     if( videoEmbeddedFlag )
     {
         videoWidget = new VideoWidget( p_intf );
@@ -649,7 +655,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
                                    int *pi_y, unsigned int *pi_width,
                                    unsigned int *pi_height )
 {
-    bool bgWasVisible = false;
+    bgWasVisible = false;
 
     /* Request the videoWidget */
     void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
@@ -679,14 +685,14 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
 //        emit askVideoToResize( *pi_width, *pi_height );
         emit askUpdate();
 
-        fullscreenControls->attachVout( p_nvout );
+        if( fullscreenControls ) fullscreenControls->attachVout( p_nvout );
     }
     return ret;
 }
 
 void MainInterface::releaseVideo( vout_thread_t *p_vout, void *p_win )
 {
-    fullscreenControls->detachVout( p_vout );
+    if( fullscreenControls ) fullscreenControls->detachVout( p_vout );
     emit askReleaseVideo( p_win );
 }
 
@@ -695,8 +701,11 @@ void MainInterface::releaseVideoSlot( void *p_win )
     videoWidget->release( p_win );
     videoWidget->hide();
 
-    if( bgWidget )// WRONG
+    if( bgWasVisible )
+    {
+        bgWasVisible = false;
         bgWidget->show();
+    }
 
     adjustSize();
     videoIsActive = false;
@@ -798,6 +807,12 @@ void MainInterface::toggleMinimalView()
 {
     /* HACK for minimalView, see menus.cpp */
     if( !menuBar()->isVisible() ) QVLCMenu::minimalViewAction->toggle();
+    if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
+        i_visualmode != QT_MINIMAL_MODE )
+    {
+        emit askBgWidgetToToggle();
+    }
+
     TOGGLEV( menuBar() );
     TOGGLEV( controls );
     TOGGLEV( statusBar() );
@@ -817,6 +832,7 @@ void MainInterface::doComponentsUpdate()
 void MainInterface::toggleAdvanced()
 {
     controls->toggleAdvanced();
+    fullscreenControls->toggleAdvanced();
 }
 
 /* Get the visibility status of the controls (hidden or not, advanced or not) */
@@ -884,12 +900,17 @@ void MainInterface::setName( QString name )
 void MainInterface::setStatus( int status )
 {
     msg_Dbg( p_intf, "I was here, updating your status" );
+
     /* Forward the status to the controls to toggle Play/Pause */
     controls->setStatus( status );
-    fullscreenControls->setStatus( status );
-
     controls->updateInput();
-    fullscreenControls->updateInput();
+
+    if( fullscreenControls )
+    {
+        fullscreenControls->setStatus( status );
+        fullscreenControls->updateInput();
+    }
+
     speedControl->setEnable( THEMIM->getIM()->hasInput() );
 
     /* And in the systray for the menu */