/*****************************************************************************
- * interface_widgets.cpp : Custom widgets for the main interface
+ * playlist.cpp : Custom widgets for the playlist
****************************************************************************
- * Copyright ( C ) 2006 the VideoLAN team
+ * Copyright © 2007-2010 the VideoLAN team
* $Id$
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
- * Rafaël Carré <funman@videolanorg>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#include "components/playlist/panels.hpp"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "components/playlist/standardpanel.hpp"
#include "components/playlist/selector.hpp"
#include "components/playlist/playlist.hpp"
-#include <QSettings>
-#include <QLabel>
-#include <QSpacerItem>
-#include <QCursor>
-#include <QPushButton>
-#include <QVBoxLayout>
+#include "input_manager.hpp" /* art signal */
+#include "main_interface.hpp" /* DropEvent TODO remove this*/
+
+#include <QGroupBox>
+#include <iostream>
/**********************************************************************
* Playlist Widget. The embedded playlist
**********************************************************************/
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) :
- p_intf ( _p_i )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
+ : QSplitter( _par ), p_intf ( _p_i )
{
+ setContentsMargins( 3, 3, 3, 3 );
+
/* Left Part and design */
- QWidget *leftW = new QWidget( this );
- QVBoxLayout *left = new QVBoxLayout( leftW );
+ leftSplitter = new QSplitter( Qt::Vertical, this );
/* Source Selector */
- selector = new PLSelector( this, p_intf, THEPL );
- left->addWidget( selector );
+ selector = new PLSelector( this, p_intf );
+
+ QLabel *selLabel = new QLabel( qtr( "Media Browser" ) );
+ QFont font;
+ font.setBold( true );
+ selLabel->setFont( font );
+ selLabel->setMargin( 5 );
+
+ QVBoxLayout *selBox = new QVBoxLayout();
+ selBox->setContentsMargins(0,0,0,0);
+ selBox->setSpacing( 0 );
+ selBox->addWidget( selLabel );
+ selBox->addWidget( selector );
+
+ QWidget *mediaBrowser = new QWidget();
+ mediaBrowser->setLayout( selBox );
+ leftSplitter->addWidget( mediaBrowser );
+
+ /* Create a Container for the Art Label
+ in order to have a beautiful resizing for the selector above it */
+ QWidget *artContainer = new QWidget;
+ QHBoxLayout *artContLay = new QHBoxLayout( artContainer );
+ artContLay->setMargin( 0 );
+ artContLay->setSpacing( 0 );
+ artContainer->setMaximumHeight( 128 );
/* Art label */
- art = new QLabel( "" );
- art->setMinimumHeight( 128 );
- art->setMinimumWidth( 128 );
- art->setMaximumHeight( 128 );
- art->setMaximumWidth( 128 );
- art->setScaledContents( true );
- art->setPixmap( QPixmap( ":/noart.png" ) );
- left->addWidget( art );
+ art = new ArtLabel( artContainer, p_intf );
+ art->setToolTip( qtr( "Double click to get media information" ) );
+
+ CONNECT( THEMIM->getIM(), artChanged( QString ),
+ art, showArtUpdate( const QString& ) );
+
+ artContLay->addWidget( art, 1 );
+
+ leftSplitter->addWidget( artContainer );
/* Initialisation of the playlist */
- playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
- THEPL->p_local_category );
+ playlist_t * p_playlist = THEPL;
+ PL_LOCK;
+ playlist_item_t *p_root = THEPL->p_playing;
- rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
- p_intf, THEPL, p_root ) );
+ PL_UNLOCK;
- /* Connects */
- CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
+ rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
- CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
- artSet( QString ) , this, setArt( QString ) );
- /* Forward removal requests from the selector to the main panel */
- CONNECT( qobject_cast<PLSelector *>( selector )->model,
- shouldRemove( int ),
- qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
+ /* Connect the activation of the selector to a redefining of the PL */
+ DCONNECT( selector, activated( playlist_item_t * ),
+ rightPanel, setRoot( playlist_item_t * ) );
- connect( selector, SIGNAL( activated( int ) ),
- this, SIGNAL( rootChanged( int ) ) );
- emit rootChanged( p_root->i_id );
+ rightPanel->setRoot( p_root );
/* Add the two sides of the QSplitter */
- addWidget( leftW );
+ addWidget( leftSplitter );
addWidget( rightPanel );
- leftW->setMaximumWidth( 250 );
- setCollapsible( 1, false );
-
QList<int> sizeList;
sizeList << 180 << 420 ;
setSizes( sizeList );
- setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
+ //setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
setStretchFactor( 0, 0 );
setStretchFactor( 1, 3 );
+ leftSplitter->setMaximumWidth( 250 );
+ setCollapsible( 1, false );
- /* In case we want to keep the splitter informations */
- settings->beginGroup( "playlist" );
- restoreState( settings->value("splitterSizes").toByteArray());
- resize( settings->value("size", QSize(600, 300)).toSize());
- move( settings->value("pos", QPoint( 0, 400)).toPoint());
- settings->endGroup();
+ /* In case we want to keep the splitter information */
+ // components shall never write there setting to a fixed location, may infer
+ // with other uses of the same component...
+ getSettings()->beginGroup("Playlist");
+ restoreState( getSettings()->value("splitterSizes").toByteArray());
+ leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() );
+ getSettings()->endGroup();
+
+ setAcceptDrops( true );
+ setWindowTitle( qtr( "Playlist" ) );
+ setWindowRole( "vlc-playlist" );
+ setWindowIcon( QApplication::windowIcon() );
}
-void PlaylistWidget::setArt( QString url )
+PlaylistWidget::~PlaylistWidget()
{
- if( url.isNull() )
+ getSettings()->beginGroup("Playlist");
+ getSettings()->setValue( "splitterSizes", saveState() );
+ getSettings()->setValue( "leftSplitterGeometry", leftSplitter->saveState() );
+ getSettings()->endGroup();
+ msg_Dbg( p_intf, "Playlist Destroyed" );
+}
+
+void PlaylistWidget::dropEvent( QDropEvent *event )
+{
+ if( p_intf->p_sys->p_mi )
+ p_intf->p_sys->p_mi->dropEventPlay( event, false );
+}
+void PlaylistWidget::dragEnterEvent( QDragEnterEvent *event )
+{
+ event->acceptProposedAction();
+}
+
+void PlaylistWidget::closeEvent( QCloseEvent *event )
+{
+ if( THEDP->isDying() )
{
- art->setPixmap( QPixmap( ":/noart.png" ) );
- emit artSet( url );
+ p_intf->p_sys->p_mi->playlistVisible = true;
+ event->accept();
}
- else if( prevArt != url )
+ else
{
- art->setPixmap( QPixmap( url ) );
- prevArt = url;
- emit artSet( url );
+ p_intf->p_sys->p_mi->playlistVisible = false;
+ hide();
+ event->ignore();
}
}
-QSize PlaylistWidget::sizeHint() const
+void PlaylistWidget::forceHide()
{
- return QSize( 600 , 300 );
+ leftSplitter->hide();
+ rightPanel->hide();
+ updateGeometry();
}
-PlaylistWidget::~PlaylistWidget()
-{}
-
-void PlaylistWidget::savingSettings( QSettings *settings )
+void PlaylistWidget::forceShow()
{
- settings->beginGroup( "playlist" );
- settings->setValue( "pos", pos() );
- settings->setValue( "size", size() );
- settings->setValue("splitterSizes", saveState() );
- settings->endGroup();
+ leftSplitter->show();
+ rightPanel->show();
+ updateGeometry();
}
-