]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Win32: fix Win7's taskbar buttons
[vlc] / modules / gui / qt4 / main_interface.cpp
index 156a881a903d32b8df5be068e29835f686c5d237..02f5ee8c68fccf6763753f5ae3475e8a90cc7379 100644 (file)
@@ -40,6 +40,7 @@
 #include "components/controller.hpp"
 #include "components/playlist/playlist.hpp"
 #include "dialogs/external.hpp"
+#include "dialogs/firstrun.hpp"
 
 #include "menus.hpp"
 #include "recents.hpp"
@@ -57,6 +58,7 @@
 #include <QLabel>
 #include <QGroupBox>
 #include <QPushButton>
+#include <QStackedWidget>
 
 #ifdef WIN32
  #include <vlc_windows_interfaces.h>
@@ -67,8 +69,9 @@
 
 #include <vlc_keys.h> /* Wheel event */
 #include <vlc_vout_window.h>
-#include <vlc_vout.h>
+#include <vlc_vout_display.h>
 
+// #define DEBUG_INTF
 /* 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 );
@@ -82,21 +85,22 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     bgWidget             = NULL;
     videoWidget          = NULL;
     playlistWidget       = NULL;
+#ifndef HAVE_MAEMO
     sysTray              = NULL;
-    videoIsActive        = false;
-    playlistVisible      = false;
-    input_name           = "";
+#endif
     fullscreenControls   = NULL;
     cryptedLabel         = NULL;
     controls             = NULL;
     inputC               = NULL;
-    b_shouldHide         = false;
 
-    bgWasVisible         = false;
+    b_hideAfterCreation  = false;
+    playlistVisible      = false; // FIXME remove
+    input_name           = "";
+
     i_bg_height          = 0;
 
-    /* Ask for privacy */
-    askForPrivacy();
+    /* Ask for Privacy */
+    FirstRun::CheckAndRun( this, p_intf );
 
     /**
      *  Configuration and settings
@@ -118,6 +122,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* Are we in the enhanced always-video mode or not ? */
     i_visualmode = config_GetInt( p_intf, "qt-display-mode" );
 
+    /* Do we want anoying popups or not */
+    notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
+
     /* Set the other interface settings */
     settings = getSettings();
     settings->beginGroup( "MainWindow" );
@@ -131,8 +138,6 @@ 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();
 
-    /* Do we want anoying popups or not */
-    notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" );
 
     /**************
      * Status Bar *
@@ -152,64 +157,56 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
              this, destroyPopupMenu() );
 
-#if 0
-    /* Create a Dock to get the playlist */
-    dockPL = new QDockWidget( qtr( "Playlist" ), this );
-    dockPL->setSizePolicy( QSizePolicy::Preferred,
-                           QSizePolicy::Expanding );
-    dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures );
-    dockPL->setAllowedAreas( Qt::LeftDockWidgetArea
-                           | Qt::RightDockWidgetArea
-                           | Qt::BottomDockWidgetArea );
-    dockPL->hide();
-#endif
+    /*********************************
+     * Create the Systray Management *
+     *********************************/
+    initSystray();
 
     /********************
      * Input Manager    *
      ********************/
     MainInputManager::getInstance( p_intf );
 
-    /*********************************
-     * Create the Systray Management *
-     *********************************/
-    initSystray();
-
-    /**************************
-     * Various CONNECTs on IM *
-     **************************/
-    /* Connect the input manager to the GUI elements it manages */
+#ifdef WIN32
+    taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated");
+#endif
 
+    /************************************************************
+     * Connect the input manager to the GUI elements it manages *
+     ************************************************************/
     /**
      * Connects on nameChanged()
-     * Those connects are not merged because different options can trigger
-     * them down.
-     */
-    /* Naming in the controller statusbar */
+     * Those connects are different because options can impeach them to trigger.
+     **/
+    /* Main Interface statusbar */
     CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
              this, setName( const QString& ) );
-    /* and in the systray */
+    /* and systray */
+#ifndef HAVE_MAEMO
     if( sysTray )
     {
-        CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this,
-                 updateSystrayTooltipName( const QString& ) );
+        CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
+                 this, updateSystrayTooltipName( const QString& ) );
     }
-    /* and in the title of the controller */
+#endif
+    /* and title of the Main Interface*/
     if( config_GetInt( p_intf, "qt-name-in-title" ) )
     {
-        CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this,
-             setVLCWindowsTitle( const QString& ) );
+        CONNECT( THEMIM->getIM(), nameChanged( const QString& ),
+                 this, setVLCWindowsTitle( const QString& ) );
     }
 
     /**
      * CONNECTS on PLAY_STATUS
      **/
     /* Status on the systray */
+#ifndef HAVE_MAEMO
     if( sysTray )
     {
         CONNECT( THEMIM->getIM(), statusChanged( int ),
                  this, updateSystrayTooltipStatus( int ) );
     }
-
+#endif
 
     /* END CONNECTS ON IM */
 
@@ -243,7 +240,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
     CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
 
