1 /*****************************************************************************
2 * playlist.cpp : Custom widgets for the playlist
3 ****************************************************************************
4 * Copyright © 2007-2010 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/standardpanel.hpp"
30 #include "components/playlist/selector.hpp"
31 #include "components/playlist/playlist.hpp"
33 #include "input_manager.hpp" /* art signal */
34 #include "main_interface.hpp" /* DropEvent TODO remove this*/
39 /**********************************************************************
40 * Playlist Widget. The embedded playlist
41 **********************************************************************/
43 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
44 : QSplitter( _par ), p_intf ( _p_i )
46 setContentsMargins( 3, 3, 3, 3 );
48 /* Left Part and design */
49 leftSplitter = new QSplitter( Qt::Vertical, this );
52 selector = new PLSelector( this, p_intf );
54 QVBoxLayout *selBox = new QVBoxLayout();
55 selBox->setContentsMargins(0,0,0,0);
56 selBox->setSpacing( 0 );
57 selBox->addWidget( selector );
59 QWidget *mediaBrowser = new QWidget();
60 mediaBrowser->setLayout( selBox );
61 leftSplitter->addWidget( mediaBrowser );
63 /* Create a Container for the Art Label
64 in order to have a beautiful resizing for the selector above it */
65 QWidget *artContainer = new QWidget;
66 QHBoxLayout *artContLay = new QHBoxLayout( artContainer );
67 artContLay->setMargin( 0 );
68 artContLay->setSpacing( 0 );
69 artContainer->setMaximumHeight( 128 );
72 art = new ArtLabel( artContainer, p_intf );
73 art->setToolTip( qtr( "Double click to get media information" ) );
75 CONNECT( THEMIM->getIM(), artChanged( QString ),
76 art, showArtUpdate( const QString& ) );
78 artContLay->addWidget( art, 1 );
80 leftSplitter->addWidget( artContainer );
82 /* Initialisation of the playlist */
83 playlist_t * p_playlist = THEPL;
85 playlist_item_t *p_root = THEPL->p_playing;
89 rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root, selector );
91 /* Connect the activation of the selector to a redefining of the PL */
92 DCONNECT( selector, activated( playlist_item_t * ),
93 rightPanel, setRoot( playlist_item_t * ) );
95 rightPanel->setRoot( p_root );
97 /* Add the two sides of the QSplitter */
98 addWidget( leftSplitter );
99 addWidget( rightPanel );
102 sizeList << 180 << 420 ;
103 setSizes( sizeList );
104 //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
105 setStretchFactor( 0, 0 );
106 setStretchFactor( 1, 3 );
107 leftSplitter->setMaximumWidth( 250 );
108 setCollapsible( 1, false );
110 /* In case we want to keep the splitter information */
111 // components shall never write there setting to a fixed location, may infer
112 // with other uses of the same component...
113 getSettings()->beginGroup("Playlist");
114 restoreState( getSettings()->value("splitterSizes").toByteArray());
115 leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() );
116 getSettings()->endGroup();
118 setAcceptDrops( true );
119 setWindowTitle( qtr( "Playlist" ) );
120 setWindowRole( "vlc-playlist" );
121 setWindowIcon( QApplication::windowIcon() );
124 PlaylistWidget::~PlaylistWidget()
126 getSettings()->beginGroup("Playlist");
127 getSettings()->setValue( "splitterSizes", saveState() );
128 getSettings()->setValue( "leftSplitterGeometry", leftSplitter->saveState() );
129 getSettings()->endGroup();
130 msg_Dbg( p_intf, "Playlist Destroyed" );
133 void PlaylistWidget::dropEvent( QDropEvent *event )
135 if( p_intf->p_sys->p_mi )
136 p_intf->p_sys->p_mi->dropEventPlay( event, false );
138 void PlaylistWidget::dragEnterEvent( QDragEnterEvent *event )
140 event->acceptProposedAction();
143 void PlaylistWidget::closeEvent( QCloseEvent *event )
145 if( THEDP->isDying() )
147 p_intf->p_sys->p_mi->playlistVisible = true;
152 p_intf->p_sys->p_mi->playlistVisible = false;
158 void PlaylistWidget::forceHide()
160 leftSplitter->hide();
165 void PlaylistWidget::forceShow()
167 leftSplitter->show();