#include <vlc_playlist.h>
#include <vlc_services_discovery.h>
+void SelectorActionButton::paintEvent( QPaintEvent *event )
+{
+ QPainter p( this );
+ QColor color = palette().color( QPalette::HighlightedText );
+ color.setAlpha( 80 );
+ if( underMouse() )
+ p.fillRect( rect(), color );
+ p.setPen( color );
+ int frame = style()->pixelMetric( QStyle::PM_DefaultFrameWidth, 0, this );
+ p.drawLine( rect().topLeft() + QPoint( 0, frame ),
+ rect().bottomLeft() - QPoint( 0, frame ) );
+ QVLCFramelessButton::paintEvent( event );
+}
+
PLSelItem::PLSelItem ( QTreeWidgetItem *i, const QString& text )
: qitem(i), lblAction( NULL)
{
layout->setContentsMargins(0,0,0,0);
layout->addSpacing( 3 );
- lbl = new QLabel( text );
+ lbl = new QVLCElidingLabel( text );
layout->addWidget(lbl, 1);
setLayout( layout );
- setMinimumHeight( 22 ); //Action icon height plus 6
+ int height = qMax( 22, fontMetrics().height() + 8 );
+ setMinimumHeight( height );
}
void PLSelItem::addAction( ItemAction act, const QString& tooltip )
icon = QIcon( ":/buttons/playlist/playlist_remove" ); break;
}
- lblAction = new QVLCFramelessButton();
+ lblAction = new SelectorActionButton();
lblAction->setIcon( icon );
+ lblAction->setMinimumWidth( lblAction->sizeHint().width() + 6 );
if( !tooltip.isEmpty() ) lblAction->setToolTip( tooltip );
layout->addWidget( lblAction, 0 );
lblAction->hide();
- layout->addSpacing( 3 );
CONNECT( lblAction, clicked(), this, triggerAction() );
}
setFrameStyle( QFrame::NoFrame );
viewport()->setAutoFillBackground( false );
setIconSize( QSize( 24,24 ) );
- setIndentation( 14 );
+ setIndentation( 12 );
header()->hide();
setRootIsDecorated( true );
setAlternatingRowColors( false );
PLSelItem *PLSelector::addPodcastItem( playlist_item_t *p_item )
{
- vlc_gc_incref( p_item->p_input );
- char *psz_name = input_item_GetName( p_item->p_input );
- PLSelItem *item = addItem(
- PL_ITEM_TYPE, qfu( psz_name ), false, podcastsParent );
- item->addAction( RM_ACTION, qtr( "Remove this podcast subscription" ) );
- item->treeItem()->setData( 0, PL_ITEM_ROLE, QVariant::fromValue( p_item ) );
- item->treeItem()->setData( 0, PL_ITEM_ID_ROLE, QVariant(p_item->i_id) );
- item->treeItem()->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( p_item->p_input ) );
- CONNECT( item, action( PLSelItem* ), this, podcastRemove( PLSelItem* ) );
- free( psz_name );
- return item;
+ vlc_gc_incref( p_item->p_input );
+ char *psz_name = input_item_GetName( p_item->p_input );
+ PLSelItem *item = addItem(
+ PL_ITEM_TYPE, qfu( psz_name ), false, podcastsParent );
+ item->addAction( RM_ACTION, qtr( "Remove this podcast subscription" ) );
+ item->treeItem()->setData( 0, PL_ITEM_ROLE, QVariant::fromValue( p_item ) );
+ item->treeItem()->setData( 0, PL_ITEM_ID_ROLE, QVariant(p_item->i_id) );
+ item->treeItem()->setData( 0, IN_ITEM_ROLE, QVariant::fromValue( p_item->p_input ) );
+ CONNECT( item, action( PLSelItem* ), this, podcastRemove( PLSelItem* ) );
+ free( psz_name );
+ return item;
}
void PLSelector::createItems()
void PLSelector::podcastRemove( PLSelItem* item )
{
- //FIXME will translators know to leave that %1 somewhere inside?
QString question ( qtr( "Do you really want to unsubscribe from %1?" ) );
question = question.arg( item->text() );
QMessageBox::StandardButton res =
QStyleOption option;
option.initFrom( this );
option.rect = rect.adjusted( rect.width() - indentation(), 0, 0, 0 );
-
- /*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 );