-    /* Size and placement of interface */
+        /* Enable the popup menu in the MI */
+    setContextMenuPolicy( Qt::CustomContextMenu );
+    CONNECT( this, customContextMenuRequested( const QPoint& ),
+             this, popupMenu( const QPoint& ) );
+
+    /** END of CONNECTS**/
+
+
+    /**** FINAL SIZING and placement of interface */
     settings->beginGroup( "MainWindow" );
     QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
 
@@ -261,115 +266,28 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
        }
     }
 
-    bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
-    settings->endGroup();
-
+    msg_Dbg( p_intf, "%i", stackCentralOldState );
     /* Playlist */
-    if( b_visible ) togglePlaylist();
-
-    /* Enable the popup menu in the MI */
-    setContextMenuPolicy( Qt::CustomContextMenu );
-    CONNECT( this, customContextMenuRequested( const QPoint& ),
-             this, popupMenu( const QPoint& ) );
+    if( settings->value( "playlist-visible", 0 ).toInt() )
+        togglePlaylist();
+    settings->endGroup();
 
     /* Final sizing and showing */
-    setMinimumWidth( __MAX( controls->sizeHint().width(),
-                            menuBar()->sizeHint().width() ) );
-    setVisible( !b_shouldHide );
+    setVisible( !b_hideAfterCreation );
+    //setMinimumSize( QSize( 0, 0 ) );
+    //    setMinimumWidth( __MAX( controls->sizeHint().width(),
+    //                          menuBar()->sizeHint().width() ) );
 
+    debug();
     /* And switch to minimal view if needed
        Must be called after the show() */
     if( i_visualmode == QT_MINIMAL_MODE )
         toggleMinimalView( true );
 
     /* Update the geometry : It is useful if you switch between
-       qt-display-modes ?*/
+       qt-display-modes */
     updateGeometry();
     resize( sizeHint() );
-
-#ifdef WIN32
-    /*Here is the code for the taskbar thumb buttons
-    FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
-    FIXME:the play button's picture doesn't changed to pause when clicked
-    */
-    OSVERSIONINFO winVer;
-    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-    if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 && winVer.dwMajorVersion > 0 )
-    {
-        if(himl = ImageList_Create( 15, //cx
-                                    18, //cy
-                                    ILC_COLOR,//flags
-                                    4,//initial nb of images
-                                    0//nb of images that can be added
-                                    ))
-        {
-            QPixmap img   = QPixmap(":/toolbar/previous_b");
-            QPixmap img2  = QPixmap(":/toolbar/pause_b");
-            QPixmap img3  = QPixmap(":/toolbar/play_b");
-            QPixmap img4  = QPixmap(":/toolbar/next_b");
-            QBitmap mask  = img.createMaskFromColor(Qt::transparent);
-            QBitmap mask2 = img2.createMaskFromColor(Qt::transparent);
-            QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
-            QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
-
-            if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
-            if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
-            if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
-            if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
-                msg_Err( p_intf, "ImageList_Add failed" );
-        }
-
-        CoInitialize( 0 );
-
-        if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
-                    NULL, CLSCTX_INPROC_SERVER,
-                    &IID_ITaskbarList3,
-                    (void **)&p_taskbl) )
-        {
-            p_taskbl->vt->HrInit(p_taskbl);
-
-            int msg_value = RegisterWindowMessage("TaskbarButtonCreated");
-            //msg_Info( p_intf, "msg value: %04x", msg_value );
-
-            // Define an array of two buttons. These buttons provide images through an 
-            // image list and also provide tooltips.
-            DWORD dwMask = THB_BITMAP | THB_FLAGS;
-
-            THUMBBUTTON thbButtons[2];
-            thbButtons[0].dwMask = dwMask;
-            thbButtons[0].iId = 0;
-            thbButtons[0].iBitmap = 0;
-            thbButtons[0].dwFlags = THBF_HIDDEN;
-
-            thbButtons[1].dwMask = dwMask;
-            thbButtons[1].iId = 1;
-            thbButtons[1].iBitmap = 2;
-            thbButtons[1].dwFlags = THBF_HIDDEN;
-
-            thbButtons[2].dwMask = dwMask;
-            thbButtons[2].iId = 2;
-            thbButtons[2].iBitmap = 3;
-            thbButtons[2].dwFlags = THBF_HIDDEN;
-
-            HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, GetForegroundWindow(), himl );
-            if(S_OK != hr)
-                msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
-            if(S_OK != p_taskbl->vt->ThumbBarAddButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons))
-                msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", GetLastError() );
-
-            CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
-        }
-    }
-    else
-    {
-        himl = NULL;
-        p_taskbl = NULL;
-    }
-#endif
-
 }
 
 MainInterface::~MainInterface()
@@ -377,7 +295,8 @@ MainInterface::~MainInterface()
     msg_Dbg( p_intf, "Destroying the main interface" );
 
     /* Unsure we hide the videoWidget before destroying it */
-    if( videoIsActive ) videoWidget->hide();
+    if( stackCentralOldState == VIDEO_TAB )
+        showBg();
 
     /* Save playlist state */
     if( playlistWidget )
