backgroundLayout->setColumnStretch( 0, 1 );
backgroundLayout->setColumnStretch( 2, 1 );
- CONNECT( THEMIM->getIM(), artChanged( input_item_t* ),
- this, updateArt( input_item_t* ) );
+ CONNECT( THEMIM->getIM(), artChanged( QString ),
+ this, updateArt( QString ) );
}
BackgroundWidget::~BackgroundWidget()
label->show();
}
-void BackgroundWidget::updateArt( input_item_t *p_item )
+void BackgroundWidget::updateArt( QString url )
{
- QString url;
- if( p_item )
- {
- char *psz_art = input_item_GetArtURL( p_item );
- url = psz_art;
- free( psz_art );
- }
-
if( url.isEmpty() )
{
if( QDate::currentDate().dayOfYear() >= 354 )
}
else
{
- url = url.replace( "file://", QString("" ) );
- /* Taglib seems to define a attachment://, It won't work yet */
- url = url.replace( "attachment://", QString("" ) );
label->setPixmap( QPixmap( url ) );
}
}
THEMIM->getIM()->setRate( INPUT_RATE_DEFAULT );
}
-static int downloadCoverCallback( vlc_object_t *p_this,
- char const *psz_var,
- vlc_value_t oldvar, vlc_value_t newvar,
- void *data )
-{
- if( !strcmp( psz_var, "item-change" ) )
- {
- CoverArtLabel *art = static_cast< CoverArtLabel* >( data );
- if( art )
- art->requestUpdate();
- }
- return VLC_SUCCESS;
-}
-
-CoverArtLabel::CoverArtLabel( QWidget *parent,
- vlc_object_t *_p_this,
- input_item_t *_p_input )
- : QLabel( parent ), p_this( _p_this), p_input( _p_input ), prevArt()
+CoverArtLabel::CoverArtLabel( QWidget *parent, intf_thread_t *_p_i )
+ : QLabel( parent ), p_intf( _p_i )
{
setContextMenuPolicy( Qt::ActionsContextMenu );
CONNECT( this, updateRequested(), this, doUpdate() );
-
- playlist_t *p_playlist = pl_Hold( p_this );
- var_AddCallback( p_playlist, "item-change",
- downloadCoverCallback, this );
- pl_Release( p_this );
+ CONNECT( THEMIM->getIM(), artChanged( QString ),
+ this, doUpdate( QString ) );
setMinimumHeight( 128 );
setMinimumWidth( 128 );
doUpdate();
}
-CoverArtLabel::~CoverArtLabel()
-{
- playlist_t *p_playlist = pl_Hold( p_this );
- var_DelCallback( p_playlist, "item-change", downloadCoverCallback, this );
- pl_Release( p_this );
-
- if( p_input )
- vlc_gc_decref( p_input );
-};
-
-void CoverArtLabel::downloadCover()
+void CoverArtLabel::doUpdate( QString url )
{
- if( p_input )
+ QPixmap pix;
+ if( !url.isEmpty() && pix.load( url ) )
{
- playlist_t *p_playlist = pl_Hold( p_this );
- playlist_AskForArtEnqueue( p_playlist, p_input, pl_Unlocked );
- pl_Release( p_this );
+ setPixmap( pix );
+ }
+ else
+ {
+ setPixmap( QPixmap( ":/noart.png" ) );
}
}
void CoverArtLabel::doUpdate()
{
- if( !p_input )
- {
- setPixmap( QPixmap( ":/noart.png" ) );
- QList< QAction* > artActions = actions();
- if( !artActions.isEmpty() )
- foreach( QAction *act, artActions )
- removeAction( act );
- prevArt = "";
- }
- else
- {
- char *psz_meta = input_item_GetArtURL( p_input );
- if( psz_meta && !strncmp( psz_meta, "file://", 7 ) )
- {
- QString artUrl = qfu( psz_meta ).replace( "file://", "" );
- if( artUrl != prevArt )
- {
- QPixmap pix;
- if( pix.load( artUrl ) )
- setPixmap( pix );
- else
- {
- msg_Dbg( p_this, "Qt could not load image '%s'",
- qtu( artUrl ) );
- setPixmap( QPixmap( ":/noart.png" ) );
- }
- }
- QList< QAction* > artActions = actions();
- if( !artActions.isEmpty() )
- {
- foreach( QAction *act, artActions )
- removeAction( act );
- }
- prevArt = artUrl;
- }
- else
- {
- if( prevArt != "" )
- setPixmap( QPixmap( ":/noart.png" ) );
- prevArt = "";
- QList< QAction* > artActions = actions();
- if( artActions.isEmpty() )
- {
- QAction *action = new QAction( qtr( "Download cover art" ),
- this );
- addAction( action );
- CONNECT( action, triggered(),
- this, downloadCover() );
- }
- }
- free( psz_meta );
- }
+ THEMIM->getIM()->requestArtUpdate();
}
TimeLabel::TimeLabel( intf_thread_t *_p_intf ) :QLabel(), p_intf( _p_intf )
case ItemChanged_Type:
UpdateStatus();
// UpdateName();
- // UpdateArt();
+ UpdateArt();
break;
case ItemStateChanged_Type:
// TODO: Fusion with above state
}
}
-inline void InputManager::UpdateArt()
+void InputManager::requestArtUpdate()
{
+ if( hasInput() )
+ {
+ playlist_t *p_playlist = pl_Hold( p_intf );
+ playlist_AskForArtEnqueue( p_playlist, input_GetItem( p_input ), pl_Unlocked );
+ pl_Release( p_intf );
+ }
+}
+
+void InputManager::UpdateArt()
+{
+ QString url;
+
+ if( hasInput() )
+ {
+ char *psz_art = input_item_GetArtURL( input_GetItem( p_input ) );
+ url = psz_art;
+ free( psz_art );
+ }
+ url = url.replace( "file://", QString("" ) );
+ /* Taglib seems to define a attachment://, It won't work yet */
+ url = url.replace( "attachment://", QString("" ) );
/* Update Art meta */
- emit artChanged( input_GetItem( p_input ) );
+ emit artChanged( url );
}
inline void InputManager::UpdateStats()