mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
* Fixed crash and show hover state for album items again.
This commit is contained in:
parent
c9704cbe64
commit
eb87952ce5
@ -65,6 +65,9 @@ AlbumPlaylistInterface::siblingItem( int itemsAway )
|
||||
if ( p >= m_queries.count() )
|
||||
return Tomahawk::result_ptr();
|
||||
|
||||
if ( !m_queries.at( p )->numResults() )
|
||||
return siblingItem( itemsAway + 1 );
|
||||
|
||||
m_currentTrack = p;
|
||||
m_currentItem = m_queries.at( p )->results().first();
|
||||
return m_currentItem;
|
||||
|
@ -160,7 +160,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
|
||||
painter->drawPixmap( r, cover.scaled( r.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
|
||||
|
||||
/* if ( m_hoverIndex == index )
|
||||
if ( m_hoverIndex == index )
|
||||
{
|
||||
painter->save();
|
||||
|
||||
@ -168,15 +168,9 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
painter->setBrush( QColor( 33, 33, 33 ) );
|
||||
painter->setOpacity( 0.5 );
|
||||
painter->drawRect( r );
|
||||
|
||||
painter->setOpacity( 1.0 );
|
||||
QPixmap playButton = QPixmap( RESPATH "images/play-rest.png" );
|
||||
int delta = ( r.width() - playButton.width() ) / 2;
|
||||
m_playButtonRect = r.adjusted( delta, delta, -delta, -delta );
|
||||
painter->drawPixmap( m_playButtonRect, playButton );
|
||||
|
||||
painter->restore();
|
||||
}*/
|
||||
}
|
||||
|
||||
painter->save();
|
||||
|
||||
@ -257,31 +251,31 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
||||
void
|
||||
AlbumItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
|
||||
{
|
||||
AlbumItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( item )
|
||||
{
|
||||
if ( !item->query().isNull() )
|
||||
AudioEngine::instance()->playItem( Tomahawk::playlistinterface_ptr(), item->query() );
|
||||
else if ( !item->album().isNull() )
|
||||
AudioEngine::instance()->playItem( item->album() );
|
||||
else if ( !item->artist().isNull() )
|
||||
AudioEngine::instance()->playItem( item->artist() );
|
||||
}
|
||||
|
||||
QPoint pos = m_button[ index ]->pos();
|
||||
foreach ( ImageButton* button, m_button )
|
||||
button->deleteLater();
|
||||
m_button.clear();
|
||||
|
||||
_detail::Closure* closure = NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ),
|
||||
const_cast<AlbumItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
|
||||
|
||||
AnimatedSpinner* spinner = new AnimatedSpinner( m_view );
|
||||
spinner->setAutoCenter( false );
|
||||
spinner->fadeIn();
|
||||
spinner->move( pos );
|
||||
|
||||
m_subWidgets[ index ] = spinner;
|
||||
|
||||
AlbumItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
||||
if ( item )
|
||||
{
|
||||
_detail::Closure* closure = NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ),
|
||||
const_cast<AlbumItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
|
||||
|
||||
if ( !item->query().isNull() )
|
||||
AudioEngine::instance()->playItem( Tomahawk::playlistinterface_ptr(), item->query() );
|
||||
else if ( !item->album().isNull() )
|
||||
AudioEngine::instance()->playItem( item->album() );
|
||||
else if ( !item->artist().isNull() )
|
||||
AudioEngine::instance()->playItem( item->artist() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user