@@ -419,7 +338,6 @@ MainInterface::~MainInterface()
     QVLCTools::saveWidgetPosition(settings, this);
     settings->endGroup();
 
-
     /* Unregister callbacks */
     var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
     var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf );
@@ -432,20 +350,22 @@ MainInterface::~MainInterface()
  *****************************/
 void MainInterface::recreateToolbars()
 {
-    msg_Dbg( p_intf, "Recreating the toolbars" );
+    //msg_Dbg( p_intf, "Recreating the toolbars" );
     settings->beginGroup( "MainWindow" );
     delete controls;
     delete inputC;
+
     controls = new ControlsWidget( p_intf, false, this ); /* FIXME */
     CONNECT( controls, advancedControlsToggled( bool ),
              this, doComponentsUpdate() );
     CONNECT( controls, sizeChanged(),
              this, doComponentsUpdate() );
+
     inputC = new InputControlsWidget( p_intf, this );
 
-    mainLayout->addWidget( inputC, 2, 0, 1, -1, Qt::AlignBottom );
-    mainLayout->addWidget( controls, settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
-                              0, 1, -1, Qt::AlignBottom );
+    mainLayout->insertWidget( 2, inputC );
+    mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
+                              controls );
     settings->endGroup();
 }
 
@@ -454,37 +374,31 @@ void MainInterface::createMainWidget( QSettings *settings )
     /* Create the main Widget and the mainLayout */
     QWidget *main = new QWidget;
     setCentralWidget( main );
-    mainLayout = new QGridLayout( main );
+    mainLayout = new QVBoxLayout( main );
 
     /* Margins, spacing */
     main->setContentsMargins( 0, 0, 0, 0 );
-    main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
-    mainLayout->setSpacing( 0 );
-    mainLayout->setMargin( 0 );
+    mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 );
 
-    /* Visualisation */
-    /* Disabled for now, they SUCK */
-    #if 0
-    visualSelector = new VisualSelector( p_intf );
-    mainLayout->insertWidget( 0, visualSelector );
-    visualSelector->hide();
-    #endif
+    /* */
+    stackCentralW = new QStackedWidget( main );
 
     /* Bg Cone */
     bgWidget = new BackgroundWidget( p_intf );
     bgWidget->resize(
             settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() );
     bgWidget->updateGeometry();
+    stackCentralW->insertWidget( BACKG_TAB, bgWidget );
 
-    if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
-        i_visualmode != QT_MINIMAL_MODE )
-    {
-        bgWidget->hide();
-    }
 
     /* And video Outputs */
     if( videoEmbeddedFlag )
+    {
         videoWidget = new VideoWidget( p_intf );
+        stackCentralW->insertWidget( VIDEO_TAB, videoWidget );
+    }
+    mainLayout->insertWidget( 1, stackCentralW, 100 );
+
 
     /* Create the CONTROLS Widget */
     controls = new ControlsWidget( p_intf,
@@ -495,17 +409,31 @@ void MainInterface::createMainWidget( QSettings *settings )
              this, doComponentsUpdate() );
     inputC = new InputControlsWidget( p_intf, this );
 
-
-    /* Add the controls Widget to the main Widget */
-    if( videoWidget ){
-        mainLayout->addWidget( videoWidget, 0, 0, 1, -1 );
-        mainLayout->setRowStretch( 0, 10 );
+    if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
+        i_visualmode != QT_MINIMAL_MODE )
+    {
+        hideStackWidget();
+        stackCentralOldState = HIDDEN_TAB;
+    }
+    else
+    {
+        showTab( BACKG_TAB );
+        stackCentralOldState = BACKG_TAB;
     }
-    mainLayout->addWidget( bgWidget, 1, 0, 1, -1 );
+
+
     //mainLayout->setRowStretch( 1, 10 );
-    mainLayout->addWidget( inputC, 2, 0, 1, -1, Qt::AlignBottom );
-    mainLayout->addWidget( controls, settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
-                           0, 1, -1, Qt::AlignBottom );
+    mainLayout->insertWidget( 2, inputC );
+    mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
+                              controls );
+
+    /* Visualisation */
+    /* Disabled for now, they SUCK */
+    #if 0
+    visualSelector = new VisualSelector( p_intf );
+    mainLayout->insertWidget( 0, visualSelector );
+    visualSelector->hide();
+    #endif
 
     /* Finish the sizing */
     main->updateGeometry();
@@ -523,6 +451,28 @@ void MainInterface::createMainWidget( QSettings *settings )
     }
 }
 
