]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
[Qt] Fix small glitches, issues, because of previous commits.
[vlc] / modules / gui / qt4 / main_interface.cpp
index d21cca070c277efc9830610d344b1acbe0e1886a..0cd62dca11885da08b23b067c98222645c602ecc 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * main_interface.cpp : Main interface
  ****************************************************************************
- * Copyright (C) 2006-2007 the VideoLAN team
+ * Copyright (C) 2006-2008 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
 #include "main_interface.hpp"
 #include "input_manager.hpp"
 #include "util/qvlcframe.hpp"
+#include "util/qvlcapp.hpp"
 #include "util/customwidgets.hpp"
 #include "dialogs_provider.hpp"
 #include "components/interface_widgets.hpp"
+#include "components/controller.hpp"
 #include "components/playlist/playlist.hpp"
 #include "dialogs/extended.hpp"
 #include "dialogs/playlist.hpp"
 #include "menus.hpp"
+#include "recents.hpp"
 
 #include <QMenuBar>
 #include <QCloseEvent>
 #include <QLabel>
 #include <QSlider>
 #include <QWidgetAction>
-#if 0
-#include <QDockWidget>
-#endif
 #include <QToolBar>
 #include <QGroupBox>
 #include <QDate>
-#include <QProgressBar>
 
 #include <assert.h>
 #include <vlc_keys.h>
 #include <vlc_vout.h>
 
-#define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
-#define SET_HEIGHT(i,j) i->widgetSize.setHeight(j)
-#define SET_WH( i,j,k) i->widgetSize.setWidth(j); i->widgetSize.setHeight(k);
-
-#define DS(i) i.width(),i.height()
-
 /* Callback prototypes */
 static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable,
                         vlc_value_t old_val, vlc_value_t new_val, void *param );
@@ -81,13 +74,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,11 +103,13 @@ 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
-    visualSelectorEnabled = settings->value( "visual-selector", false ).toBool();
+    /* Visualisation, not really used yet */
+    visualSelectorEnabled = settings->value( "visual-selector", false).toBool();
+
+    /* Do we want anoying popups or not */
     notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
 
     /**************************
@@ -134,14 +130,17 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     dockPL->hide();
 #endif
 
-    /************
-     * Menu Bar
-     ************/
+    /**************************
+     * Menu Bar and Status Bar
+     **************************/
     QVLCMenu::createMenuBar( this, p_intf, visualSelectorEnabled );
 
     /* StatusBar Creation */
     createStatusBar();
 
+    /* Recents menu updates */
+    CONNECT( RecentsMRL::getInstance( p_intf ), updated(),
+             this, updateRecentsMenu() );
 
     /********************
      * Input Manager    *
@@ -153,10 +152,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      **************************/
     /* Connect the input manager to the GUI elements it manages */
 
-    /* It is also connected to the control->slider, see the ControlsWidget */
-    CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
-             this, setDisplayPosition( float, int, int ) );
-    /* Change the SpeedRate in the Status */
+    /* Change the SpeedRate in the Status Bar */
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
 
     /**
@@ -195,15 +191,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* END CONNECTS ON IM */
 
 
-    /** OnTimeOut **/
-    /* TODO Remove this function, but so far, there is no choice because there
-       is no intf-should-die variable */
-    ON_TIMEOUT( updateOnTimer() );
-    //ON_TIMEOUT( debug() );
-
-    /**
+    /************
      * Callbacks
-     **/
+     ************/
     var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
     var_AddCallback( p_intf, "interaction", InteractCallback, this );
     p_intf->b_interaction = true;
@@ -211,44 +201,42 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
 
     /* Register callback for the intf-popupmenu variable */
-    playlist_t *p_playlist = pl_Yield( p_intf );
-    var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
-    pl_Release( p_intf );
+    var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
+
 
