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