]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/playlist/selector.cpp
Qt: respect font sizes
[vlc] / modules / gui / qt4 / components / playlist / selector.cpp
index 7af9b34b1b9a7da771aa28f449c69199731dd7ad..2b42401046d1936ec3cf0f57bcf92d00d9351a77 100644 (file)
 #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)
 {
@@ -51,13 +65,14 @@ PLSelItem::PLSelItem ( QTreeWidgetItem *i, const QString& text )
     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 )
@@ -74,14 +89,14 @@ 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() );
 }
@@ -102,7 +117,7 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
     setFrameStyle( QFrame::NoFrame );
     viewport()->setAutoFillBackground( false );
     setIconSize( QSize( 24,24 ) );
-    setIndentation( 14 );
+    setIndentation( 12 );
     header()->hide();
     setRootIsDecorated( true );
     setAlternatingRowColors( false );
@@ -226,17 +241,17 @@ PLSelItem * putPLData( PLSelItem* item, playlist_item_t* plItem )
 
 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()
@@ -446,7 +461,6 @@ void PLSelector::podcastAdd( PLSelItem* item )
 
 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 =
@@ -481,9 +495,6 @@ void PLSelector::drawBranches ( QPainter * painter, const QRect & rect, const QM
     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 );