-    /* VideoWidget connect mess to avoid different threads speaking to each other */
-    CONNECT( this, askReleaseVideo( void ),
-             this, releaseVideoSlot( void ) );
+    /* VideoWidget connects to avoid different threads speaking to each other */
+    CONNECT( this, askReleaseVideo( void ),
+             this, releaseVideoSlot( void ) );
     if( videoWidget )
         CONNECT( this, askVideoToResize( unsigned int, unsigned int ),
                  videoWidget, SetSizing( unsigned int, unsigned int ) );
 
     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
 
-    CONNECT( controls, advancedControlsToggled( bool ),
-             this, doComponentsUpdate() );
-
-    CONNECT( fullscreenControls, advancedControlsToggled( bool ),
-             this, doComponentsUpdate() );
-
-    CONNECT( THEMIM->getIM(), inputUnset(),
-            fullscreenControls, unregFullscreenCallback() );
-
-
     /* Size and placement of interface */
-    QVLCTools::restoreWidgetPosition(settings,this,QSize(350,60));
+    settings->beginGroup( "MainWindow" );
+    QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
 
+    bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
+    settings->endGroup();
 
     /* Playlist */
-    if( settings->value( "playlist-visible", 0 ).toInt() ) togglePlaylist();
-    settings->endGroup();
+    if( b_visible ) togglePlaylist();
 
+    /* Final sizing and showing */
+    setMinimumWidth( __MAX( controls->sizeHint().width(),
+                            menuBar()->sizeHint().width() ) );
     show();
 
+    /* And switch to minimal view if needed
+       Must be called after the show() */
     if( i_visualmode == QT_MINIMAL_MODE )
         toggleMinimalView();
 
-    /* Update the geometry TODO: is it useful ?*/
+    /* Update the geometry : It is useful if you switch between
+       qt-display-modes ?*/
     updateGeometry();
+    resize( sizeHint() );
 
     /*****************************************************
      * End everything by creating the Systray Management *
@@ -260,31 +248,33 @@ MainInterface::~MainInterface()
 {
     msg_Dbg( p_intf, "Destroying the main interface" );
 
+    if( videoIsActive ) videoWidget->hide();
+
     if( playlistWidget )
-        playlistWidget->savingSettings( settings );
+    {
+        if( !isDocked() )
+            QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
+
+        delete playlistWidget;
+    }
 
     settings->beginGroup( "MainWindow" );
 
-    // settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) );
+    settings->setValue( "pl-dock-status", (int)i_pl_dock );
     settings->setValue( "playlist-visible", (int)playlistVisible );
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
 
-    if( !videoIsActive )
-        QVLCTools::saveWidgetPosition(settings, this);
-
     if( bgWidget )
         settings->setValue( "backgroundSize", bgWidget->size() );
 
+    QVLCTools::saveWidgetPosition(settings, this);
     settings->endGroup();
-    delete settings;
 
     var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
 
     /* Unregister callback for the intf-popupmenu variable */
-    playlist_t *p_playlist = pl_Yield( p_intf );
-    var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf );
-    pl_Release( p_intf );
+    var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
 
     p_intf->b_interaction = false;
     var_DelCallback( p_intf, "interaction", InteractCallback, this );
@@ -302,14 +292,13 @@ inline void MainInterface::createStatusBar()
      *  Status Bar  *
      ****************/
     /* Widgets Creation*/
-    b_remainingTime = false;
-    timeLabel = new TimeLabel;
-    timeLabel->setText( " --:--/--:-- " );
-    timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
+    timeLabel = new TimeLabel( p_intf );
     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 */
@@ -317,22 +306,16 @@ inline void MainInterface::createStatusBar()
     speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
     nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel);
 
-    pgBar = new QProgressBar;
-    pgBar->hide();
-
     /* and adding those */
     statusBar()->addWidget( nameLabel, 8 );
     statusBar()->addPermanentWidget( speedLabel, 0 );
-    statusBar()->addPermanentWidget( pgBar, 0 );
     statusBar()->addPermanentWidget( timeLabel, 0 );
 
     /* timeLabel behaviour:
        - double clicking opens the goto time dialog
        - right-clicking and clicking just toggle between remaining and
          elapsed time.*/
