Commit 4fe7b124 authored by Jakob Leben's avatar Jakob Leben

Qt: make playlist widget even a bit more pretty

parent 49f0cd87
...@@ -50,12 +50,22 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -50,12 +50,22 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
/* Source Selector */ /* Source Selector */
selector = new PLSelector( this, p_intf ); selector = new PLSelector( this, p_intf );
QLabel *selLabel = new QLabel( "Media Browser" );
QFont font;
font.setBold( true );
selLabel->setFont( font );
selLabel->setMargin( 5 );
QVBoxLayout *selBox = new QVBoxLayout(); QVBoxLayout *selBox = new QVBoxLayout();
selBox->setContentsMargins(5,5,5,0); selBox->setContentsMargins(0,0,0,0);
selBox->setSpacing( 0 );
selBox->addWidget( selLabel );
selBox->addWidget( selector ); selBox->addWidget( selector );
QGroupBox *selGroup = new QGroupBox( qtr( "Media Browser") );
selGroup->setLayout( selBox ); QWidget *mediaBrowser = new QWidget();
leftSplitter->addWidget( selGroup ); mediaBrowser->setLayout( selBox );
leftSplitter->addWidget( mediaBrowser );
/* Create a Container for the Art Label /* Create a Container for the Art Label
in order to have a beautiful resizing for the selector above it */ in order to have a beautiful resizing for the selector above it */
......
...@@ -101,9 +101,9 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) ...@@ -101,9 +101,9 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
setFrameStyle( QFrame::NoFrame ); setFrameStyle( QFrame::NoFrame );
viewport()->setAutoFillBackground( false ); viewport()->setAutoFillBackground( false );
setIconSize( QSize( 24,24 ) ); setIconSize( QSize( 24,24 ) );
setIndentation( 10 ); setIndentation( 14 );
header()->hide(); header()->hide();
setRootIsDecorated( false ); setRootIsDecorated( true );
setAlternatingRowColors( false ); setAlternatingRowColors( false );
podcastsParent = NULL; podcastsParent = NULL;
podcastsParentId = -1; podcastsParentId = -1;
...@@ -248,15 +248,10 @@ void PLSelector::createItems() ...@@ -248,15 +248,10 @@ void PLSelector::createItems()
THEPL->p_media_library ); THEPL->p_media_library );
ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) ); ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );
QTreeWidgetItem *msrc = addItem( CATEGORY_TYPE, qtr( "Media Sources" ),
false )->treeItem();
QTreeWidgetItem *mfldrs = NULL; QTreeWidgetItem *mfldrs = NULL;
QTreeWidgetItem *shouts = NULL; QTreeWidgetItem *shouts = NULL;
msrc->setExpanded( true );
char **ppsz_longnames; char **ppsz_longnames;
char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames ); char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames );
if( !ppsz_names ) if( !ppsz_names )
...@@ -272,21 +267,21 @@ void PLSelector::createItems() ...@@ -272,21 +267,21 @@ void PLSelector::createItems()
SD_IS("frenchtv") || SD_IS("freebox") ) SD_IS("frenchtv") || SD_IS("freebox") )
{ {
if( !shouts ) shouts = addItem( CATEGORY_TYPE, qtr( "Shoutcast" ), if( !shouts ) shouts = addItem( CATEGORY_TYPE, qtr( "Shoutcast" ),
false, msrc )->treeItem(); false )->treeItem();
putSDData( addItem( SD_TYPE, *ppsz_longname, false, shouts ), putSDData( addItem( SD_TYPE, *ppsz_longname, false, shouts ),
*ppsz_name, *ppsz_longname ); *ppsz_name, *ppsz_longname );
} }
else if( SD_IS("video_dir") || SD_IS("audio_dir") || SD_IS("picture_dir") ) else if( SD_IS("video_dir") || SD_IS("audio_dir") || SD_IS("picture_dir") )
{ {
if( !mfldrs ) mfldrs = addItem( CATEGORY_TYPE, qtr( "Media Folders" ), if( !mfldrs ) mfldrs = addItem( CATEGORY_TYPE, qtr( "Media Folders" ),
false, msrc )->treeItem(); false )->treeItem();
putSDData( addItem( SD_TYPE, *ppsz_longname, false, mfldrs ), putSDData( addItem( SD_TYPE, *ppsz_longname, false, mfldrs ),
*ppsz_name, *ppsz_longname ); *ppsz_name, *ppsz_longname );
} }
else if( SD_IS("podcast") ) else if( SD_IS("podcast") )
{ {
PLSelItem *podItem = addItem( SD_TYPE, qtr( "Podcasts" ), false, msrc ); PLSelItem *podItem = addItem( SD_TYPE, qtr( "Podcasts" ), false );
putSDData( podItem, *ppsz_name, *ppsz_longname ); putSDData( podItem, *ppsz_name, *ppsz_longname );
podItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) ); podItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
podItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) ); podItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
...@@ -296,7 +291,7 @@ void PLSelector::createItems() ...@@ -296,7 +291,7 @@ void PLSelector::createItems()
} }
else else
{ {
putSDData( addItem( SD_TYPE, qtr( *ppsz_longname ), false, msrc ), putSDData( addItem( SD_TYPE, qtr( *ppsz_longname ), false ),
*ppsz_name, *ppsz_longname ); *ppsz_name, *ppsz_longname );
} }
...@@ -468,3 +463,15 @@ PLSelItem * PLSelector::itemWidget( QTreeWidgetItem *item ) ...@@ -468,3 +463,15 @@ PLSelItem * PLSelector::itemWidget( QTreeWidgetItem *item )
return ( static_cast<PLSelItem*>( QTreeWidget::itemWidget( item, 0 ) ) ); return ( static_cast<PLSelItem*>( QTreeWidget::itemWidget( item, 0 ) ) );
} }
void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) const
{
if( !model()->hasChildren( index ) ) return;
QStyleOption option;
option.initFrom( this );
option.rect = rect;
/*option.state = QStyle::State_Children;
if( isExpanded( index ) ) option.state |= QStyle::State_Open;*/
style()->drawPrimitive( isExpanded( index ) ?
QStyle::PE_IndicatorArrowDown :
QStyle::PE_IndicatorArrowRight, &option, painter );
}
...@@ -108,8 +108,9 @@ protected: ...@@ -108,8 +108,9 @@ protected:
friend class PlaylistWidget; friend class PlaylistWidget;
private: private:
QStringList mimeTypes () const; QStringList mimeTypes () const;
bool dropMimeData ( QTreeWidgetItem * parent, int index, const QMimeData * data, Qt::DropAction action ); bool dropMimeData ( QTreeWidgetItem *, int, const QMimeData *, Qt::DropAction );
void createItems(); void createItems();
void drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const;
PLSelItem * addItem ( PLSelItem * addItem (
SelectorItemType type, const QString& str, bool drop, SelectorItemType type, const QString& str, bool drop,
QTreeWidgetItem* parentItem = 0 ); QTreeWidgetItem* parentItem = 0 );
......
...@@ -89,7 +89,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -89,7 +89,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
layout->setColumnStretch( 4, 2 ); layout->setColumnStretch( 4, 2 );
/* Add item to the playlist button */ /* Add item to the playlist button */
addButton = new QPushButton; addButton = new QToolButton;
addButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) ); addButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) );
addButton->setMaximumWidth( 30 ); addButton->setMaximumWidth( 30 );
BUTTONACT( addButton, popupAdd() ); BUTTONACT( addButton, popupAdd() );
...@@ -97,7 +97,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -97,7 +97,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
/* Button to switch views */ /* Button to switch views */
QToolButton *viewButton = new QToolButton( this ); QToolButton *viewButton = new QToolButton( this );
viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogContentsView ) ); viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
layout->addWidget( viewButton, 0, 2 ); layout->addWidget( viewButton, 0, 2 );
/* View selection menu */ /* View selection menu */
...@@ -474,7 +474,7 @@ void LocationBar::setIndex( const QModelIndex &index ) ...@@ -474,7 +474,7 @@ void LocationBar::setIndex( const QModelIndex &index )
char *fb_name = input_item_GetTitleFbName( item->inputItem() ); char *fb_name = input_item_GetTitleFbName( item->inputItem() );
QString text = qfu(fb_name); QString text = qfu(fb_name);
free(fb_name); free(fb_name);
text = QString("/ ") + metrics.elidedText( text, Qt::ElideRight, 150 ); text = QString("> ") + metrics.elidedText( text, Qt::ElideRight, 150 );
btn->setText( text ); btn->setText( text );
btn->setFont( font ); btn->setFont( font );
prev = insertWidget( prev, btn ); prev = insertWidget( prev, btn );
......
...@@ -68,7 +68,7 @@ private: ...@@ -68,7 +68,7 @@ private:
QWidget *parent; QWidget *parent;
QLabel *title; QLabel *title;
QPushButton *addButton; QToolButton *addButton;
QGridLayout *layout; QGridLayout *layout;
LocationBar *locationBar; LocationBar *locationBar;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment