Commit 96fe985a authored by Francois Cartegnie's avatar Francois Cartegnie

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

parent 26713706
...@@ -263,6 +263,7 @@ void MetaPanel::update( input_item_t *p_item ) ...@@ -263,6 +263,7 @@ void MetaPanel::update( input_item_t *p_item )
} }
art_cover->showArtUpdate( file ); art_cover->showArtUpdate( file );
art_cover->setItem( p_item );
} }
/** /**
......
...@@ -503,10 +503,12 @@ void SpeedControlWidget::resetRate() ...@@ -503,10 +503,12 @@ void SpeedControlWidget::resetRate()
} }
CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i ) 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 ); setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, askForUpdate() ); CONNECT( this, updateRequested(), this, askForUpdate() );
CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
this, showArtUpdate( input_item_t * ) );
setMinimumHeight( 128 ); setMinimumHeight( 128 );
setMinimumWidth( 128 ); setMinimumWidth( 128 );
...@@ -527,6 +529,14 @@ CoverArtLabel::~CoverArtLabel() ...@@ -527,6 +529,14 @@ CoverArtLabel::~CoverArtLabel()
QList< QAction* > artActions = actions(); QList< QAction* > artActions = actions();
foreach( QAction *act, artActions ) foreach( QAction *act, artActions )
removeAction( act ); 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 ) void CoverArtLabel::showArtUpdate( const QString& url )
...@@ -545,9 +555,20 @@ void CoverArtLabel::showArtUpdate( const QString& url ) ...@@ -545,9 +555,20 @@ void CoverArtLabel::showArtUpdate( const QString& url )
setPixmap( pix ); 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() void CoverArtLabel::askForUpdate()
{ {
THEMIM->getIM()->requestArtUpdate(); THEMIM->getIM()->requestArtUpdate( p_item );
} }
TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType ) TimeLabel::TimeLabel( intf_thread_t *_p_intf, TimeLabel::Display _displayType )
......
...@@ -228,6 +228,7 @@ class CoverArtLabel : public QLabel ...@@ -228,6 +228,7 @@ class CoverArtLabel : public QLabel
Q_OBJECT Q_OBJECT
public: public:
CoverArtLabel( QWidget *parent, intf_thread_t * ); CoverArtLabel( QWidget *parent, intf_thread_t * );
void setItem( input_item_t * );
virtual ~CoverArtLabel(); virtual ~CoverArtLabel();
protected: protected:
...@@ -241,6 +242,7 @@ protected: ...@@ -241,6 +242,7 @@ protected:
} }
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
input_item_t *p_item;
public slots: public slots:
void requestUpdate() { emit updateRequested(); } void requestUpdate() { emit updateRequested(); }
...@@ -249,6 +251,7 @@ public slots: ...@@ -249,6 +251,7 @@ public slots:
requestUpdate(); requestUpdate();
} }
void showArtUpdate( const QString& ); void showArtUpdate( const QString& );
void showArtUpdate( input_item_t * );
private slots: private slots:
void askForUpdate(); void askForUpdate();
......
...@@ -78,6 +78,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par ) ...@@ -78,6 +78,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
CONNECT( THEMIM->getIM(), artChanged( QString ), CONNECT( THEMIM->getIM(), artChanged( QString ),
art, showArtUpdate( const QString& ) ); art, showArtUpdate( const QString& ) );
CONNECT( THEMIM->getIM(), artChanged( input_item_t * ),
art, showArtUpdate( input_item_t * ) );
leftSplitter->addWidget( artContainer ); leftSplitter->addWidget( artContainer );
......
...@@ -628,17 +628,24 @@ void InputManager::UpdateCaching() ...@@ -628,17 +628,24 @@ void InputManager::UpdateCaching()
} }
} }
void InputManager::requestArtUpdate() void InputManager::requestArtUpdate( input_item_t *p_item )
{ {
if( hasInput() ) bool b_current_item = false;
{ if ( !p_item && hasInput() )
playlist_AskForArtEnqueue( pl_Get(p_intf), input_GetItem( p_input ) ); { /* 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, /* No input will signal the cover art to update,
* let's do it ourself */ * let's do it ourself */
UpdateArt(); if ( b_current_item )
UpdateArt();
else
emit artChanged( p_item );
} }
} }
...@@ -689,6 +696,7 @@ inline void InputManager::UpdateStats() ...@@ -689,6 +696,7 @@ inline void InputManager::UpdateStats()
inline void InputManager::UpdateMeta( input_item_t *p_item_ ) inline void InputManager::UpdateMeta( input_item_t *p_item_ )
{ {
emit metaChanged( p_item_ ); emit metaChanged( p_item_ );
emit artChanged( p_item_ );
} }
inline void InputManager::UpdateMeta() inline void InputManager::UpdateMeta()
......
...@@ -140,7 +140,7 @@ public: ...@@ -140,7 +140,7 @@ public:
bool hasAudio(); bool hasAudio();
bool hasVideo() { return hasInput() && b_video; } bool hasVideo() { return hasInput() && b_video; }
bool hasVisualisation(); bool hasVisualisation();
void requestArtUpdate(); void requestArtUpdate( input_item_t *p_item );
QString getName() { return oldName; } QString getName() { return oldName; }
static const QString decodeArtURL( input_item_t *p_item ); static const QString decodeArtURL( input_item_t *p_item );
...@@ -223,7 +223,8 @@ signals: ...@@ -223,7 +223,8 @@ signals:
void infoChanged( input_item_t* ); void infoChanged( input_item_t* );
void currentMetaChanged( input_item_t* ); void currentMetaChanged( input_item_t* );
void metaChanged( 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 /// Play/pause status
void playingStatusChanged( int ); void playingStatusChanged( int );
void recordingStateChanged( bool ); void recordingStateChanged( bool );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment