[vlc-devel] commit: Qt: use the CoverArtLabel in the playlist view and media information dialog ( Jean-Philippe Andre )

git version control git at videolan.org
Sun Sep 7 09:49:54 CEST 2008


vlc | branch: 0.9-bugfix | Jean-Philippe Andre <jpeg at via.ecp.fr> | Wed Sep  3 23:19:19 2008 -0400| [9ed87e8da93447cb1a2682230f9cb90ae3aac2f7] | committer: Jean-Baptiste Kempf 

Qt: use the CoverArtLabel in the playlist view and media information dialog
(cherry picked from commit d2348d98b49475c0868d43bf79639a5980d75c84)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/components/info_panels.cpp       |   23 ++++-----------------
 modules/gui/qt4/components/info_panels.hpp       |    3 +-
 modules/gui/qt4/components/playlist/playlist.cpp |   20 ++----------------
 modules/gui/qt4/components/playlist/playlist.hpp |   13 +++++++----
 modules/gui/qt4/input_manager.cpp                |   15 +------------
 modules/gui/qt4/input_manager.hpp                |    2 +-
 6 files changed, 21 insertions(+), 55 deletions(-)

diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index 29e1757..da90cab 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -28,6 +28,7 @@
 
 #include "qt4.hpp"
 #include "components/info_panels.hpp"
+#include "components/interface_widgets.hpp"
 
 #include <QTreeWidget>
 #include <QListView>
@@ -105,13 +106,7 @@ MetaPanel::MetaPanel( QWidget *parent,
     line++;
 
     /* ART_URL */
-    art_cover = new QLabel( "" );
-    art_cover->setMinimumHeight( 128 );
-    art_cover->setMinimumWidth( 128 );
-    art_cover->setMaximumHeight( 128 );
-    art_cover->setMaximumWidth( 128 );
-    art_cover->setScaledContents( true );
-    art_cover->setPixmap( QPixmap( ":/noart.png" ) );
+    art_cover = new CoverArtLabel( VLC_OBJECT( p_intf ) );
     metaLayout->addWidget( art_cover, line, 8, 4, 2, Qt::AlignRight );
 
 /* Settings is unused */
@@ -227,16 +222,8 @@ void MetaPanel::update( input_item_t *p_item )
 #undef UPDATE_META_INT
 #undef UPDATE_META
 
-    /* Art Urls */
-    psz_meta = input_item_GetArtURL( p_item );
-    if( psz_meta && !strncmp( psz_meta, "file://", 7 ) )
-    {
-        QString artUrl = qfu( psz_meta ).replace( "file://",QString("" ) );
-        art_cover->setPixmap( QPixmap( artUrl ) );
-    }
-    else
-        art_cover->setPixmap( QPixmap( ":/noart.png" ) );
-    free( psz_meta );
+    /* Update Art */
+    art_cover->update( p_item );
 }
 
 /**
@@ -330,7 +317,7 @@ void MetaPanel::clear()
     language_text->clear();
     nowplaying_text->clear();
     publisher_text->clear();
-    art_cover;
+    art_cover->update( NULL );
 
     setEditMode( false );
 }
diff --git a/modules/gui/qt4/components/info_panels.hpp b/modules/gui/qt4/components/info_panels.hpp
index e2efe66..5a948e4 100644
--- a/modules/gui/qt4/components/info_panels.hpp
+++ b/modules/gui/qt4/components/info_panels.hpp
@@ -49,6 +49,7 @@ class QTreeWidgetItem;
 class QTreeView;
 class QSpinBox;
 class QLineEdit;
+class CoverArtLabel;
 
 class MetaPanel: public QWidget
 {
@@ -80,7 +81,7 @@ private:
     QLineEdit *nowplaying_text;
     QLineEdit *publisher_text;
 //    QLineEdit *encodedby_text;
-    QLabel *art_cover;
+    CoverArtLabel *art_cover;
 
 public slots:
     void update( input_item_t * );
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 7168d36..a16d39e 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -64,13 +64,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i,
     artContainer->setMaximumHeight( 128 );
 
     /* Art label */
-    art = new ArtLabel;
-    art->setMinimumHeight( 128 );
-    art->setMinimumWidth( 128 );
-    art->setMaximumHeight( 128 );
-    art->setMaximumWidth( 128 );
-    art->setScaledContents( true );
-    art->setPixmap( QPixmap( ":/noart.png" ) );
+    art = new ArtLabel( p_intf );
     art->setToolTip( qtr( "Double click to get media information" ) );
 
     artContLay->addWidget( art, 1 );
