/*****************************************************************************
* playlist.cpp : Custom widgets for the playlist
****************************************************************************
- * Copyright © 2006 the VideoLAN team
+ * Copyright © 2007-2008 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* along with this program; if not, write to the Free Software
* 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,
+ QWidget *_parent )
+ : p_intf ( _p_i ), parent( _parent )
{
+ setContentsMargins( 3, 3, 3, 3 );
+
/* Left Part and design */
QSplitter *leftW = new QSplitter( Qt::Vertical, this );
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 ArtLabel;
art->setMinimumHeight( 128 );
art->setMaximumWidth( 128 );
art->setScaledContents( true );
art->setPixmap( QPixmap( ":/noart.png" ) );
- art->setToolTip( qtr( "Double click to get the media informations" ) );
- leftW->addWidget( art );
+ art->setToolTip( qtr( "Double click to get media information" ) );
+
+ artContLay->addWidget( art, 1 );
+
+ leftW->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 );
+ PL_UNLOCK;
rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
connect( selector, SIGNAL( activated( int ) ),
this, SIGNAL( rootChanged( int ) ) );
- CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
/* Forward removal requests from the selector to the main panel */
CONNECT( qobject_cast<PLSelector *>( selector )->model,
shouldRemove( 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 );
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 );
setCollapsible( 1, false );
/* In case we want to keep the splitter informations */
- settings->beginGroup( "playlist" );
- restoreState( settings->value("splitterSizes").toByteArray());
- resize( settings->value("size", QSize(600, 300)).toSize());
- move( settings->value("pos", QPoint( 0, 400)).toPoint());
- settings->endGroup();
+ // components shall never write there setting to a fixed location, may infer
+ // with other uses of the same component...
+ // getSettings()->beginGroup( "playlist" );
+ restoreState( getSettings()->value("splitterSizes").toByteArray());
}
void PlaylistWidget::setArt( QString url )
{
- if( url.isNull() )
- {
- art->setPixmap( QPixmap( ":/noart.png" ) );
- }
- else if( prevArt != url )
+ if( prevArt != url )
{
- art->setPixmap( QPixmap( url ) );
+ art->setPixmap( QPixmap( url.isEmpty() ? ":/noart.png" : url ) );
prevArt = url;
}
}
PlaylistWidget::~PlaylistWidget()
{}
-void PlaylistWidget::savingSettings( QSettings *settings )
+void PlaylistWidget::savingSettings()
{
- settings->beginGroup( "playlist" );
- settings->setValue( "pos", parent->pos() );
- settings->setValue( "size", parent->size() );
- settings->setValue( "splitterSizes", saveState() );
- settings->endGroup();
+ getSettings()->setValue( "splitterSizes", saveState() );
}