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 *****************************************************************************/
28 #include "components/playlist/panels.hpp"
29 #include "components/playlist/selector.hpp"
30 #include "components/playlist/playlist.hpp"
31 #include "input_manager.hpp" /* art */
35 #include <QSpacerItem>
37 #include <QPushButton>
38 #include <QVBoxLayout>
40 /**********************************************************************
41 * Playlist Widget. The embedded playlist
42 **********************************************************************/
44 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *_parent ) :
45 p_intf ( _p_i ), parent( _parent )
47 /* Left Part and design */
48 QSplitter *leftW = new QSplitter( Qt::Vertical, this );
51 selector = new PLSelector( this, p_intf, THEPL );
52 leftW->addWidget( selector );
56 art->setMinimumHeight( 128 );
57 art->setMinimumWidth( 128 );
58 art->setMaximumHeight( 128 );
59 art->setMaximumWidth( 128 );
60 art->setScaledContents( true );
61 art->setPixmap( QPixmap( ":/noart.png" ) );
62 art->setToolTip( qtr( "Double click to get the media informations" ) );
63 leftW->addWidget( art );
65 /* Initialisation of the playlist */
66 playlist_item_t *p_root =
67 playlist_GetPreferredNode( THEPL, THEPL->p_local_category );
69 rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
71 /* Connect the activation of the selector to a redefining of the PL */
72 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
74 /* Connect the activated() to the rootChanged() signal
75 This will be used by StandardPLPanel to setCurrentRootId, that will
76 change the label of the addButton */
77 connect( selector, SIGNAL( activated( int ) ),
78 this, SIGNAL( rootChanged( int ) ) );
80 CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
81 /* Forward removal requests from the selector to the main panel */
82 CONNECT( qobject_cast<PLSelector *>( selector )->model,
84 qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
86 emit rootChanged( p_root->i_id );
88 /* Add the two sides of the QSplitter */
90 addWidget( rightPanel );
93 sizeList << 180 << 420 ;
95 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
96 setStretchFactor( 0, 0 );
97 setStretchFactor( 1, 3 );
98 leftW->setMaximumWidth( 250 );
99 setCollapsible( 1, false );
101 /* In case we want to keep the splitter informations */
102 settings->beginGroup( "playlist" );
103 restoreState( settings->value("splitterSizes").toByteArray());
104 resize( settings->value("size", QSize(600, 300)).toSize());
105 move( settings->value("pos", QPoint( 0, 400)).toPoint());
106 settings->endGroup();
109 void PlaylistWidget::setArt( QString url )
113 art->setPixmap( QPixmap( ":/noart.png" ) );
115 else if( prevArt != url )
117 art->setPixmap( QPixmap( url ) );
122 QSize PlaylistWidget::sizeHint() const
124 return QSize( 600 , 300 );
127 PlaylistWidget::~PlaylistWidget()
130 void PlaylistWidget::savingSettings( QSettings *settings )
132 settings->beginGroup( "playlist" );
133 settings->setValue( "pos", parent->pos() );
134 settings->setValue( "size", parent->size() );
135 settings->setValue( "splitterSizes", saveState() );
136 settings->endGroup();