[vlc-commits] Qt: input manager: allow updating art for not current input_item

Francois Cartegnie git at videolan.org
Mon Jun 4 20:39:19 CEST 2012


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jun  4 15:23:45 2012 +0200| [96fe985a456d5a1dc156093ee7912a361f024451] | committer: Francois Cartegnie

Qt: input manager: allow updating art for not current input_item

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

 modules/gui/qt4/components/info_panels.cpp       |    1 +
 modules/gui/qt4/components/interface_widgets.cpp |   25 ++++++++++++++++++++--
 modules/gui/qt4/components/interface_widgets.hpp |    3 +++
 modules/gui/qt4/components/playlist/playlist.cpp |    2 ++
 modules/gui/qt4/input_manager.cpp                |   22 +++++++++++++------
 modules/gui/qt4/input_manager.hpp                |    5 +++--
 6 files changed, 47 insertions(+), 11 deletions(-)

diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index 6b72d57..f4c439f 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -263,6 +263,7 @@ void MetaPanel::update( input_item_t *p_item )
     }
 
     art_cover->showArtUpdate( file );
+    art_cover->setItem( p_item );
 }
 
 /**
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index e3fcc17..14c449f 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -503,10 +503,12 @@ void SpeedControlWidget::resetRate()
 }
 
 CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
-              : QLabel( parent ), p_intf( _p_i )
+    : QLabel( parent ), p_intf( _p_i ), p_item( NULL )
 {
     setContextMenuPolicy( Qt::ActionsContextMenu );
     CONNECT( this, updateRequested(), this, askForUpdate() );
+    CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
+             this, showArtUpdate( input_item_t * ) );
 
     setMinimumHeight( 128 );
     setMinimumWidth( 128 );
@@ -527,6 +529,14 @@ CoverArtLabel::~CoverArtLabel()
     QList< QAction* > artActions = actions();
     foreach( QAction *act, artActions )
         removeAction( act );
+    if ( p_item ) vlc_gc_decref( p_item );
+}
+
+void CoverArtLabel::setItem( input_item_t *_p_item )
+{
+    if ( p_item ) vlc_gc_decref( p_item );
+    p_item = _p_item;
+    if ( p_item ) vlc_gc_incref( p_item );
 }
 
 void CoverArtLabel::showArtUpdate( const QString& url )
@@ -545,9 +555,20 @@ void CoverArtLabel::showArtUpdate( const QString& url )
     setPixmap( pix );
 }
 
+void CoverArtLabel::showArtUpdate( input_item_t *_p_item )
+{
+    /* not for me */
+    if ( _p_item != p_item )
+        return;
+
+    QString url;
+    if ( _p_item ) url = THEMIM->getIM()->decodeArtURL( _p_item );
+    showArtUpdate( url );
+}
+
 void CoverArtLabel::askForUpdate()
 {
-    THEMIM->getIM()->requestArtUpdate();
+    THEMIM->getIM()->requestArtUpdate( p_item );
 }
 
 TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType  )
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 6251d46..a8869f7 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -228,6 +228,7 @@ class CoverArtLabel : public QLabel
     Q_OBJECT
 public:
     CoverArtLabel( QWidget *parent, intf_thread_t * );
+    void setItem( input_item_t * );
     virtual ~CoverArtLabel();
 
 protected:
@@ -241,6 +242,7 @@ protected:
     }
 private:
     intf_thread_t *p_intf;
+    input_item_t *p_item;
 
 public slots:
     void requestUpdate() { emit updateRequested(); }
@@ -249,6 +251,7 @@ public slots:
         requestUpdate();
     }
     void showArtUpdate( const QString& );
+    void showArtUpdate( input_item_t * );
 
 private slots:
     void askForUpdate();
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index de1c683..29d402d 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -78,6 +78,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
 
     CONNECT( THEMIM->getIM(), artChanged( QString ),
              art, showArtUpdate( const QString& ) );
+    CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
+             art, showArtUpdate( input_item_t * ) );
 
     leftSplitter->addWidget( artContainer );
 
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 88847df..0b710ad 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -628,17 +628,24 @@ void InputManager::UpdateCaching()
     }
 }
 
-void InputManager::requestArtUpdate()
+void InputManager::requestArtUpdate( input_item_t *p_item )
 {
-    if( hasInput() )
-    {
-        playlist_AskForArtEnqueue( pl_Get(p_intf), input_GetItem( p_input ) );
+    bool b_current_item = false;
+    if ( !p_item && hasInput() )
+    {   /* default to current item */
+        p_item = input_GetItem( p_input );
+        b_current_item = true;
     }
-    else
+
+    if ( p_item )
     {
+        playlist_AskForArtEnqueue( pl_Get(p_intf), p_item );
         /* No input will signal the cover art to update,
-         * let's do it ourself */
-        UpdateArt();
+             * let's do it ourself */
+        if ( b_current_item )
+            UpdateArt();
+        else
+            emit artChanged( p_item );
     }
 }
 
@@ -689,6 +696,7 @@ inline void InputManager::UpdateStats()
 inline void InputManager::UpdateMeta( input_item_t *p_item_ )
 {
     emit metaChanged( p_item_ );
+    emit artChanged( p_item_ );
 }
 
 inline void InputManager::UpdateMeta()
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 61957ac..2c8deda 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -140,7 +140,7 @@ public:
     bool hasAudio();
     bool hasVideo() { return hasInput() && b_video; }
     bool hasVisualisation();
-    void requestArtUpdate();
+    void requestArtUpdate( input_item_t *p_item );
 
     QString getName() { return oldName; }
     static const QString decodeArtURL( input_item_t *p_item );
@@ -223,7 +223,8 @@ signals:
     void infoChanged( input_item_t* );
     void currentMetaChanged( input_item_t* );
     void metaChanged( input_item_t *);
-    void artChanged( QString );
+    void artChanged( QString ); /* current item art ( same as item == NULL ) */
+    void artChanged( input_item_t * );
     /// Play/pause status
     void playingStatusChanged( int );
     void recordingStateChanged( bool );



More information about the vlc-commits mailing list