mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-16 02:54:33 +02:00
Fade out spinner and update playstate on cover button
This commit is contained in:
@@ -257,6 +257,10 @@ GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
|
|||||||
m_spinner[ index ] = spinner;
|
m_spinner[ index ] = spinner;
|
||||||
|
|
||||||
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
||||||
|
|
||||||
|
NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
|
||||||
|
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
|
||||||
|
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
if ( !item->query().isNull() )
|
if ( !item->query().isNull() )
|
||||||
@@ -455,9 +459,55 @@ GridItemDelegate::onPlaybackFinished()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GridItemDelegate::onPlayPauseHover( const QPersistentModelIndex& index )
|
||||||
|
{
|
||||||
|
if( m_pauseButton.contains( index ) )
|
||||||
|
{
|
||||||
|
updatePlayPauseButton( m_pauseButton[ index ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GridItemDelegate::updatePlayPauseButton( ImageButton* button, bool setState )
|
||||||
|
{
|
||||||
|
if ( button )
|
||||||
|
{
|
||||||
|
if ( button->property( "paused" ).toBool() )
|
||||||
|
{
|
||||||
|
button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
|
||||||
|
button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PauseButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButton, TomahawkUtils::Original, QSize( 48, 48 ) ) );
|
||||||
|
button->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::PlayButtonPressed, TomahawkUtils::Original, QSize( 48, 48 ) ), QIcon::Off, QIcon::Active );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( setState )
|
||||||
|
button->setProperty( "paused", !button->property( "paused" ).toBool() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
GridItemDelegate::onPlayPausedClicked()
|
||||||
|
{
|
||||||
|
ImageButton* button = qobject_cast< ImageButton* >( QObject::sender() );
|
||||||
|
updatePlayPauseButton( button, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GridItemDelegate::onPlaybackStarted( const QPersistentModelIndex& index )
|
GridItemDelegate::onPlaybackStarted( const QPersistentModelIndex& index )
|
||||||
{
|
{
|
||||||
|
if( m_spinner.contains( index ) )
|
||||||
|
{
|
||||||
|
LoadingSpinner* spinner = static_cast<LoadingSpinner*>(m_spinner[ index ]);
|
||||||
|
spinner->fadeOut();
|
||||||
|
}
|
||||||
|
|
||||||
clearButtons();
|
clearButtons();
|
||||||
createPauseButton( index );
|
createPauseButton( index );
|
||||||
|
|
||||||
@@ -504,9 +554,11 @@ GridItemDelegate::createPauseButton( const QPersistentModelIndex& index )
|
|||||||
button->setContentsMargins( 0, 0, 0, 0 );
|
button->setContentsMargins( 0, 0, 0, 0 );
|
||||||
button->setFocusPolicy( Qt::NoFocus );
|
button->setFocusPolicy( Qt::NoFocus );
|
||||||
button->installEventFilter( this );
|
button->installEventFilter( this );
|
||||||
|
button->setProperty( "paused", false );
|
||||||
button->show();
|
button->show();
|
||||||
|
|
||||||
connect( button, SIGNAL( clicked( bool ) ), AudioEngine::instance(), SLOT( playPause() ) );
|
connect( button, SIGNAL( clicked( bool ) ), AudioEngine::instance(), SLOT( playPause() ) );
|
||||||
|
connect( button, SIGNAL( clicked( bool ) ), this, SLOT( onPlayPausedClicked() ) );
|
||||||
|
|
||||||
m_pauseButton[ index ] = button;
|
m_pauseButton[ index ] = button;
|
||||||
}
|
}
|
||||||
|
@@ -68,6 +68,7 @@ private slots:
|
|||||||
|
|
||||||
void onViewChanged();
|
void onViewChanged();
|
||||||
void onPlaybackStarted( const QPersistentModelIndex& index );
|
void onPlaybackStarted( const QPersistentModelIndex& index );
|
||||||
|
|
||||||
void onPlaybackFinished();
|
void onPlaybackFinished();
|
||||||
|
|
||||||
void onPlayClicked( const QPersistentModelIndex& index );
|
void onPlayClicked( const QPersistentModelIndex& index );
|
||||||
@@ -75,6 +76,10 @@ private slots:
|
|||||||
void fadingFrameChanged( const QPersistentModelIndex& );
|
void fadingFrameChanged( const QPersistentModelIndex& );
|
||||||
void fadingFrameFinished( const QPersistentModelIndex& );
|
void fadingFrameFinished( const QPersistentModelIndex& );
|
||||||
|
|
||||||
|
void updatePlayPauseButton(ImageButton* button , bool setState = false );
|
||||||
|
void onPlayPauseHover( const QPersistentModelIndex& index );
|
||||||
|
void onPlayPausedClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimeLine* createTimeline( QTimeLine::Direction direction );
|
QTimeLine* createTimeline( QTimeLine::Direction direction );
|
||||||
void createPauseButton( const QPersistentModelIndex& index );
|
void createPauseButton( const QPersistentModelIndex& index );
|
||||||
|
Reference in New Issue
Block a user