]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist.cpp
various modules: adjust to new playlist design
[vlc] / modules / gui / qt4 / components / playlist / playlist.cpp
index 8ad5d11f8f26c3b4e171e13021616a6b9e9bafa0..8ebc9c3eba0a6c73e0fb4244017a187d05f657a4 100644 (file)
 # include "config.h"
 #endif
 
-#include "components/playlist/panels.hpp"
+#include "components/playlist/standardpanel.hpp"
 #include "components/playlist/selector.hpp"
 #include "components/playlist/playlist.hpp"
 
 #include "input_manager.hpp" /* art signal */
 #include "main_interface.hpp" /* DropEvent TODO remove this*/
 
+#include <QGroupBox>
+
+#include <iostream>
 /**********************************************************************
  * Playlist Widget. The embedded playlist
  **********************************************************************/
 
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
+               : QSplitter( _par ), p_intf ( _p_i )
 {
     setContentsMargins( 3, 3, 3, 3 );
 
     /* Left Part and design */
-    QSplitter *leftW = new QSplitter( Qt::Vertical, this );
+    leftSplitter = new QSplitter( Qt::Vertical, this );
 
     /* Source Selector */
     selector = new PLSelector( this, p_intf );
-    leftW->addWidget( selector );
+    QVBoxLayout *selBox = new QVBoxLayout();
+    selBox->setContentsMargins(5,5,5,0);
+    selBox->addWidget( selector );
+    QGroupBox *selGroup = new QGroupBox( qtr( "Media Browser") );
+    selGroup->setLayout( selBox );
+    leftSplitter->addWidget( selGroup );
 
     /* Create a Container for the Art Label
        in order to have a beautiful resizing for the selector above it */
@@ -65,35 +74,25 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
 
     artContLay->addWidget( art, 1 );
 
-    leftW->addWidget( artContainer );
+    leftSplitter->addWidget( artContainer );
 
     /* Initialisation of the playlist */
     playlist_t * p_playlist = THEPL;
     PL_LOCK;
-    playlist_item_t *p_root =
-                  playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
+    playlist_item_t *p_root = THEPL->p_playing;
+
     PL_UNLOCK;
 
     rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
 
     /* Connect the activation of the selector to a redefining of the PL */
-    CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
-
-    /* Connect the activated() to the rootChanged() signal
-       This will be used by StandardPLPanel to setCurrentRootId, that will
-       change the label of the addButton  */
-    connect( selector, SIGNAL( activated( int ) ),
-             this, SIGNAL( rootChanged( int ) ) );
-
-    /* Forward removal requests from the selector to the main panel */
-    CONNECT( qobject_cast<PLSelector *>( selector )->model,
-             shouldRemove( int ),
-             qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
+    CONNECT( selector, activated( playlist_item_t * ),
+             rightPanel, setRoot( playlist_item_t * ) );
 
-    emit rootChanged( p_root->i_id );
+    rightPanel->setRoot( p_root );
 
     /* Add the two sides of the QSplitter */
-    addWidget( leftW );
+    addWidget( leftSplitter );
     addWidget( rightPanel );
 
     QList<int> sizeList;
@@ -102,7 +101,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
     //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
     setStretchFactor( 0, 0 );
     setStretchFactor( 1, 3 );
-    leftW->setMaximumWidth( 250 );
+    leftSplitter->setMaximumWidth( 250 );
     setCollapsible( 1, false );
 
     /* In case we want to keep the splitter informations */
@@ -111,10 +110,12 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
     // getSettings()->beginGroup( "playlist" );
     getSettings()->beginGroup("Playlist");
     restoreState( getSettings()->value("splitterSizes").toByteArray());
+    leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() );
     getSettings()->endGroup();
 
     setAcceptDrops( true );
     setWindowTitle( qtr( "Playlist" ) );
+    setWindowRole( "vlc-playlist" );
     setWindowIcon( QApplication::windowIcon() );
 }
 
@@ -122,6 +123,7 @@ PlaylistWidget::~PlaylistWidget()
 {
     getSettings()->beginGroup("Playlist");
     getSettings()->setValue( "splitterSizes", saveState() );
+    getSettings()->setValue( "leftSplitterGeometry", leftSplitter->saveState() );
     getSettings()->endGroup();
     msg_Dbg( p_intf, "Playlist Destroyed" );
 }
@@ -141,12 +143,11 @@ void PlaylistWidget::closeEvent( QCloseEvent *event )
     if( THEDP->isDying() )
     {
         /* FIXME is it needed ? */
-        close();
+        event->accept();
     }
     else
     {
-        if( p_intf->p_sys->p_mi )
-            p_intf->p_sys->p_mi->togglePlaylist();
+        hide();
+        event->ignore();
     }
-    event->accept();
 }