From: Méven Car Date: Wed, 15 Jan 2025 20:15:42 +0000 (+0100) Subject: InformationPanel: prevent animated images from glitching X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/9a44aad838e111175b57a7ff14a9f6d2f44c5b65 InformationPanel: prevent animated images from glitching And show them in their actual pixel density. --- diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp index 11c13e348..c870e9c3e 100644 --- a/src/panels/information/pixmapviewer.cpp +++ b/src/panels/information/pixmapviewer.cpp @@ -44,8 +44,11 @@ void PixmapViewer::setPixmap(const QPixmap &pixmap) } // Avoid flicker with static pixmap if an animated image is running - if (m_animatedImage && m_animatedImage->state() == QMovie::Running) { - return; + if (m_animatedImage) { + m_animatedImage->setScaledSize(pixmap.size()); + if (m_animatedImage->state() == QMovie::Running) { + return; + } } if ((m_transition != NoTransition) && (m_animation.state() == QTimeLine::Running)) { @@ -68,7 +71,6 @@ void PixmapViewer::setPixmap(const QPixmap &pixmap) // 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(); } } @@ -126,7 +128,8 @@ void PixmapViewer::paintEvent(QPaintEvent *event) 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); } @@ -144,7 +147,6 @@ void PixmapViewer::checkPendingPixmaps() update(); m_animation.start(); } else if (m_hasAnimatedImage) { - m_animatedImage->setScaledSize(m_pixmap.size()); m_animatedImage->start(); } else { m_oldPixmap = m_pixmap;