-    CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
     CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
-    CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
 
     /* Speed Label behaviour:
        - right click gives the vertical speed slider */
@@ -391,19 +374,15 @@ void MainInterface::handleMainUi( QSettings *settings )
     mainLayout->setMargin( 0 );
 
     /* Create the CONTROLS Widget */
-    /* bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); */
-    controls = new ControlsWidget( p_intf, this,
-                   settings->value( "adv-controls", false ).toBool(),
-                   config_GetInt( p_intf, "qt-blingbling" ) );
-
-    /* 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(),
-                   config_GetInt( p_intf, "qt-blingbling" ) );
+    controls = new ControlsWidget( p_intf,
+                   settings->value( "adv-controls", false ).toBool(), this );
+    CONNECT( controls, advancedControlsToggled( bool ),
+             this, doComponentsUpdate() );
+    InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
 
     /* Add the controls Widget to the main Widget */
     mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom );
+    mainLayout->insertWidget( 0, inputC, 0, Qt::AlignBottom );
 
     /* Create the Speed Control Widget */
     speedControl = new SpeedControlWidget( p_intf );
@@ -421,18 +400,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 );
@@ -441,6 +423,16 @@ void MainInterface::handleMainUi( QSettings *settings )
 
     /* Finish the sizing */
     main->updateGeometry();
+
+    getSettings()->endGroup();
+#ifdef WIN32
+    if ( depth() > 8 )
+#endif
+    /* Create the FULLSCREEN CONTROLS Widget */
+    if( config_GetInt( p_intf, "qt-fs-controller" ) )
+    {
+        fullscreenControls = new FullscreenControllerWidget( p_intf );
+    }
 }
 
 inline void MainInterface::askForPrivacy()
@@ -451,7 +443,7 @@ inline void MainInterface::askForPrivacy()
     if( config_GetInt( p_intf, "qt-privacy-ask") )
     {
         QList<ConfigControl *> controls;
-        if( privacyDialog( controls ) == QDialog::Accepted )
+        if( privacyDialog( &controls ) == QDialog::Accepted )
         {
             QList<ConfigControl *>::Iterator i;
             for(  i = controls.begin() ; i != controls.end() ; i++ )
@@ -467,11 +459,11 @@ inline void MainInterface::askForPrivacy()
     }
 }
 
-int MainInterface::privacyDialog( QList<ConfigControl *> controls )
+int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
 {
     QDialog *privacy = new QDialog();
 
-    privacy->setWindowTitle( qtr( "Privacy and Network policies" ) );
+    privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
 
     QGridLayout *gLayout = new QGridLayout( privacy );
 
@@ -480,13 +472,13 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
     QLabel *text = new QLabel( qtr(
         "<p>The <i>VideoLAN Team</i> doesn't like when an application goes "
         "online without authorization.</p>\n "
-        "<p><i>VLC media player</i> can request limited information on "
-        "the Internet, especially to get CD covers and songs metadata or to know "
-        "if updates are available.</p>\n"
+        "<p><i>VLC media player</i> can retreive limited information from "
+        "the Internet in order to get CD covers or to check "
+        "for available updates.</p>\n"
         "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> "
         "information, even anonymously, about your usage.</p>\n"
-        "<p>Therefore please check the following options, the default being "
-        "almost no access on the web.</p>\n") );
+        "<p>Therefore please select from the following options, the default being "
+        "almost no access to the web.</p>\n") );
     text->setWordWrap( true );
     text->setTextFormat( Qt::RichText );
 
@@ -507,7 +499,7 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
     {                                                             \
         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                 p_config, options, false, optionsLayout, line );  \
-        controls.append( control );                               \
+        controls->append( control );                               \
     }
 
 #define CONFIG_GENERIC_NOBOOL( option, type )                     \
@@ -516,17 +508,16 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
     {                                                             \
         control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
                 p_config, options, optionsLayout, line );  \
