]> git.sesse.net Git - vlc/commitdiff
Qt: make playlist widget even a bit more pretty
authorJakob Leben <jleben@videolan.org>
Thu, 4 Feb 2010 04:34:02 +0000 (05:34 +0100)
committerJakob Leben <jleben@videolan.org>
Thu, 4 Feb 2010 04:35:11 +0000 (05:35 +0100)
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/selector.cpp
modules/gui/qt4/components/playlist/selector.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index 8ebc9c3eba0a6c73e0fb4244017a187d05f657a4..87e8c3d7bfcd3a928899756acfae61231c402f17 100644 (file)
@@ -50,12 +50,22 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     /* Source Selector */
     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();
-    selBox->setContentsMargins(5,5,5,0);
+    selBox->setContentsMargins(0,0,0,0);
+    selBox->setSpacing( 0 );
+    selBox->addWidget( selLabel );
     selBox->addWidget( selector );
-    QGroupBox *selGroup = new QGroupBox( qtr( "Media Browser") );
-    selGroup->setLayout( selBox );
-    leftSplitter->addWidget( selGroup );
+
+    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 */
index c4c581304c39491d936154d62a1ec5c79263ea76..09305f6aa9e11e340cb95f4b484d94cfe4e17c86 100644 (file)
@@ -101,9 +101,9 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
     setFrameStyle( QFrame::NoFrame );
     viewport()->setAutoFillBackground( false );
     setIconSize( QSize( 24,24 ) );
-    setIndentation( 10 );
+    setIndentation( 14 );
     header()->hide();
-    setRootIsDecorated( false );
+    setRootIsDecorated( true );
     setAlternatingRowColors( false );
     podcastsParent = NULL;
     podcastsParentId = -1;
@@ -248,15 +248,10 @@ void PLSelector::createItems()
                               THEPL->p_media_library );
     ml->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_ML ) );
 
-    QTreeWidgetItem *msrc = addItem( CATEGORY_TYPE, qtr( "Media Sources" ),
-                                      false )->treeItem();
-
     QTreeWidgetItem *mfldrs = NULL;
 
     QTreeWidgetItem *shouts = NULL;
 
-    msrc->setExpanded( true );
-
     char **ppsz_longnames;
     char **ppsz_names = vlc_sd_GetNames( THEPL, &ppsz_longnames );
     if( !ppsz_names )
@@ -272,21 +267,21 @@ void PLSelector::createItems()
             SD_IS("frenchtv") || SD_IS("freebox") )
         {
             if( !shouts ) shouts = addItem( CATEGORY_TYPE, qtr( "Shoutcast" ),
-                                            false, msrc )->treeItem();
+                                            false )->treeItem();
             putSDData( addItem( SD_TYPE, *ppsz_longname, false, shouts ),
                        *ppsz_name, *ppsz_longname );
         }
         else if( SD_IS("video_dir") || SD_IS("audio_dir") || SD_IS("picture_dir") )
         {
             if( !mfldrs ) mfldrs = addItem( CATEGORY_TYPE, qtr( "Media Folders" ),
-                                            false, msrc )->treeItem();
+                                            false )->treeItem();
             putSDData( addItem( SD_TYPE, *ppsz_longname, false, mfldrs ),
                        *ppsz_name, *ppsz_longname );
         }
         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 );
             podItem->treeItem()->setData( 0, SPECIAL_ROLE, QVariant( IS_PODCAST ) );
             podItem->addAction( ADD_ACTION, qtr( "Subscribe to a podcast" ) );
@@ -296,7 +291,7 @@ void PLSelector::createItems()
         }
         else
         {
-            putSDData( addItem( SD_TYPE, qtr( *ppsz_longname ), false, msrc ),
+            putSDData( addItem( SD_TYPE, qtr( *ppsz_longname ), false ),
                        *ppsz_name, *ppsz_longname );
         }
 
@@ -468,3 +463,15 @@ PLSelItem * PLSelector::itemWidget( QTreeWidgetItem *item )
     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 );
+}
index 3682b27769d1408b4b3a4662d2383c62ce61e83c..d290714e11e8d9f531ec5fc0b8e6906e21340bc0 100644 (file)
@@ -108,8 +108,9 @@ protected:
     friend class PlaylistWidget;
 private:
     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 drawBranches ( QPainter *, const QRect &, const QModelIndex & ) const;
     PLSelItem * addItem (
         SelectorItemType type, const QString& str, bool drop,
         QTreeWidgetItem* parentItem = 0 );
index 5174b82ec9887550615aeb97b5944afe874ca500..46f5d34bb07c123878730c589d0db39884a585ea 100644 (file)
@@ -89,7 +89,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     layout->setColumnStretch( 4, 2 );
 
     /* Add item to the playlist button */
-    addButton = new QPushButton;
+    addButton = new QToolButton;
     addButton->setIcon( QIcon( ":/buttons/playlist/playlist_add" ) );
     addButton->setMaximumWidth( 30 );
     BUTTONACT( addButton, popupAdd() );
@@ -97,7 +97,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     /* Button to switch views */
     QToolButton *viewButton = new QToolButton( this );
-    viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogContentsView ) );
+    viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
     layout->addWidget( viewButton, 0, 2 );
 
     /* View selection menu */
@@ -474,7 +474,7 @@ void LocationBar::setIndex( const QModelIndex &index )
         char *fb_name = input_item_GetTitleFbName( item->inputItem() );
         QString text = qfu(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->setFont( font );
         prev = insertWidget( prev, btn );
index a84367875c244a391fd286ae647d2fba95c47a26..7df1cae018d447a06db6f7db620ca1d84459b631 100644 (file)
@@ -68,7 +68,7 @@ private:
 
     QWidget     *parent;
     QLabel      *title;
-    QPushButton *addButton;
+    QToolButton *addButton;
     QGridLayout *layout;
     LocationBar *locationBar;