Commit 96fe985a authored by François Cartegnie's avatar François 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 )
}
art_cover->showArtUpdate( file );
art_cover->setItem( p_item );
}
/**
......
......@@ -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 )
......
......@@ -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();
......
......@@ -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 );
......
......@@ -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()
......
......@@ -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 );
......
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