-        controls.append( control );                               \
+        controls->append( control );                               \
     }
 
     CONFIG_GENERIC( "album-art", IntegerList ); line++;
-    CONFIG_GENERIC_NOBOOL( "fetch-meta", Bool ); line++;
 #ifdef UPDATE_CHECK
     CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
     CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); line++;
 #endif
 
-    QPushButton *ok = new QPushButton( qtr( "Ok" ) );
+    QPushButton *ok = new QPushButton( qtr( "OK" ) );
 
     gLayout->addWidget( ok, 2, 2 );
 
@@ -547,7 +538,7 @@ int MainInterface::privacyDialog( QList<ConfigControl *> controls )
    ask _parent->isFloating()...
    If you think this would be better, please FIXME it...
 */
-#if 0
+
 QSize MainInterface::sizeHint() const
 {
     int nwidth  = controls->sizeHint().width();
@@ -557,67 +548,46 @@ QSize MainInterface::sizeHint() const
                   + statusBar()->size().height()
                   : 0 ;
 
-    msg_Dbg( p_intf, "1 %i %i", nheight, nwidth );
     if( VISIBLE( bgWidget ) )
     {
         nheight += bgWidget->size().height();
         nwidth  = bgWidget->size().width();
-        msg_Dbg( p_intf, "1b %i %i", nheight, nwidth );
     }
-    else if( videoIsActive )
+    else if( videoIsActive && videoWidget->isVisible() )
     {
-        nheight += videoWidget->size().height();
-        nwidth  = videoWidget->size().width();
-        msg_Dbg( p_intf, "2 %i %i", nheight, nwidth );
+        nheight += videoWidget->sizeHint().height();
+        nwidth  = videoWidget->sizeHint().width();
     }
-/*    if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget()  )
+#if 0
+    if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget()  )
     {
         nheight += dockPL->size().height();
         nwidth = __MAX( nwidth, dockPL->size().width() );
-        msg_Dbg( p_intf, "3 %i %i", nheight, nwidth );
-    }*/
-    msg_Dbg( p_intf, "4 %i %i", nheight, nwidth );
-    return QSize( nwidth, nheight );
-}
-#endif
-#if 0
-/* FIXME This is dead code and need to be removed AT THE END */
-void MainInterface::resizeEvent( QResizeEvent *e )
-{
-    if( videoWidget )
-        videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
-    if( videoWidget && videoIsActive && videoWidget->widgetSize.height() > 1 )
-    {
-        SET_WH( videoWidget, e->size().width() - addSize.width(),
-                             e->size().height()  - addSize.height() );
-        videoWidget->updateGeometry();
+        msg_Warn( p_intf, "3 %i %i", nheight, nwidth );
     }
-    if( VISIBLE( playlistWidget ) )
-    {
-//        SET_WH( playlistWidget , e->size().width() - addSize.width(),
-              //                   e->size().height() - addSize.height() );
-        playlistWidget->updateGeometry();
-    }
-}
 #endif
+    return QSize( nwidth, nheight );
+}
 
-void MainInterface::requestLayoutUpdate()
+void MainInterface::toggleFSC()
 {
-    emit askUpdate();
+   if( !fullscreenControls ) return;
+
+   IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 );
+   QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) );
 }
 
-//FIXME remove me at the end...
 void MainInterface::debug()
 {
+#ifndef NDEBUG
     msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
     msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
     if( videoWidget && videoWidget->isVisible() )
     {
-//    sleep( 10 );
-    msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
-    msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
+        msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
+        msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
     }
-    adjustSize();
+#endif
 }
 
 /****************************************************************************
@@ -632,6 +602,9 @@ void MainInterface::showSpeedMenu( QPoint pos )
 /****************************************************************************
  * 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:
@@ -639,17 +612,13 @@ public:
       QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop)
     {}
 
-    bool OnTop() const
-    {
-        return onTop;
-    }
+    bool OnTop() const { return onTop; }
 
 private:
     bool onTop;
 };
 
 /**
- * README
  * README
  * Thou shall not call/resize/hide widgets from on another thread.
  * This is wrong, and this is TEH reason to emit signals on those Video Functions
@@ -658,8 +627,6 @@ 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;
-
     /* Request the videoWidget */
     void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
     if( ret ) /* The videoWidget is available */