+inline void MainInterface::initSystray()
+{
+#ifndef HAVE_MAEMO
+    bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
+    bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
+
+    if( config_GetInt( p_intf, "qt-start-minimized") > 0 )
+    {
+        if( b_systrayAvailable )
+        {
+            b_systrayWanted = true;
+            b_hideAfterCreation = true;
+        }
+        else
+            msg_Err( p_intf, "cannot start minimized without system tray bar" );
+    }
+
+    if( b_systrayAvailable && b_systrayWanted )
+        createSystray();
+#endif
+}
+
 inline void MainInterface::createStatusBar()
 {
     /****************
@@ -557,116 +507,125 @@ inline void MainInterface::createStatusBar()
              this, showCryptedLabel( bool ) );
 }
 
-inline void MainInterface::initSystray()
+#ifdef WIN32
+void MainInterface::createTaskBarButtons()
 {
-    bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
-    bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
-
-    if( config_GetInt( p_intf, "qt-start-minimized") > 0 )
+    taskbar_wmsg = WM_NULL;
+    /*Here is the code for the taskbar thumb buttons
+    FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
+    FIXME:the play button's picture doesn't changed to pause when clicked
+    */
+    OSVERSIONINFO winVer;
+    winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 )
     {
-        if( b_systrayAvailable )
+        if(himl = ImageList_Create( 15, //cx
+                                    18, //cy
+                                    ILC_COLOR,//flags
+                                    4,//initial nb of images
+                                    0//nb of images that can be added
+                                    ))
         {
-            b_systrayWanted = true;
-            b_shouldHide = true;
+            QPixmap img   = QPixmap(":/toolbar/previous_b");
+            QPixmap img2  = QPixmap(":/toolbar/pause_b");
+            QPixmap img3  = QPixmap(":/toolbar/play_b");
+            QPixmap img4  = QPixmap(":/toolbar/next_b");
+            QBitmap mask  = img.createMaskFromColor(Qt::transparent);
+            QBitmap mask2 = img2.createMaskFromColor(Qt::transparent);
+            QBitmap mask3 = img3.createMaskFromColor(Qt::transparent);
+            QBitmap mask4 = img4.createMaskFromColor(Qt::transparent);
+
+            if(-1 == ImageList_Add(himl, img.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask.toWinHBITMAP()))
+                msg_Err( p_intf, "ImageList_Add failed" );
+            if(-1 == ImageList_Add(himl, img2.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask2.toWinHBITMAP()))
+                msg_Err( p_intf, "ImageList_Add failed" );
+            if(-1 == ImageList_Add(himl, img3.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask3.toWinHBITMAP()))
+                msg_Err( p_intf, "ImageList_Add failed" );
+            if(-1 == ImageList_Add(himl, img4.toWinHBITMAP(QPixmap::PremultipliedAlpha),mask4.toWinHBITMAP()))
+                msg_Err( p_intf, "ImageList_Add failed" );
         }
-        else
-            msg_Err( p_intf, "cannot start minimized without system tray bar" );
-    }
 
-    if( b_systrayAvailable && b_systrayWanted )
-            createSystray();
-}
+        CoInitialize( 0 );
 
-inline void MainInterface::askForPrivacy()
-{
-    /**
-     * Ask for the network policy on FIRST STARTUP
-     **/
-    if( config_GetInt( p_intf, "qt-privacy-ask") )
-    {
-        QList<ConfigControl *> controls;
-        if( privacyDialog( &controls ) == QDialog::Accepted )
+        if( S_OK == CoCreateInstance( &clsid_ITaskbarList,
+                    NULL, CLSCTX_INPROC_SERVER,
+                    &IID_ITaskbarList3,
+                    (void **)&p_taskbl) )
         {
-            QList<ConfigControl *>::Iterator i;
-            for(  i = controls.begin() ; i != controls.end() ; i++ )
+            p_taskbl->vt->HrInit(p_taskbl);
+
+            // Define an array of two buttons. These buttons provide images through an
+            // image list and also provide tooltips.
+            DWORD dwMask = THB_BITMAP | THB_FLAGS;
+
+            THUMBBUTTON thbButtons[3];
+            thbButtons[0].dwMask = dwMask;
+            thbButtons[0].iId = 0;
+            thbButtons[0].iBitmap = 0;
+            thbButtons[0].dwFlags = THBF_HIDDEN;
+
+            thbButtons[1].dwMask = dwMask;
+            thbButtons[1].iId = 1;
+            thbButtons[1].iBitmap = 2;
+            thbButtons[1].dwFlags = THBF_HIDDEN;
+
+            thbButtons[2].dwMask = dwMask;
+            thbButtons[2].iId = 2;
+            thbButtons[2].iBitmap = 3;
+            thbButtons[2].dwFlags = THBF_HIDDEN;
+
+            HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
+            if(S_OK != hr)
+                msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
+            else
             {
-                ConfigControl *c = qobject_cast<ConfigControl *>(*i);
-                c->doApply( p_intf );
+                hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
+                if(S_OK != hr)
+                    msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr );
             }
-
-            config_PutInt( p_intf,  "qt-privacy-ask" , 0 );
-            /* We have to save here because the user may not launch Prefs */
-            config_SaveConfigFile( p_intf, NULL );
+            CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
+            CONNECT( this, playPauseSignal(), THEMIM, togglePlayPause() );
+            CONNECT( this, prevSignal(), THEMIM, prev() );
+            CONNECT( this, nextSignal(), THEMIM, next() );
         }
     }
+    else
+    {
+        himl = NULL;
+        p_taskbl = NULL;
+    }
 }
 
