return;
}
- // Avoid flicker with static pixmap if an animated image is running
- if (m_animatedImage && m_animatedImage->state() == QMovie::Running) {
- return;
- }
-
if ((m_transition != NoTransition) && (m_animation.state() == QTimeLine::Running)) {
m_pendingPixmaps.enqueue(pixmap);
if (m_pendingPixmaps.count() > 5) {
m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap;
m_pixmap = pixmap;
+
+ // Avoid flicker with static pixmap if an animated image is running
+ if (m_animatedImage && m_animatedImage->state() == QMovie::Running) {
+ return;
+ }
+
update();
const bool animateTransition = (m_transition != NoTransition) && (m_pixmap.size() != m_oldPixmap.size());
// If there is no transition animation but an animatedImage
// and it is not already running, start animating now
if (m_animatedImage->state() != QMovie::Running) {
- m_animatedImage->setScaledSize(m_pixmap.size());
m_animatedImage->start();
}
}
}
if (m_animatedImage->fileName() != fileName) {
- m_animatedImage->stop();
m_animatedImage->setFileName(fileName);
}
const bool useOldPixmap = (m_transition == SizeTransition) && (m_oldPixmap.width() > m_pixmap.width());
const QPixmap &largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap;
if (!largePixmap.isNull()) {
- const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, scaledHeight, Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, scaledHeight, Qt::IgnoreAspectRatio, Qt::FastTransformation);
+ scaledPixmap.setDevicePixelRatio(devicePixelRatioF());
style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, scaledPixmap);
}
Q_ASSERT(m_animatedImage);
m_pixmap = m_animatedImage->currentPixmap();
+ if (m_pixmap.width() > m_sizeHint.width() || m_pixmap.height() > m_sizeHint.height()) {
+ m_pixmap = m_pixmap.scaled(m_sizeHint, Qt::KeepAspectRatio);
+ m_animatedImage->setScaledSize(m_pixmap.size());
+ }
update();
}
if (m_hasAnimatedImage) {
m_animatedImage->stop();
m_hasAnimatedImage = false;
+ delete m_animatedImage;
+ m_animatedImage = nullptr;
}
}
return QMovie::supportedFormats().contains(format);
});
}
+
+#include "moc_pixmapviewer.cpp"