@@ -670,51 +637,45 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
             bgWasVisible = true;
             emit askBgWidgetToToggle();
         }
-#if 0
-        if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
-        {
-            videoWidget->widgetSize = QSize( *pi_width, *pi_height );
-        }
-        else /* Background widget available, use its size */
-        {
-            /* Ok, our visualizations are bad, so don't do this for the moment
-             * use the requested size anyway */
-            // videoWidget->widgetSize = bgWidget->widgeTSize;
-            videoWidget->widgetSize = QSize( *pi_width, *pi_height );
-        }
-#endif
+        else
+            bgWasVisible = false;
+
+        /* Consider the video active now */
         videoIsActive = true;
 
-//        emit askVideoToResize( *pi_width, *pi_height );
         emit askUpdate();
 
-        fullscreenControls->regFullscreenCallback( p_nvout );
+        if( fullscreenControls ) fullscreenControls->attachVout( p_nvout );
     }
     return ret;
 }
 
-void MainInterface::requestNotEmbeddedVideo( vout_thread_t *p_nvout )
+/* Call from the WindowClose function */
+void MainInterface::releaseVideo( void )
 {
-    fullscreenControls->regFullscreenCallback( p_nvout );
+    if( fullscreenControls ) fullscreenControls->detachVout();
+    emit askReleaseVideo( );
 }
 
-void MainInterface::releaseVideo( void *p_win )
+/* Function that is CONNECTED to the previous emit */
+void MainInterface::releaseVideoSlot( void )
 {
-    emit askReleaseVideo( p_win );
-}
+    videoWidget->release( );
 
-void MainInterface::releaseVideoSlot( void *p_win )
-{
-    videoWidget->release( p_win );
-    videoWidget->hide();
-
-    if( bgWidget )// WRONG
+    if( bgWasVisible )
+    {
+        /* Reset the bg state */
+        bgWasVisible = false;
         bgWidget->show();
+    }
 
-    adjustSize();
     videoIsActive = false;
+
+    /* Try to resize, except when you are in Fullscreen mode */
+    if( !isFullScreen() ) doComponentsUpdate();
 }
 
+/* Call from WindowControl function */
 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
 {
     int i_ret = VLC_SUCCESS;
@@ -758,57 +719,69 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
  **/
 void MainInterface::togglePlaylist()
 {
-    THEDP->playlistDialog();
-#if 0
     /* CREATION
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf, settings, dockPL );
+        playlistWidget = new PlaylistWidget( p_intf );
 
-        /* Add it to the parent DockWidget */
-        dockPL->setWidget( playlistWidget );
+        i_pl_dock = PL_UNDOCKED;
+/*        i_pl_dock = (pl_dock_e)getSettings()
+                         ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
 
-        /* Add the dock to the main Interface */
-        addDockWidget( Qt::BottomDockWidgetArea, dockPL );
+        if( i_pl_dock == PL_UNDOCKED )
+        {
+            playlistWidget->setWindowFlags( Qt::Window );
 
-        /* Make the playlist floating is requested. Default is not. */
-        settings->beginGroup( "MainWindow" );
-        if( settings->value( "playlist-floats", 1 ).toInt() )
+            /* This will restore the geometry but will not work for position,
+               because of parenting */
+            QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
+                    playlistWidget, QSize( 600, 300 ) );
+        }
+        else
         {
-            msg_Dbg( p_intf, "we don't want the playlist inside");
-            dockPL->setFloating( true );
+            mainLayout->insertWidget( 4, playlistWidget );
         }
-        settings->endGroup();
-        settings->beginGroup( "playlist" );
-        dockPL->move( settings->value( "pos", QPoint( 0,0 ) ).toPoint() );
-        QSize newSize = settings->value( "size", QSize( 400, 300 ) ).toSize();
-        if( newSize.isValid() )
-            dockPL->resize( newSize );
-        settings->endGroup();
-
-        dockPL->show();
         playlistVisible = true;
+
+        playlistWidget->show();
     }
     else
     {
     /* toggle the visibility of the playlist */
-       TOGGLEV( dockPL );
-       resize( sizeHint() );
+       TOGGLEV( playlistWidget );
        playlistVisible = !playlistVisible;
+       //doComponentsUpdate(); //resize( sizeHint() );
     }
