1 /*****************************************************************************
2 * interface_widgets.cpp : Custom widgets for the main interface
3 ****************************************************************************
4 * Copyright ( C ) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Rafaël Carré <funman@videolanorg>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * ( at your option ) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 #include "components/playlist/panels.hpp"
27 #include "components/playlist/selector.hpp"
28 #include "components/playlist/playlist.hpp"
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 ) :
44 /* Left Part and design */
45 QWidget *leftW = new QWidget( this );
46 QVBoxLayout *left = new QVBoxLayout( leftW );
49 selector = new PLSelector( this, p_intf, THEPL );
50 left->addWidget( selector );
53 art = new QLabel( "" );
54 art->setMinimumHeight( 128 );
55 art->setMinimumWidth( 128 );
56 art->setMaximumHeight( 128 );
57 art->setMaximumWidth( 128 );
58 art->setScaledContents( true );
59 art->setPixmap( QPixmap( ":/noart.png" ) );
60 left->addWidget( art );
62 /* Initialisation of the playlist */
63 playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
64 THEPL->p_local_category );
66 rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
67 p_intf, THEPL, p_root ) );
70 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
72 CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
73 artSet( QString ) , this, setArt( QString ) );
74 /* Forward removal requests from the selector to the main panel */
75 CONNECT( qobject_cast<PLSelector *>( selector )->model,
77 qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
79 connect( selector, SIGNAL( activated( int ) ),
80 this, SIGNAL( rootChanged( int ) ) );
81 emit rootChanged( p_root->i_id );
83 /* Add the two sides of the QSplitter */
85 addWidget( rightPanel );
87 leftW->setMaximumWidth( 250 );
88 setCollapsible( 1, false );
91 sizeList << 180 << 420 ;
93 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
95 /* In case we want to keep the splitter informations */
96 settings->beginGroup( "playlist" );
97 restoreState( settings->value("splitterSizes").toByteArray());
98 resize( settings->value("size", QSize(600, 300)).toSize());
99 move( settings->value("pos", QPoint( 0, 400)).toPoint());
100 settings->endGroup();
103 void PlaylistWidget::setArt( QString url )
107 art->setPixmap( QPixmap( ":/noart.png" ) );
110 else if( prevArt != url )
112 art->setPixmap( QPixmap( url ) );
118 QSize PlaylistWidget::sizeHint() const
120 return QSize( 600 , 300 );
123 PlaylistWidget::~PlaylistWidget()
126 void PlaylistWidget::savingSettings( QSettings *settings )
128 settings->beginGroup( "playlist" );
129 settings->setValue( "pos", pos() );
130 settings->setValue( "size", size() );
131 settings->setValue("splitterSizes", saveState() );
132 settings->endGroup();