From 789a93dbe9af1c34245c66bd7f4a84781c603757 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 8 Apr 2012 15:33:44 -0400 Subject: [PATCH 1/4] Make changes to audiocontrols fader to better handle transitions to/from default cover --- src/audiocontrols.cpp | 6 ++-- src/libtomahawk/widgets/FadingPixmap.cpp | 39 +++++++++++++++++------- src/libtomahawk/widgets/FadingPixmap.h | 4 +-- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index b53c5dd33..6a54e9144 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -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 ); diff --git a/src/libtomahawk/widgets/FadingPixmap.cpp b/src/libtomahawk/widgets/FadingPixmap.cpp index c21db431e..7b3cfe7d2 100644 --- a/src/libtomahawk/widgets/FadingPixmap.cpp +++ b/src/libtomahawk/widgets/FadingPixmap.cpp @@ -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 ); diff --git a/src/libtomahawk/widgets/FadingPixmap.h b/src/libtomahawk/widgets/FadingPixmap.h index 902eb4bab..f265afdd1 100644 --- a/src/libtomahawk/widgets/FadingPixmap.h +++ b/src/libtomahawk/widgets/FadingPixmap.h @@ -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 m_pixmapQueue; int m_fadePct; - int m_startFrame; + bool m_isDefault; static QWeakPointer< TomahawkUtils::SharedTimeLine > s_stlInstance; }; From 712805f5b0bf757f0654f1c2239c6a26cf0ded4d Mon Sep 17 00:00:00 2001 From: Tomahawk CI Date: Sun, 8 Apr 2012 22:16:06 +0000 Subject: [PATCH 2/4] Automatic merge of Transifex translations --- lang/tomahawk_bg.ts | 32 ++++++++++++++++---------------- lang/tomahawk_de.ts | 32 ++++++++++++++++---------------- lang/tomahawk_en.ts | 32 ++++++++++++++++---------------- lang/tomahawk_es.ts | 32 ++++++++++++++++---------------- lang/tomahawk_ja.ts | 32 ++++++++++++++++---------------- lang/tomahawk_pl.ts | 32 ++++++++++++++++---------------- lang/tomahawk_pt_BR.ts | 32 ++++++++++++++++---------------- lang/tomahawk_ru.ts | 32 ++++++++++++++++---------------- lang/tomahawk_sv.ts | 32 ++++++++++++++++---------------- 9 files changed, 144 insertions(+), 144 deletions(-) diff --git a/lang/tomahawk_bg.ts b/lang/tomahawk_bg.ts index 662e2c842..49fabc310 100644 --- a/lang/tomahawk_bg.ts +++ b/lang/tomahawk_bg.ts @@ -333,17 +333,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk е спрян - + Tomahawk is playing "%1" by %2%3. Tomahawk изпълнява "%1" от %2%3. - + on album %1 от албум %1 @@ -2311,27 +2311,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Най-актуални песни - + Loved Tracks Харесвани песни - + Hyped Tracks Песни слушани най-често - + Top Artists Най-слушани артисти - + Hyped Artists Артисти слушани най-често @@ -2389,37 +2389,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and и - + You Ти - + you ти - + and и - + %n other(s) %n друг%n други - + %1 people %1 хора - + loved this track хареса тази песен @@ -2485,7 +2485,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection Моята колекция diff --git a/lang/tomahawk_de.ts b/lang/tomahawk_de.ts index 310059e3b..b8063ff10 100644 --- a/lang/tomahawk_de.ts +++ b/lang/tomahawk_de.ts @@ -333,17 +333,17 @@ Denk dran: Erlaube das nur, wenn du dem Anderen vertraust und du die Rechte zum AudioEngine - + Tomahawk is stopped. Tomahawk ist gestoppt. - + Tomahawk is playing "%1" by %2%3. Tomahawk spielt "%1" von %2%3. - + on album %1 auf dem Album %1 @@ -2302,27 +2302,27 @@ Versuch die Filter anzupassen für neue Lieder. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Größte Hits - + Loved Tracks Lieblings Lieder - + Hyped Tracks Angesagte Stücke - + Top Artists - + Hyped Artists @@ -2380,37 +2380,37 @@ Versuch die Filter anzupassen für neue Lieder. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2476,7 +2476,7 @@ Versuch die Filter anzupassen für neue Lieder. TomahawkApp - + My Collection Meine Sammlung diff --git a/lang/tomahawk_en.ts b/lang/tomahawk_en.ts index 0370352c1..f2eb5b6fb 100644 --- a/lang/tomahawk_en.ts +++ b/lang/tomahawk_en.ts @@ -333,17 +333,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk is stopped. - + Tomahawk is playing "%1" by %2%3. Tomahawk is playing "%1" by %2%3. - + on album %1 on album %1 @@ -2309,27 +2309,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Top Tracks - + Loved Tracks Loved Tracks - + Hyped Tracks Hyped Tracks - + Top Artists Top Artists - + Hyped Artists Hyped Artists @@ -2387,37 +2387,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and and - + You You - + you you - + and and - + %n other(s) %n other%n others - + %1 people %1 people - + loved this track loved this track @@ -2483,7 +2483,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection My Collection diff --git a/lang/tomahawk_es.ts b/lang/tomahawk_es.ts index 430ce672b..d30c86425 100644 --- a/lang/tomahawk_es.ts +++ b/lang/tomahawk_es.ts @@ -331,17 +331,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk está parado. - + Tomahawk is playing "%1" by %2%3. Tomahawk está reproduciendo "%1" de %2%3. - + on album %1 @@ -2301,27 +2301,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Pistas más escuchadas - + Loved Tracks Pistas favoritas - + Hyped Tracks Pistas en alza - + Top Artists Artistas más escuchados - + Hyped Artists Artistas en alza @@ -2379,37 +2379,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2475,7 +2475,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection Mi colección diff --git a/lang/tomahawk_ja.ts b/lang/tomahawk_ja.ts index b0f0719b6..1a37a2084 100644 --- a/lang/tomahawk_ja.ts +++ b/lang/tomahawk_ja.ts @@ -331,17 +331,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawkは中止しています。 - + Tomahawk is playing "%1" by %2%3. - + on album %1 @@ -2298,27 +2298,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks - + Loved Tracks - + Hyped Tracks - + Top Artists - + Hyped Artists @@ -2376,37 +2376,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2472,7 +2472,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection diff --git a/lang/tomahawk_pl.ts b/lang/tomahawk_pl.ts index 9baf00d7a..9fceb0e0b 100644 --- a/lang/tomahawk_pl.ts +++ b/lang/tomahawk_pl.ts @@ -331,17 +331,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk jest zatrzymany. - + Tomahawk is playing "%1" by %2%3. Tomahawk odtwarza "%1" wykonawcy %2%3. - + on album %1 z albumu %1 @@ -2302,27 +2302,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks - + Loved Tracks - + Hyped Tracks - + Top Artists - + Hyped Artists @@ -2380,37 +2380,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2476,7 +2476,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection Moja Kolekcja diff --git a/lang/tomahawk_pt_BR.ts b/lang/tomahawk_pt_BR.ts index 22a940384..a5e9aaf1e 100644 --- a/lang/tomahawk_pt_BR.ts +++ b/lang/tomahawk_pt_BR.ts @@ -331,17 +331,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk está inativo. - + Tomahawk is playing "%1" by %2%3. Tomahawk está reproduzindo "%1" por %2%3. - + on album %1 @@ -2301,27 +2301,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Faixas principais - + Loved Tracks Faixas favoritas - + Hyped Tracks Faixas mais populares - + Top Artists Artistas principais - + Hyped Artists Artistas mais populares @@ -2379,37 +2379,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2475,7 +2475,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection Minha biblioteca diff --git a/lang/tomahawk_ru.ts b/lang/tomahawk_ru.ts index 67a27a561..04d9c9b0a 100644 --- a/lang/tomahawk_ru.ts +++ b/lang/tomahawk_ru.ts @@ -331,17 +331,17 @@ Remember: Only allow peers to connect if you trust who they are and if you have AudioEngine - + Tomahawk is stopped. Tomahawk остановлен. - + Tomahawk is playing "%1" by %2%3. Tomahawk играет "%1" by %2%3. - + on album %1 на альбом %1 @@ -2298,27 +2298,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks Топ песен - + Loved Tracks Любимые песни - + Hyped Tracks - + Top Artists Любимые исполнители - + Hyped Artists @@ -2376,37 +2376,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You Ты - + you ты - + and и - + %n other(s) - + %1 people - + loved this track любимый @@ -2472,7 +2472,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection Моя коллекция diff --git a/lang/tomahawk_sv.ts b/lang/tomahawk_sv.ts index 3814689d4..31368009f 100644 --- a/lang/tomahawk_sv.ts +++ b/lang/tomahawk_sv.ts @@ -333,17 +333,17 @@ Kom ihåg: Tillåt endast anslutning från klienter du litar på, och som har la AudioEngine - + Tomahawk is stopped. Tomahawk är stoppad. - + Tomahawk is playing "%1" by %2%3. Tomahawk spelar upp "%1" av %2%3. - + on album %1 på album %1 @@ -2299,27 +2299,27 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::InfoSystem::LastFmPlugin - + Top Tracks - + Loved Tracks - + Hyped Tracks - + Top Artists - + Hyped Artists @@ -2377,37 +2377,37 @@ Try tweaking the filters for a new set of songs to play. Tomahawk::Query - + and - + You - + you - + and - + %n other(s) - + %1 people - + loved this track @@ -2473,7 +2473,7 @@ Try tweaking the filters for a new set of songs to play. TomahawkApp - + My Collection From c6b5ea0380178df1ef84a016d1b79dce9a39db0a Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 8 Apr 2012 18:30:29 -0400 Subject: [PATCH 3/4] Covers aren't showing up now...but at least we're not pegging CPU. Will continue to fix in a bit --- src/libtomahawk/utils/PixmapDelegateFader.cpp | 14 ++++++-------- src/libtomahawk/widgets/FadingPixmap.cpp | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libtomahawk/utils/PixmapDelegateFader.cpp b/src/libtomahawk/utils/PixmapDelegateFader.cpp index 5b4637be8..c1c34cd53 100644 --- a/src/libtomahawk/utils/PixmapDelegateFader.cpp +++ b/src/libtomahawk/utils/PixmapDelegateFader.cpp @@ -105,8 +105,6 @@ PixmapDelegateFader::init() { m_current = QPixmap( m_size ); m_current.fill( Qt::transparent ); - - stlInstance().data()->setUpdateInterval( 20 ); if ( m_currentReference.isNull() ) { @@ -135,7 +133,7 @@ PixmapDelegateFader::albumChanged() if ( m_album.isNull() ) return; - setPixmap( m_album->cover( m_size ) ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_album->cover( m_size ) ) ); } void @@ -144,7 +142,7 @@ PixmapDelegateFader::artistChanged() if ( m_artist.isNull() ) return; - setPixmap( m_artist->cover( m_size ) ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_artist->cover( m_size ) ) ); } @@ -154,7 +152,7 @@ PixmapDelegateFader::trackChanged() if ( m_track.isNull() ) return; - setPixmap( m_track->cover( m_size ) ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_track->cover( m_size ) ) ); } @@ -179,10 +177,11 @@ PixmapDelegateFader::setPixmap( const QPixmap& pixmap ) m_pixmapQueue.enqueue( pixmap ); return; } - + m_oldReference = m_currentReference; m_currentReference = pixmap; + stlInstance().data()->setUpdateInterval( 20 ); m_startFrame = stlInstance().data()->currentFrame(); m_connectedToStl = true; m_fadePct = 0; @@ -270,13 +269,12 @@ void PixmapDelegateFader::onAnimationFinished() { m_oldReference = QPixmap(); - onAnimationStep( INT_MAX ); m_connectedToStl = false; disconnect( stlInstance().data(), SIGNAL( frameChanged( int ) ), this, SLOT( onAnimationStep( int ) ) ); if ( !m_pixmapQueue.isEmpty() ) - setPixmap( m_pixmapQueue.dequeue() ); + QMetaObject::invokeMethod( this, "setPixmap", Qt::QueuedConnection, Q_ARG( QPixmap, m_pixmapQueue.dequeue() ) ); } diff --git a/src/libtomahawk/widgets/FadingPixmap.cpp b/src/libtomahawk/widgets/FadingPixmap.cpp index 7b3cfe7d2..e6054751b 100644 --- a/src/libtomahawk/widgets/FadingPixmap.cpp +++ b/src/libtomahawk/widgets/FadingPixmap.cpp @@ -141,7 +141,6 @@ FadingPixmap::mouseReleaseEvent( QMouseEvent* event ) void FadingPixmap::paintEvent( QPaintEvent* event ) { - tDebug() << Q_FUNC_INFO; Q_UNUSED( event ); QPainter p( this ); From 41a3cea05e0f6e00ce925ccfabd91559196d85fc Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sun, 8 Apr 2012 19:30:28 -0400 Subject: [PATCH 4/4] Fix CPU usage due to fader --- src/libtomahawk/utils/PixmapDelegateFader.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libtomahawk/utils/PixmapDelegateFader.h b/src/libtomahawk/utils/PixmapDelegateFader.h index b477d24fa..4026b93db 100644 --- a/src/libtomahawk/utils/PixmapDelegateFader.h +++ b/src/libtomahawk/utils/PixmapDelegateFader.h @@ -50,9 +50,7 @@ public: PixmapDelegateFader( const query_ptr& track, const QSize& size, TomahawkUtils::ImageMode mode = TomahawkUtils::Original, bool forceLoad = true ); virtual ~PixmapDelegateFader(); - - void setPixmap( const QPixmap& pixmap ); - + QPixmap currentPixmap() const; signals: @@ -65,6 +63,8 @@ private slots: void onAnimationStep( int ); void onAnimationFinished(); + void setPixmap( const QPixmap& pixmap ); + private: void init();