1 /*****************************************************************************
2 * playlist.cpp : Custom widgets for the playlist
3 ****************************************************************************
4 * Copyright © 2007-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * ( at your option ) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include "components/playlist/panels.hpp"
30 #include "components/playlist/selector.hpp"
31 #include "components/playlist/playlist.hpp"
32 #include "input_manager.hpp" /* art signal */
36 #include <QSpacerItem>
38 #include <QPushButton>
39 #include <QVBoxLayout>
41 /**********************************************************************
42 * Playlist Widget. The embedded playlist
43 **********************************************************************/
45 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *_parent ) :
46 p_intf ( _p_i ), parent( _parent )
48 /* Left Part and design */
49 QSplitter *leftW = new QSplitter( Qt::Vertical, this );
52 selector = new PLSelector( this, p_intf, THEPL );
53 leftW->addWidget( selector );
55 QWidget *artContainer = new QWidget;
56 QHBoxLayout *artContLay = new QHBoxLayout( artContainer );
60 art->setMinimumHeight( 128 );
61 art->setMinimumWidth( 128 );
62 art->setMaximumHeight( 128 );
63 art->setMaximumWidth( 128 );
64 art->setScaledContents( true );
65 art->setPixmap( QPixmap( ":/noart.png" ) );
66 art->setToolTip( qtr( "Double click to get the media informations" ) );
67 artContLay->addWidget( art, 1 );
69 leftW->addWidget( artContainer );
71 /* Initialisation of the playlist */
72 playlist_item_t *p_root =
73 playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
75 rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
77 /* Connect the activation of the selector to a redefining of the PL */
78 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
80 /* Connect the activated() to the rootChanged() signal
81 This will be used by StandardPLPanel to setCurrentRootId, that will
82 change the label of the addButton */
83 connect( selector, SIGNAL( activated( int ) ),
84 this, SIGNAL( rootChanged( int ) ) );
86 CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
87 /* Forward removal requests from the selector to the main panel */
88 CONNECT( qobject_cast<PLSelector *>( selector )->model,
90 qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
92 emit rootChanged( p_root->i_id );
94 /* Add the two sides of the QSplitter */
96 addWidget( rightPanel );
99 sizeList << 180 << 420 ;
100 setSizes( sizeList );
101 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
102 setStretchFactor( 0, 0 );
103 setStretchFactor( 1, 3 );
104 leftW->setMaximumWidth( 250 );
105 setCollapsible( 1, false );
107 /* In case we want to keep the splitter informations */
108 settings->beginGroup( "playlist" );
109 restoreState( settings->value("splitterSizes").toByteArray());
110 resize( settings->value("size", QSize(600, 300)).toSize());
111 move( settings->value("pos", QPoint( 0, 400)).toPoint());
112 settings->endGroup();
115 void PlaylistWidget::setArt( QString url )
119 art->setPixmap( QPixmap( ":/noart.png" ) );
121 else if( prevArt != url )
123 art->setPixmap( QPixmap( url ) );
128 QSize PlaylistWidget::sizeHint() const
130 return QSize( 600 , 300 );
133 PlaylistWidget::~PlaylistWidget()
136 void PlaylistWidget::savingSettings( QSettings *settings )
138 settings->beginGroup( "playlist" );
139 settings->setValue( "pos", parent->pos() );
140 settings->setValue( "size", parent->size() );
141 settings->setValue( "splitterSizes", saveState() );
142 settings->endGroup();