]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
New recently played menu.
[vlc] / modules / gui / qt4 / main_interface.cpp
index 1f694559cd7f48b2557dcaaf66375e13ed56c49a..dd29bc6bdc6c6881a38d30e5363247f5923a6af6 100644 (file)
 #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>
@@ -131,9 +133,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      * 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    *
@@ -185,11 +190,6 @@ 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 #1365 */
-    ON_TIMEOUT( updateOnTimer() );
-
     /************
      * Callbacks
      ************/
@@ -213,9 +213,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
 
     /* Size and placement of interface */
+    settings->beginGroup( "MainWindow" );
     QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
 
-
     bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
     settings->endGroup();
 
@@ -253,6 +253,8 @@ MainInterface::~MainInterface()
     {
         if( !isDocked() )
             QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
+
+        delete playlistWidget;
     }
 
     settings->beginGroup( "MainWindow" );
@@ -371,26 +373,11 @@ 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(),
-                   b_shiny );
+    controls = new ControlsWidget( p_intf,
+                   settings->value( "adv-controls", false ).toBool() );
     CONNECT( controls, advancedControlsToggled( bool ),
              this, doComponentsUpdate() );
 
-#ifdef WIN32
-    if ( depth() > 8 )
-#endif
-    /* Create the FULLSCREEN CONTROLS Widget */
-    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 );
 
@@ -433,6 +420,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()
@@ -724,7 +721,7 @@ void MainInterface::togglePlaylist()
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf, this );
+        playlistWidget = new PlaylistWidget( p_intf );
 
         i_pl_dock = PL_UNDOCKED;
 /*        i_pl_dock = (pl_dock_e)getSettings()
@@ -734,6 +731,8 @@ void MainInterface::togglePlaylist()
         {
             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 ) );
         }
@@ -811,7 +810,7 @@ void MainInterface::doComponentsUpdate()
 void MainInterface::toggleAdvanced()
 {
     controls->toggleAdvanced();
-    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
+//    if( fullscreenControls ) fullscreenControls->toggleAdvanced();
 }
 
 /* Get the visibility status of the controls (hidden or not, advanced or not) */
@@ -859,16 +858,6 @@ void MainInterface::setStatus( int status )
 {
     msg_Dbg( p_intf, "Updating the stream status: %i", status );
 
-    /* Forward the status to the controls to toggle Play/Pause */
-    controls->setStatus( status );
-    controls->updateInput();
-
-    if( fullscreenControls )
-    {
-        fullscreenControls->setStatus( status );
-        fullscreenControls->updateInput();
-    }
-
     speedControl->setEnable( THEMIM->getIM()->hasInput() );
 
     /* And in the systray for the menu */
@@ -886,16 +875,6 @@ void MainInterface::setRate( int rate )
     speedControl->updateControls( rate );
 }
 
-void MainInterface::updateOnTimer()
-{
-    /* No event for dying */
-    if( !vlc_object_alive( p_intf ) )
-    {
-        QApplication::closeAllWindows();
-        QApplication::quit();
-    }
-}
-
 /*****************************************************************************
  * Systray Icon and Systray Menu
  *****************************************************************************/
@@ -1071,6 +1050,7 @@ void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
                           PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
                           PLAYLIST_END, true, false );
             first = false;
+            RecentsMRL::getInstance( p_intf )->addRecent( s );
         }
      }
      event->acceptProposedAction();
@@ -1203,3 +1183,12 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable,
     /* Show event */
      return VLC_SUCCESS;
 }
+
+/*****************************************************************************
+ * updateRecentsMenu: event called by RecentsMRL
+ *****************************************************************************/
+
+void MainInterface::updateRecentsMenu()
+{
+    QVLCMenu::updateRecents( p_intf );
+}