-int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
+bool MainInterface::winEvent ( MSG * msg, long * result )
 {
-    QDialog *privacy = new QDialog( this );
-
-    privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) );
-    privacy->setWindowRole( "vlc-privacy" );
-
-    QGridLayout *gLayout = new QGridLayout( privacy );
-
-    QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) );
-    QGridLayout *blablaLayout = new QGridLayout( blabla );
-    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 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 select from the following options, the default being "
-        "almost no access to the web.</p>\n") );
-    text->setWordWrap( true );
-    text->setTextFormat( Qt::RichText );
-
-    blablaLayout->addWidget( text, 0, 0 ) ;
-
-    QGroupBox *options = new QGroupBox;
-    QGridLayout *optionsLayout = new QGridLayout( options );
-
-    gLayout->addWidget( blabla, 0, 0, 1, 3 );
-    gLayout->addWidget( options, 1, 0, 1, 3 );
-    module_config_t *p_config;
-    ConfigControl *control;
-    int line = 0;
-
-#define CONFIG_GENERIC( option, type )                            \
-    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
-    if( p_config )                                                \
-    {                                                             \
-        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
-                p_config, options, false, optionsLayout, line );  \
-        controls->append( control );                               \
+    if (msg->message == taskbar_wmsg)
+    {
+        //We received the taskbarbuttoncreated, now we can really create th buttons
+        createTaskBarButtons();
     }
-
-#define CONFIG_GENERIC_NOBOOL( option, type )                     \
-    p_config =  config_FindConfig( VLC_OBJECT(p_intf), option );  \
-    if( p_config )                                                \
-    {                                                             \
-        control =  new type ## ConfigControl( VLC_OBJECT(p_intf), \
-                p_config, options, optionsLayout, line );  \
-        controls->append( control );                               \
+    switch( msg->message )
+    {
+        case WM_COMMAND:
+            if (HIWORD(msg->wParam) == THBN_CLICKED)
+            {
+                switch(LOWORD(msg->wParam))
+                {
+                    case 0:
+                        emit prevSignal();
+                        break;
+                    case 1:
+                        emit playPauseSignal();
+                        break;
+                    case 2:
+                        emit nextSignal();
+                        break;
+                }
+            }
+            break;
     }
-
-    CONFIG_GENERIC( "album-art", IntegerList ); line++;
-#ifdef UPDATE_CHECK
-    CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++;
-#endif
-
-    QPushButton *ok = new QPushButton( qtr( "OK" ) );
-
-    gLayout->addWidget( ok, 2, 2 );
-
-    CONNECT( ok, clicked(), privacy, accept() );
-    return privacy->exec();
+    return false;
 }
-
+#endif
 
 /**********************************************************************
  * Handling of sizing of the components
@@ -683,6 +642,7 @@ int MainInterface::privacyDialog( QList<ConfigControl *> *controls )
 
 QSize MainInterface::sizeHint() const
 {
+#if 0
     if( b_keep_size )
     {
         if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
@@ -700,8 +660,11 @@ QSize MainInterface::sizeHint() const
                 return mainBasedSize;
         }
     }
+#endif
+
+    int nwidth  = __MAX( controls->sizeHint().width(),
+                         menuBar()->sizeHint().width() );
 
-    int nwidth  = controls->sizeHint().width();
     int nheight = controls->isVisible() ?
                   controls->size().height()
                   + inputC->size().height()
@@ -709,8 +672,13 @@ QSize MainInterface::sizeHint() const
                   + statusBar()->size().height()
                   : 0 ;
 
-    if( VISIBLE( bgWidget ) )
+    if( stackCentralW->isVisible() )
+        nheight += stackCentralW->height();
+        nwidth  = __MAX( nwidth, stackCentralW->width() );
+
+/*    if( VISIBLE( bgWidget ) )
     {
+        msg_Warn( p_intf, "Hello here" );
         if( i_bg_height )
             nheight += i_bg_height;
         else
@@ -719,9 +687,10 @@ QSize MainInterface::sizeHint() const
     }
     else if( videoIsActive && videoWidget->isVisible() )
     {
+        msg_Warn( p_intf, "Hello there" );
         nheight += videoWidget->sizeHint().height();
         nwidth  = __MAX( nwidth, videoWidget->sizeHint().width() );
-    }
+    }*/
 #if 0
     if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget()  )
     {
@@ -733,6 +702,7 @@ QSize MainInterface::sizeHint() const
     return QSize( nwidth, nheight );
 }
 
+
 /* Video widget cannot do this synchronously as it runs in another thread */
 /* Well, could it, actually ? Probably dangerous ... */
 
@@ -745,34 +715,102 @@ void MainInterface::doComponentsUpdate()
 {
     if( isFullScreen() || isMaximized() ) return;
 
-    msg_Dbg( p_intf, "Updating the geometry" );
+//    msg_Warn( p_intf, "Updating the geometry" );
     /* 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
+    /* This is WRONG, but I believe there is a Qt bug here */
+    setMinimumSize( 0, 0 );
+    resize( sizeHint() );
+
+    //adjustSize() ; /* This is not needed, but might help in the future */
 }
 
 void MainInterface::debug()
 {
 #ifndef NDEBUG
+    msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->size().height(), size().width() );
+    if( videoEmbeddedFlag )
+        msg_Dbg( p_intf, "Stack Size: %i - %i",
+                 stackCentralW->widget( VIDEO_TAB )->size().height(),
+                 stackCentralW->widget( VIDEO_TAB )->size().width() );
+    else
+        msg_Dbg( p_intf, "no embedded video" );
+
     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() )
