- QPainter painter;
- painter.begin(this);
- const int x = (width() - m_pixmap.width()) / 2;
- const int y = (height() - m_pixmap.height()) / 2;
-
- if ( !m_nextPixmap.isNull() )
- {
- const int nextPixmapX = (width() - m_nextPixmap.width()) / 2;
- const int nextPixmapY = (height() - m_nextPixmap.height()) / 2;
-
- painter.setOpacity( 1 - m_animation.currentValue() );
- painter.drawPixmap(x, y, m_pixmap);
- painter.setOpacity( m_animation.currentValue() );
- painter.drawPixmap(nextPixmapX,nextPixmapY,m_nextPixmap);
- }
- else
- {
+ QPainter painter(this);
+
+ if (m_transition != NoTransition) {
+ const float value = m_animation.currentValue();
+ const int scaledWidth = static_cast<int>((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value));
+ const int scaledHeight = static_cast<int>((m_oldPixmap.height() * (1.0 - value)) + (m_pixmap.height() * value));
+
+ const int x = (width() - scaledWidth ) / 2;
+ const int y = (height() - scaledHeight) / 2;
+
+ const bool useOldPixmap = (m_transition == SizeTransition) &&
+ (m_oldPixmap.width() > m_pixmap.width());
+ const QPixmap& largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap;
+ const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth,
+ scaledHeight,
+ Qt::IgnoreAspectRatio,
+ Qt::FastTransformation);
+ painter.drawPixmap(x, y, scaledPixmap);
+ } else {
+ const int x = (width() - m_pixmap.width() ) / 2;
+ const int y = (height() - m_pixmap.height()) / 2;