1 /*****************************************************************************
2 * playlist.cpp : Custom widgets for the playlist
3 ****************************************************************************
4 * Copyright © 2006 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 *****************************************************************************/
25 #include "components/playlist/panels.hpp"
26 #include "components/playlist/selector.hpp"
27 #include "components/playlist/playlist.hpp"
28 #include "input_manager.hpp" /* art */
32 #include <QSpacerItem>
34 #include <QPushButton>
35 #include <QVBoxLayout>
37 /**********************************************************************
38 * Playlist Widget. The embedded playlist
39 **********************************************************************/
41 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *_parent ) :
42 p_intf ( _p_i ), parent( _parent )
44 /* Left Part and design */
45 QSplitter *leftW = new QSplitter( Qt::Vertical, this );
48 selector = new PLSelector( this, p_intf, THEPL );
49 leftW->addWidget( selector );
52 art = new QLabel( "" );
53 art->setMinimumHeight( 128 );
54 art->setMinimumWidth( 128 );
55 art->setMaximumHeight( 128 );
56 art->setMaximumWidth( 128 );
57 art->setScaledContents( true );
58 art->setPixmap( QPixmap( ":/noart.png" ) );
59 leftW->addWidget( art );
61 /* Initialisation of the playlist */
62 playlist_item_t *p_root =
63 playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
65 rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
67 /* Connect the activation of the selector to a redefining of the PL */
68 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
70 /* Connect the activated() to the rootChanged() signal
71 This will be used by StandardPLPanel to setCurrentRootId, that will
72 change the label of the addButton */
73 connect( selector, SIGNAL( activated( int ) ),
74 this, SIGNAL( rootChanged( int ) ) );
76 CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
77 /* Forward removal requests from the selector to the main panel */
78 CONNECT( qobject_cast<PLSelector *>( selector )->model,
80 qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
82 emit rootChanged( p_root->i_id );
84 /* Add the two sides of the QSplitter */
86 addWidget( rightPanel );
89 sizeList << 180 << 420 ;
91 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
92 setStretchFactor( 0, 0 );
93 setStretchFactor( 1, 3 );
94 leftW->setMaximumWidth( 250 );
95 setCollapsible( 1, false );
97 /* In case we want to keep the splitter informations */
98 settings->beginGroup( "playlist" );
99 restoreState( settings->value("splitterSizes").toByteArray());
100 resize( settings->value("size", QSize(600, 300)).toSize());
101 move( settings->value("pos", QPoint( 0, 400)).toPoint());
102 settings->endGroup();
105 void PlaylistWidget::setArt( QString url )
109 art->setPixmap( QPixmap( ":/noart.png" ) );
112 else if( prevArt != url )
114 art->setPixmap( QPixmap( url ) );
120 QSize PlaylistWidget::sizeHint() const
122 return QSize( 600 , 300 );
125 PlaylistWidget::~PlaylistWidget()
128 void PlaylistWidget::savingSettings( QSettings *settings )
130 settings->beginGroup( "playlist" );
131 settings->setValue( "pos", parent->pos() );
132 settings->setValue( "size", parent->size() );
133 settings->setValue( "splitterSizes", saveState() );
134 settings->endGroup();