@@ -103,7 +97,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i,
     emit rootChanged( p_root->i_id );
 
     /* art */
-    CONNECT( THEMIM->getIM(), artChanged( QString ) , this, setArt( QString ) );
+    CONNECT( THEMIM->getIM(), artChanged( input_item_t* ) ,
+             art, update( input_item_t* ) );
 
     /* Add the two sides of the QSplitter */
     addWidget( leftW );
@@ -129,15 +124,6 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i,
     setWindowIcon( QApplication::windowIcon() );
 }
 
-void PlaylistWidget::setArt( QString url )
-{
-    if( prevArt != url )
-    {
-        art->setPixmap( QPixmap( url.isEmpty() ? ":/noart.png" : url ) );
-        prevArt = url;
-    }
-}
-
 PlaylistWidget::~PlaylistWidget()
 {
     getSettings()->beginGroup("playlistdialog");
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index 701b913..71180e0 100644
--- a/modules/gui/qt4/components/playlist/playlist.hpp
+++ b/modules/gui/qt4/components/playlist/playlist.hpp
@@ -33,6 +33,7 @@
 #include <vlc_common.h>
 #include "qt4.hpp"
 #include "dialogs_provider.hpp"
+#include "components/interface_widgets.hpp"
 
 #include <QSplitter>
 #include <QLabel>
@@ -40,6 +41,8 @@
 class PLSelector;
 class PLPanel;
 class QPushButton;
+class CoverArtLabel;
+class ArtLabel;
 
 class PlaylistWidget : public QSplitter
 {
@@ -51,8 +54,7 @@ private:
     PLSelector *selector;
     PLPanel *rightPanel;
     QPushButton *addButton;
-    QLabel *art;
-    QString prevArt;
+    ArtLabel *art;
     QWidget *parent;
 protected:
     intf_thread_t *p_intf;
@@ -60,15 +62,16 @@ protected:
     virtual void dragEnterEvent( QDragEnterEvent * );
     virtual void closeEvent( QCloseEvent * );
 
-private slots:
-    void setArt( QString );
 signals:
     void rootChanged( int );
 };
 
-class ArtLabel : public QLabel
+class ArtLabel : public CoverArtLabel
 {
     Q_OBJECT
+public:
+    ArtLabel( intf_thread_t *intf ) : CoverArtLabel( VLC_OBJECT( intf ) ) {};
+    virtual ~ArtLabel() {};
     void mouseDoubleClickEvent( QMouseEvent *event )
     {
         THEDP->mediaInfoDialog();
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 9536614..6c0848f 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -122,7 +122,7 @@ void InputManager::delInput()
         emit positionUpdated( -1.0, 0 ,0 );
         emit statusChanged( END_S );
         emit nameChanged( "" );
-        emit artChanged( "" );
+        emit artChanged( NULL );
         emit rateChanged( INPUT_RATE_DEFAULT );
         emit voutChanged( false );
         vlc_object_release( p_input );
@@ -383,18 +383,7 @@ void InputManager::UpdateVout()
 void InputManager::UpdateArt()
 {
     /* Update Art meta */
-    QString url;
-    char *psz_art = input_item_GetArtURL( input_GetItem( p_input ) );
-    url.sprintf("%s", psz_art );
-    free( psz_art );
-    if( artUrl != url )
-    {
-        artUrl = url.replace( "file://",QString("" ) );
-        /* Taglib seems to define a attachment://, It won't work yet */
-        artUrl = url.replace( "attachment://",QString("" ) );
-        emit artChanged( artUrl );
-        msg_Dbg( p_intf, "Art:  %s", qtu( artUrl ) );
-    }
+    emit artChanged( input_GetItem( p_input ) );
 }
 
 /* User update of the slider */
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 4d4ef5d..0d0798d 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -124,7 +124,7 @@ signals:
     void navigationChanged( int );
     /// Play/pause status
     void statusChanged( int );
-    void artChanged( QString );
+    void artChanged( input_item_t* );
     /// Teletext
     void teletextEnabled( bool );
     void toggleTelexButtons();




More information about the vlc-devel mailing list