[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/multimedia/amarok/src/context/applets/currenttrack
From: Michaƫl Todorovic <michael.todorovic () free ! fr>
Date: 2008-02-14 15:18:47
Message-ID: 1203002327.266367.24555.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 774984 by mtodorovic:
Fixes a blur problem when resizing covers in currentTrack applet
M +25 -22 CurrentTrack.cpp
M +3 -0 CurrentTrack.h
--- trunk/extragear/multimedia/amarok/src/context/applets/currenttrack/CurrentTrack.cpp \
#774983:774984 @@ -162,18 +162,9 @@
m_scoreLabel->scale( scaleFactor, scaleFactor );
m_numPlayedLabel->scale( scaleFactor, scaleFactor );
m_playedLastLabel->scale( scaleFactor, scaleFactor );
-
+ resizeCover(m_bigCover);
- QPixmap cover = m_albumCover->pixmap();
- if( !cover.isNull() )
- {
- debug() << "getting album rect:" << m_theme->elementRect( "albumart" \
).size();
- cover = cover.scaledToWidth( qMin( m_theme->elementRect( "albumart" \
).size().width(),
- m_theme->elementRect( \
"albumart" ).size().height() )
- , \
Qt::SmoothTransformation );
- m_albumCover->setPixmap( cover );
- }
debug() << "changing pixmap size from " << m_albumCover->pixmap().width() << " \
to " << m_theme->elementRect( "albumart" ).size().width();
dataEngine( "amarok-current" )->setProperty( "coverWidth", m_theme->elementRect( \
"albumart" ).size().width() ); @@ -198,19 +189,12 @@
m_playedLast->setText( Amarok::verboseTimeSince( currentInfo[ \
Meta::Field::LAST_PLAYED ].toUInt() ) );
m_numPlayed->setText( currentInfo[ Meta::Field::PLAYCOUNT ].toString() );
- // scale pixmap on demand
- QPixmap cover = data[ "albumart" ].value<QPixmap>();
- if( !cover.isNull() )
+ //scale pixmap on demand
+ //store the big cover : avoid blur when resizing the applet
+ m_bigCover = data[ "albumart" ].value<QPixmap>();
+
+ if(!resizeCover(m_bigCover))
{
- QSize rectSize = m_theme->elementRect( "albumart" ).size();
- //for some reason the rectangle is not square
- int size = qMin( rectSize.width(), rectSize.height() );
- debug() << "changing pixmap size from " << cover.width() << " to " << size;
- cover = cover.scaledToWidth( size, Qt::SmoothTransformation );
- m_albumCover->setPixmap( cover );
- }
- else
- {
warning() << "album cover of current track is null, did you forget to call \
Meta::Album::image?"; }
}
@@ -338,6 +322,25 @@
return text;
}
+bool CurrentTrack::resizeCover(QPixmap cover){
+ if( !cover.isNull() )
+ {
+ QSize rectSize = m_theme->elementRect( "albumart" ).size();
+ debug() << "getting album rect:" << rectSize;
+ int size = qMin( rectSize.width(), rectSize.height() );
+ qreal pixmapRatio = (qreal)cover.width()/size;
+ if(cover.height()/pixmapRatio > rectSize.height())
+ cover = cover.scaledToHeight( size, Qt::SmoothTransformation );
+ else
+ cover = cover.scaledToWidth( size, Qt::SmoothTransformation );
+ m_albumCover->setPixmap( cover );
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
#include "CurrentTrack.moc"
--- trunk/extragear/multimedia/amarok/src/context/applets/currenttrack/CurrentTrack.h \
#774983:774984 @@ -81,7 +81,10 @@
int m_trackLength;
QGraphicsPixmapItem* m_albumCover;
+ QPixmap m_bigCover;
+ bool resizeCover(QPixmap cover);
+
};
K_EXPORT_AMAROK_APPLET( currenttrack, CurrentTrack )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic