]> cloud.milkyroute.net Git - dolphin.git/commitdiff
panels/information: Fix preview size for animated images
authorIsmael Asensio <isma.af@gmail.com>
Sun, 6 Jul 2025 13:08:48 +0000 (15:08 +0200)
committerIsmael Asensio <isma.af@gmail.com>
Sun, 13 Jul 2025 10:24:01 +0000 (12:24 +0200)
If the image size is larger than the available size, we need to scale
so it fits into the preview

src/panels/information/pixmapviewer.cpp

index 2767c87ea6ef8a6c7f542ba01a2537273bd32b10..b18c9e64ef4c0522ccd062274c431ef97aacce9c 100644 (file)
@@ -144,6 +144,7 @@ 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;
@@ -155,6 +156,10 @@ void PixmapViewer::updateAnimatedImageFrame()
     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();
 }