-    #endif
 }
 
 /* Function called from the menu to undock the playlist */
 void MainInterface::undockPlaylist()
 {
 //    dockPL->setFloating( true );
-    adjustSize();
+//    adjustSize();
+}
+
+void MainInterface::dockPlaylist( pl_dock_e i_pos )
+{
 }
 
 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 )
+    { /* NORMAL MODE then */
+        if( !videoWidget || videoWidget->isHidden() ) emit askBgWidgetToToggle();
+        else
+        {
+            /* If video is visible, then toggle the status of bgWidget */
+            bgWasVisible = !bgWasVisible;
+        }
+    }
+
     TOGGLEV( menuBar() );
     TOGGLEV( controls );
     TOGGLEV( statusBar() );
@@ -817,17 +790,29 @@ void MainInterface::toggleMinimalView()
 
 /* Video widget cannot do this synchronously as it runs in another thread */
 /* Well, could it, actually ? Probably dangerous ... */
+
+/* This function is called:
+   - toggling of minimal View
+   - through askUpdate() by Vout thread request video and resize video (zoom)
+   - Advanced buttons toggled
+ */
 void MainInterface::doComponentsUpdate()
 {
     msg_Dbg( p_intf, "Updating the geometry" );
-//    resize( sizeHint() );
+    /* Here we resize to sizeHint() and not adjustsize because we want
+       the videoWidget to be exactly the correctSize */
+    resize( sizeHint() );
+    //    adjustSize()  ;
+#ifndef NDEBUG
     debug();
+#endif
 }
 
 /* toggling advanced controls buttons */
 void MainInterface::toggleAdvanced()
 {
     controls->toggleAdvanced();
+//    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
 }
 
 /* Get the visibility status of the controls (hidden or not, advanced or not) */
@@ -862,27 +847,6 @@ void MainInterface::visual()
 /************************************************************************
  * Other stuff
  ************************************************************************/
-void MainInterface::setDisplayPosition( float pos, int time, int length )
-{
-    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
-    secstotimestr( psz_length, length );
-    secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
-                                                           : time );
-
-    QString timestr;
-    timestr.sprintf( "%s/%s", psz_time,
-                            ( !length && time ) ? "--:--" : psz_length );
-
-    /* Add a minus to remaining time*/
-    if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );
-    else timeLabel->setText( " "+timestr+" " );
-}
-
-void MainInterface::toggleTimeDisplay()
-{
-    b_remainingTime = !b_remainingTime;
-}
-
 void MainInterface::setName( QString name )
 {
     input_name = name; /* store it for the QSystray use */
@@ -894,13 +858,8 @@ 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 );
+    msg_Dbg( p_intf, "Updating the stream status: %i", status );
 
-    controls->updateInput();
-    fullscreenControls->updateInput();
     speedControl->setEnable( THEMIM->getIM()->hasInput() );
 
     /* And in the systray for the menu */
@@ -918,16 +877,6 @@ void MainInterface::setRate( int rate )
     speedControl->updateControls( rate );
 }
 
-void MainInterface::updateOnTimer()
-{
-    /* No event for dying */
-    if( intf_ShouldDie( p_intf ) )
-    {
-        QApplication::closeAllWindows();
-        QApplication::quit();
-    }
-}
-
 /*****************************************************************************
  * Systray Icon and Systray Menu
  *****************************************************************************/
