mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 09:19:41 +01:00
Make changes to audiocontrols fader to better handle transitions to/from default cover
This commit is contained in:
parent
8a85b8bbc6
commit
789a93dbe9
@ -271,10 +271,10 @@ AudioControls::setCover()
|
||||
{
|
||||
QPixmap cover;
|
||||
cover = m_currentTrack->toQuery()->cover( ui->coverImage->size() );
|
||||
ui->coverImage->setPixmap( cover );
|
||||
ui->coverImage->setPixmap( cover, false );
|
||||
}
|
||||
else
|
||||
ui->coverImage->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, ui->coverImage->size() ) );
|
||||
ui->coverImage->setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover, TomahawkUtils::ScaledCover, ui->coverImage->size() ), true );
|
||||
}
|
||||
|
||||
|
||||
@ -346,7 +346,7 @@ AudioControls::onPlaybackStopped()
|
||||
ui->ownerLabel->setText( "" );
|
||||
ui->timeLabel->setText( "" );
|
||||
ui->timeLeftLabel->setText( "" );
|
||||
ui->coverImage->setPixmap( QPixmap() );
|
||||
ui->coverImage->setPixmap( QPixmap(), true );
|
||||
ui->seekSlider->setVisible( false );
|
||||
m_sliderTimeLine.stop();
|
||||
m_sliderTimeLine.setCurrentTime( 0 );
|
||||
|
@ -44,6 +44,7 @@ FadingPixmap::FadingPixmap( QWidget* parent )
|
||||
, m_oldPixmap( QPixmap() )
|
||||
, m_fadePct( 100 )
|
||||
, m_startFrame( 0 )
|
||||
, m_isDefault( true )
|
||||
{
|
||||
// setCursor( Qt::PointingHandCursor );
|
||||
}
|
||||
@ -71,44 +72,59 @@ FadingPixmap::onAnimationStep( int frame )
|
||||
void
|
||||
FadingPixmap::onAnimationFinished()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_oldPixmap = QPixmap();
|
||||
repaint();
|
||||
|
||||
disconnect( stlInstance().data(), SIGNAL( frameChanged( int ) ), this, SLOT( onAnimationStep( int ) ) );
|
||||
|
||||
if ( m_pixmapQueue.count() )
|
||||
setPixmap( m_pixmapQueue.takeFirst() );
|
||||
QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_pixmapQueue.takeFirst() ), Q_ARG( bool, false ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FadingPixmap::setPixmap( const QPixmap& pixmap, bool clearQueue )
|
||||
FadingPixmap::setPixmap( const QPixmap& pixmap, bool isDefault )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "isDefault is " << ( isDefault ? "true" : "false" );
|
||||
if ( !m_oldPixmap.isNull() && !isDefault )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "adding pixmap to queue and clearing queue";
|
||||
m_pixmapQueue.clear();
|
||||
m_pixmapQueue << pixmap;
|
||||
if ( m_isDefault )
|
||||
QTimer::singleShot( 0, this, SLOT( onAnimationFinished() ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_isDefault && isDefault )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "moving from default to default, doing nothing";
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer( &ba );
|
||||
buffer.open( QIODevice::WriteOnly );
|
||||
pixmap.save( &buffer, "PNG" );
|
||||
QString newImageMd5 = TomahawkUtils::md5( buffer.data() );
|
||||
if ( m_oldImageMd5 == newImageMd5 )
|
||||
return;
|
||||
|
||||
m_oldImageMd5 = newImageMd5;
|
||||
|
||||
if ( !m_oldPixmap.isNull() )
|
||||
{
|
||||
if ( clearQueue )
|
||||
m_pixmapQueue.clear();
|
||||
|
||||
m_pixmapQueue << pixmap;
|
||||
tDebug() << Q_FUNC_INFO << "md5s match, doing nothing";
|
||||
return;
|
||||
}
|
||||
|
||||
m_oldImageMd5 = newImageMd5;
|
||||
|
||||
m_oldPixmap = m_pixmap;
|
||||
m_pixmap = pixmap;
|
||||
|
||||
stlInstance().data()->setUpdateInterval( 20 );
|
||||
m_startFrame = stlInstance().data()->currentFrame();
|
||||
m_fadePct = 0;
|
||||
m_isDefault = isDefault;
|
||||
tDebug() << Q_FUNC_INFO << "connecting to timeline";
|
||||
connect( stlInstance().data(), SIGNAL( frameChanged( int ) ), this, SLOT( onAnimationStep( int ) ) );
|
||||
}
|
||||
|
||||
@ -125,6 +141,7 @@ FadingPixmap::mouseReleaseEvent( QMouseEvent* event )
|
||||
void
|
||||
FadingPixmap::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
Q_UNUSED( event );
|
||||
|
||||
QPainter p( this );
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
virtual ~FadingPixmap();
|
||||
|
||||
public slots:
|
||||
virtual void setPixmap( const QPixmap& pixmap, bool clearQueue = true );
|
||||
virtual void setPixmap( const QPixmap& pixmap, bool isDefault );
|
||||
void onAnimationStep( int frame );
|
||||
|
||||
signals:
|
||||
@ -66,8 +66,8 @@ private:
|
||||
QList<QPixmap> m_pixmapQueue;
|
||||
|
||||
int m_fadePct;
|
||||
|
||||
int m_startFrame;
|
||||
bool m_isDefault;
|
||||
|
||||
static QWeakPointer< TomahawkUtils::SharedTimeLine > s_stlInstance;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user