+    //msg_Dbg( p_intf, "maximumsize: %i - %i", maximumSize().height(), maximumSize().width() );
+
+    msg_Dbg( p_intf, "Stack minimumsize: %i - %i", stackCentralW->minimumSize().height(), stackCentralW->minimumSize().width() );
+    msg_Dbg( p_intf, "Controls minimumsize: %i - %i", controls->minimumSize().height(), controls->minimumSize().width() );
+    msg_Dbg( p_intf, "Central minimumsize: %i - %i", centralWidget()->minimumSize().height(), centralWidget()->minimumSize().width() );
+    msg_Dbg( p_intf, "Menu minimumsize: %i - %i", menuBar()->minimumSize().height(), menuBar()->minimumSize().width() );
+    msg_Dbg( p_intf, "Input minimuSize: %i - %i", inputC->minimumSize().height(), inputC->minimumSize().width() );
+    msg_Dbg( p_intf, "Status minimumsize: %i - %i", statusBar()->minimumSize().height(), statusBar()->minimumSize().width() );
+    msg_Dbg( p_intf, "minimumsize: %i - %i", minimumSize().height(), minimumSize().width() );
+
+    /*if( videoWidget && videoWidget->isVisible() )
     {
         msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
         msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
+    }*/
+#endif
+}
+
+inline void MainInterface::showTab( int i_tab )
+{
+#ifdef DEBUG_INTF
+    msg_Err( p_intf, "showTab %i", i_tab );
+    msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState );
+#endif
+    stackCentralOldState = stackCentralW->isVisible() ? stackCentralW->currentIndex()
+                                          : HIDDEN_TAB;
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "State change %i %i",  stackCentralW->currentIndex(), i_tab );
+#endif
+
+    if( i_visualmode == QT_NORMAL_MODE )
+    {
+        stackCentralW->setVisible( i_tab != HIDDEN_TAB );
+        doComponentsUpdate(); // resize the player
     }
+    else
+        if( i_tab == HIDDEN_TAB ) i_tab == BACKG_TAB;
+
+    stackCentralW->setCurrentIndex( i_tab );
+
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "New stackCentralOldState %i", stackCentralOldState );
 #endif
 }
 
-void MainInterface::destroyPopupMenu()
+inline void MainInterface::restoreStackOldWidget()
 {
-    QVLCMenu::PopupMenu(p_intf, false );
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState );
+#endif
+    int temp = stackCentralW->isVisible() ? stackCentralW->currentIndex()
+                                          : HIDDEN_TAB;
+    stackCentralW->setCurrentIndex( stackCentralOldState );
+    if( i_visualmode == QT_NORMAL_MODE )
+    {
+        stackCentralW->setVisible( stackCentralOldState != HIDDEN_TAB );
+        doComponentsUpdate(); // resize the player
+    }
+
+    stackCentralOldState = temp;
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "Debug %i %i", temp, stackCentralW->currentIndex() );
+#endif
 }
 
+void MainInterface::destroyPopupMenu()
+{
+    QVLCMenu::PopupMenu( p_intf, false );
+}
 
 void MainInterface::toggleFSC()
 {
@@ -839,25 +877,20 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
     *p_id = ret;
     if( ret ) /* The videoWidget is available */
     {
-        /* Did we have a bg ? Hide it! */
-        if( VISIBLE( bgWidget) )
-        {
-            bgWasVisible = true;
-            bgWidget->toggle();
-        }
-        else
-            bgWasVisible = false;
-
         /* ask videoWidget to show */
         videoWidget->SetSizing( *pi_width, *pi_height );
 
         /* Consider the video active now */
-        videoIsActive = true;
+        showVideo();
+
+        stackCentralW->resize( *pi_width, *pi_height );
 
         emit askUpdate();
     }
 }
 
+
+
 /* Asynchronous call from the WindowClose function */
 void MainInterface::releaseVideo( void )
 {
@@ -869,22 +902,17 @@ void MainInterface::releaseVideoSlot( void )
 {
     videoWidget->release( );
 
-    if( bgWasVisible )
-    {
-        /* Reset the bg state */
-        bgWasVisible = false;
-        bgWidget->show();
-    }
-
-    videoIsActive = false;
+    restoreStackOldWidget();
 
     /* Try to resize, except when you are in Fullscreen mode */
-    doComponentsUpdate();
+//    doComponentsUpdate();
 }
 
 /* Asynchronous call from WindowControl function */
 int MainInterface::controlVideo( int i_query, va_list args )
 {
+    /* Debug to check if VOUT_WINDOW_SET_SIZE is called, because this is broken now */
+    msg_Warn( p_intf, "Control Video: %i", i_query );
     switch( i_query )
     {
     case VOUT_WINDOW_SET_SIZE:
@@ -893,12 +921,13 @@ int MainInterface::controlVideo( int i_query, va_list args )
         unsigned int i_height = va_arg( args, unsigned int );
         emit askVideoToResize( i_width, i_height );
         emit askUpdate();
-        return VLC_SUCCESS;
+        return VLC_EGENERIC;
     }
-    case VOUT_WINDOW_SET_ON_TOP:
+    case VOUT_WINDOW_SET_STATE:
     {
-        int i_arg = va_arg( args, int );
-        QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) );
+        unsigned i_arg = va_arg( args, unsigned );
+        unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE;
+        QApplication::postEvent( this, new SetVideoOnTopQtEvent( on_top ) );
         return VLC_SUCCESS;
     }
     case VOUT_WINDOW_SET_FULLSCREEN:
@@ -919,41 +948,68 @@ int MainInterface::controlVideo( int i_query, va_list args )
 /**
  * Toggle the playlist widget or dialog
  **/
+void MainInterface::createPlaylist( bool b_show )
+{
+    playlistWidget = new PlaylistWidget( p_intf, this );
+
+    i_pl_dock = PL_BOTTOM;
+    /* i_pl_dock = (pl_dock_e)getSettings()
+      ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
+
+    if( i_pl_dock == PL_UNDOCKED )
+    {
+        playlistWidget->setWindowFlags( Qt::Window );
+
+        /* This will restore the geometry but will not work for position,
+           because of parenting */
+        QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
+                playlistWidget, QSize( 600, 300 ) );
+    }
+    else
+    {
+#ifdef DEBUG_INTF
+        msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() );
+#endif
+        stackCentralW->insertWidget( PLAYL_TAB, playlistWidget );
+#ifdef DEBUG_INTF
+        msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() );
+#endif
+    }
+
+    if( b_show )
+    {
+        playlistVisible = true;
+        stackCentralW->show();
+    }
+}
+
 void MainInterface::togglePlaylist()
 {
-    /* CREATION
-    If no playlist exist, then create one and attach it to the DockPL*/
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState );
+#endif
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf );
-
-        i_pl_dock = PL_UNDOCKED;
-/*        i_pl_dock = (pl_dock_e)getSettings()
-                         ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
+        createPlaylist( true );
+    }
+#ifdef DEBUG_INTF
+    msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState );
 
-        if( i_pl_dock == PL_UNDOCKED )
+#endif
+    if( i_pl_dock != PL_UNDOCKED )
+    {
+        /* Playlist not visible */
+        if( stackCentralW->currentIndex() != PLAYL_TAB )
         {
-            playlistWidget->setWindowFlags( Qt::Window );
-
-            /* This will restore the geometry but will not work for position,
-               because of parenting */
-            QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
-                    playlistWidget, QSize( 600, 300 ) );
+            showTab( PLAYL_TAB );
+            stackCentralW->show();
         }
         else
         {
-         //   mainLayout->insertWidget( 4, playlistWidget );
+            restoreStackOldWidget();
         }
-        playlistVisible = true;
-
-        playlistWidget->show();
-    }
-    else
-    {
-    /* toggle the visibility of the playlist */
-       TOGGLEV( playlistWidget );
-       playlistVisible = !playlistVisible;
-       //doComponentsUpdate(); //resize( sizeHint() );
+        playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB );
+        //doComponentsUpdate(); //resize( sizeHint() );
     }
 }
 
@@ -973,18 +1029,23 @@ void MainInterface::toggleMinimalView( bool b_switch )
     if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
         i_visualmode != QT_MINIMAL_MODE )
     { /* NORMAL MODE then */
-        if( !videoWidget || videoWidget->isHidden() )
+        stackCentralW->show();
+        if( !videoWidget || stackCentralW->currentIndex() != VIDEO_TAB )
         {
-            bgWidget->toggle();
+            showBg();
         }
         else
         {
             /* If video is visible, then toggle the status of bgWidget */
-            bgWasVisible = !bgWasVisible;
+            //bgWasVisible = !bgWasVisible;
+            if( stackCentralOldState == BACKG_TAB )
+                stackCentralOldState = HIDDEN_TAB;
+            else
+                stackCentralOldState = BACKG_TAB;
         }
     }
 
-    i_bg_height = bgWidget->height();
+    i_bg_height = stackCentralW->height();
 
     menuBar()->setVisible( !b_switch );
     controls->setVisible( !b_switch );
@@ -1077,7 +1138,7 @@ void MainInterface::showCryptedLabel( bool b_show )
 /*****************************************************************************
  * Systray Icon and Systray Menu
  *****************************************************************************/
