]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/playlist.cpp
More Id and permission fixes.
[vlc] / modules / gui / qt4 / components / playlist / playlist.cpp
index 90bca24e51c7e5d069454af2be321987881f295a..ed94919cbfbe480738533457189ec13b3cac2b46 100644 (file)
@@ -1,12 +1,11 @@
 /*****************************************************************************
- * interface_widgets.cpp : Custom widgets for the main interface
+ * playlist.cpp : Custom widgets for the playlist
  ****************************************************************************
- * Copyright ( C ) 2006 the VideoLAN team
+ * Copyright © 2007-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Clément Stenac <zorglub@videolan.org>
  *          Jean-Baptiste Kempf <jb@videolan.org>
- *          Rafaël Carré <funman@videolanorg>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "components/playlist/panels.hpp"
 #include "components/playlist/selector.hpp"
 #include "components/playlist/playlist.hpp"
-#include "input_manager.hpp" /* art */
+#include "input_manager.hpp" /* art signal */
 
 #include <QSettings>
 #include <QLabel>
  * Playlist Widget. The embedded playlist
  **********************************************************************/
 
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *_parent ) :
-                                p_intf ( _p_i ), parent( _parent )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i,
+                                QSettings *settings,
+                                QWidget *_parent )
+               : p_intf ( _p_i ), parent( _parent )
 {
     /* Left Part and design */
     QSplitter *leftW = new QSplitter( Qt::Vertical, this );
@@ -49,36 +54,53 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidge
     selector = new PLSelector( this, p_intf, THEPL );
     leftW->addWidget( selector );
 
+    /* Create a Container for the Art Label
+       in order to have a beautiful resizing for the selector above it */
+    QWidget *artContainer = new QWidget;
+    QHBoxLayout *artContLay = new QHBoxLayout( artContainer );
+    artContLay->setMargin( 0 );
+    artContLay->setSpacing( 0 );
+    artContainer->setMaximumHeight( 128 );
+
     /* Art label */
-    art = new QLabel( "" );
+    art = new ArtLabel;
     art->setMinimumHeight( 128 );
     art->setMinimumWidth( 128 );
     art->setMaximumHeight( 128 );
     art->setMaximumWidth( 128 );
     art->setScaledContents( true );
     art->setPixmap( QPixmap( ":/noart.png" ) );
-    leftW->addWidget( art );
+    art->setToolTip( qtr( "Double click to get the media informations" ) );
+
+    artContLay->addWidget( art, 1 );
+
+    leftW->addWidget( artContainer );
 
     /* Initialisation of the playlist */
-    playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
-                                                THEPL->p_local_category );
+    playlist_item_t *p_root =
+                  playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
 
-    rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
-                              p_intf, THEPL, p_root ) );
+    rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
 
-    /* Connects */
+    /* Connect the activation of the selector to a redefining of the PL */
     CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
 
-    CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
+    /* 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, SIGNAL( activated( int ) ),
-             this, SIGNAL( rootChanged( int ) ) );
     emit rootChanged( p_root->i_id );
 
+    /* art */
+    CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
+
     /* Add the two sides of the QSplitter */
     addWidget( leftW );
     addWidget( rightPanel );
@@ -86,7 +108,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidge
     QList<int> sizeList;
     sizeList << 180 << 420 ;
     setSizes( sizeList );
-    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
+    //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
     setStretchFactor( 0, 0 );
     setStretchFactor( 1, 3 );
     leftW->setMaximumWidth( 250 );
@@ -102,16 +124,14 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidge
 
 void PlaylistWidget::setArt( QString url )
 {
-    if( url.isNull() )
+    if( url.isEmpty() )
     {
         art->setPixmap( QPixmap( ":/noart.png" ) );
-        emit artSet( url );
     }
     else if( prevArt != url )
     {
         art->setPixmap( QPixmap( url ) );
         prevArt = url;
-        emit artSet( url );
     }
 }