[vlc-devel] commit: Qt: make playlist widget even a bit more pretty (Jakob Leben )

git version control git at videolan.org
Thu Feb 4 05:35:18 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Thu Feb  4 05:34:02 2010 +0100| [4fe7b1248d1efb1f3d4970c39db646de6bb3e9e6] | committer: Jakob Leben 

Qt: make playlist widget even a bit more pretty

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4fe7b1248d1efb1f3d4970c39db646de6bb3e9e6
---

 modules/gui/qt4/components/playlist/playlist.cpp   |   18 +++++++++---
 modules/gui/qt4/components/playlist/selector.cpp   |   29 ++++++++++++-------
 modules/gui/qt4/components/playlist/selector.hpp   |    3 +-
 .../gui/qt4/components/playlist/standardpanel.cpp  |    6 ++--
 .../gui/qt4/components/playlist/standardpanel.hpp  |    2 +-
 5 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 8ebc9c3..87e8c3d 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -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 */
diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp
index c4c5813..09305f6 100644
--- a/modules/gui/qt4/components/playlist/selector.cpp
+++ b/modules/gui/qt4/components/playlist/selector.cpp
@@ -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 );
+}
diff --git a/modules/gui/qt4/components/playlist/selector.hpp b/modules/gui/qt4/components/playlist/selector.hpp
index 3682b27..d290714 100644
--- a/modules/gui/qt4/components/playlist/selector.hpp
+++ b/modules/gui/qt4/components/playlist/selector.hpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 5174b82..46f5d34 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index a843678..7df1cae 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -68,7 +68,7 @@ private:
 
     QWidget     *parent;
     QLabel      *title;
-    QPushButton *addButton;
+    QToolButton *addButton;
     QGridLayout *layout;
     LocationBar *locationBar;
 




More information about the vlc-devel mailing list