@@ -978,12 +927,15 @@ void MainInterface::toggleUpdateSystrayMenu()
         /* Visible */
 #ifdef WIN32
         /* check if any visible window is above vlc in the z-order,
-         * but ignore the ones always on top */
+         * but ignore the ones always on top
+         * and the ones which can't be activated */
         WINDOWINFO wi;
         HWND hwnd;
         wi.cbSize = sizeof( WINDOWINFO );
         for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );
-                hwnd && !IsWindowVisible( hwnd );
+                hwnd && ( !IsWindowVisible( hwnd ) ||
+                    ( GetWindowInfo( hwnd, &wi ) &&
+                      (wi.dwExStyle&WS_EX_NOACTIVATE) ) );
                 hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );
         if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||
                 (wi.dwExStyle&WS_EX_TOPMOST) )
@@ -1070,6 +1022,11 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
  * D&D Events
  ************************************************************************/
 void MainInterface::dropEvent(QDropEvent *event)
+{
+    dropEventPlay( event, true );
+}
+
+void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
 {
      const QMimeData *mimeData = event->mimeData();
 
@@ -1079,7 +1036,8 @@ void MainInterface::dropEvent(QDropEvent *event)
         if( THEMIM->getIM()->hasInput() )
         {
             if( input_AddSubtitles( THEMIM->getInput(),
-                                    qtu( mimeData->urls()[0].toString() ),
+                                    qtu( toNativeSeparators(
+                                         mimeData->urls()[0].toLocalFile() ) ),
                                     true ) )
             {
                 event->acceptProposedAction();
@@ -1087,15 +1045,17 @@ void MainInterface::dropEvent(QDropEvent *event)
             }
         }
      }
-     bool first = true;
+     bool first = b_play;
      foreach( QUrl url, mimeData->urls() )
      {
-        QString s = url.toLocalFile();
+        QString s = toNativeSeparators( url.toLocalFile() );
+
         if( s.length() > 0 ) {
             playlist_Add( THEPL, qtu(s), NULL,
-                          PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
+                          PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
                           PLAYLIST_END, true, false );
             first = false;
+            RecentsMRL::getInstance( p_intf )->addRecent( s );
         }
      }
      event->acceptProposedAction();
@@ -1129,7 +1089,7 @@ void MainInterface::customEvent( QEvent *event )
     }
 #endif
     /*else */
-    if ( event->type() == SetVideoOnTopEvent_Type )
+    if ( event->type() == (int)SetVideoOnTopEvent_Type )
     {
         SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
         if( p_event->OnTop() )
@@ -1142,7 +1102,7 @@ void MainInterface::customEvent( QEvent *event )
 
 void MainInterface::keyPressEvent( QKeyEvent *e )
 {
-    if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() & Qt::Key_H )
+    if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() == Qt::Key_H )
           && menuBar()->isHidden() )
     {
         toggleMinimalView();
@@ -1175,7 +1135,10 @@ void MainInterface::closeEvent( QCloseEvent *e )
 void MainInterface::toggleFullScreen( void )
 {
     if( isFullScreen() )
+    {
         showNormal();
+        emit askUpdate(); // Needed if video was launched after the F11
+    }
     else
         showFullScreen();
 }
@@ -1220,7 +1183,17 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
                        vlc_value_t old_val, vlc_value_t new_val, void *param )
 {
     intf_thread_t *p_intf = (intf_thread_t *)param;
-    p_intf->p_sys->p_mi->requestLayoutUpdate();
+    p_intf->p_sys->p_mi->toggleFSC();
 
-    return VLC_SUCCESS;
+    /* Show event */
+     return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * updateRecentsMenu: event called by RecentsMRL
+ *****************************************************************************/
+
+void MainInterface::updateRecentsMenu()
+{
+    QVLCMenu::updateRecents( p_intf );
 }