-
+#ifndef HAVE_MAEMO
 /**
  * Create a SystemTray icon and a menu that would go with it.
  * Connects to a click handler on the icon.
@@ -1086,9 +1147,9 @@ void MainInterface::createSystray()
 {
     QIcon iconVLC;
     if( QDate::currentDate().dayOfYear() >= 354 )
-        iconVLC =  QIcon( QPixmap( ":/logo/vlc128-christmas.png" ) );
+        iconVLC =  QIcon( ":/logo/vlc128-christmas.png" );
     else
-        iconVLC =  QIcon( QPixmap( ":/logo/vlc128.png" ) );
+        iconVLC =  QIcon( ":/logo/vlc128.png" );
     sysTray = new QSystemTrayIcon( iconVLC, this );
     sysTray->setToolTip( qtr( "VLC media player" ));
 
@@ -1220,6 +1281,7 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
     }
     QVLCMenu::updateSystrayMenu( this, p_intf );
 }
+#endif
 
 /************************************************************************
  * D&D Events
@@ -1231,30 +1293,27 @@ void MainInterface::dropEvent(QDropEvent *event)
 
 void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
 {
-     event->setDropAction( Qt::CopyAction );
-     if( !event->possibleActions() & Qt::CopyAction )
-         return;
+    event->setDropAction( Qt::CopyAction );
+    if( !event->possibleActions() & Qt::CopyAction )
+        return;
 
-     const QMimeData *mimeData = event->mimeData();
+    const QMimeData *mimeData = event->mimeData();
 
-     /* D&D of a subtitles file, add it on the fly */
-     if( mimeData->urls().size() == 1 )
-     {
-        if( THEMIM->getIM()->hasInput() )
+    /* D&D of a subtitles file, add it on the fly */
+    if( mimeData->urls().size() == 1 && THEMIM->getIM()->hasInput() )
+    {
+        if( !input_AddSubtitle( THEMIM->getInput(),
+                 qtu( toNativeSeparators( mimeData->urls()[0].toLocalFile() ) ),
+                 true ) )
         {
-            if( !input_AddSubtitle( THEMIM->getInput(),
-                                    qtu( toNativeSeparators(
-                                         mimeData->urls()[0].toLocalFile() ) ),
-                                    true ) )
-            {
-                event->accept();
-                return;
-            }
+            event->accept();
+            return;
         }
-     }
-     bool first = b_play;
-     foreach( const QUrl &url, mimeData->urls() )
-     {
+    }
+
+    bool first = b_play;
+    foreach( const QUrl &url, mimeData->urls() )
+    {
         QString s = toNativeSeparators( url.toLocalFile() );
 
         if( s.length() > 0 ) {
@@ -1266,8 +1325,8 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
             first = false;
             RecentsMRL::getInstance( p_intf )->addRecent( s );
         }
-     }
-     event->accept();
+    }
+    event->accept();
 }
 void MainInterface::dragEnterEvent(QDragEnterEvent *event)
 {
@@ -1335,6 +1394,7 @@ void MainInterface::handleKeyPress( QKeyEvent *e )
 
 void MainInterface::resizeEvent( QResizeEvent * event )
 {
+#if 0
     if( b_keep_size )
     {
         if( i_visualmode == QT_ALWAYS_VIDEO_MODE ||
@@ -1352,6 +1412,9 @@ void MainInterface::resizeEvent( QResizeEvent * event )
                 mainBasedSize = size();
         }
     }
+#endif
+    QVLCMW::resizeEvent( event );
+    msg_Dbg( p_intf, "Resize Event, height: %i", size().height() );
 }
 
 void MainInterface::wheelEvent( QWheelEvent *e )
@@ -1388,7 +1451,7 @@ void MainInterface::toggleFullScreen( void )
 void MainInterface::changeThumbbarButtons( int i_status)
 {
 #ifdef WIN32
-    // Define an array of two buttons. These buttons provide images through an
+    // Define an array of three buttons. These buttons provide images through an
     // image list and also provide tooltips.
     DWORD dwMask = THB_BITMAP | THB_FLAGS;
 
@@ -1409,14 +1472,6 @@ void MainInterface::changeThumbbarButtons( int i_status)
 
     switch( i_status )
     {
-        case  0:
-        case  END_S:
-            {
-                thbButtons[0].dwFlags = THBF_HIDDEN;
-                thbButtons[1].dwFlags = THBF_HIDDEN;
-                thbButtons[2].dwFlags = THBF_HIDDEN;
-                break;
-            }
         case PLAYING_S:
             {
                 thbButtons[0].dwFlags = THBF_ENABLED;
@@ -1427,15 +1482,16 @@ void MainInterface::changeThumbbarButtons( int i_status)
             }
         case PAUSE_S:
             {
-                //thbButtons[0].dwFlags = THBF_ENABLED;
-                //thbButtons[1].dwFlags = THBF_ENABLED;
-                //thbButtons[2].dwFlags = THBF_ENABLED;
+                thbButtons[0].dwFlags = THBF_ENABLED;
+                thbButtons[1].dwFlags = THBF_ENABLED;
+                thbButtons[2].dwFlags = THBF_ENABLED;
                 thbButtons[1].iBitmap = 2;
                 break;
             }
+        default:
+            return;
     }
-
-    HRESULT hr =  p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons);
+    HRESULT hr =  p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, this->winId(), 3, thbButtons);
     if(S_OK != hr)
         msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr );
 #else
@@ -1474,4 +1530,3 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
     /* Show event */
      return VLC_SUCCESS;
 }
-