From 2a3f1badca2a5f21bfb62022d3ff435c7e74cca7 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 23 Oct 2025 16:26:12 +0200 Subject: Don't do an animation on the information panel The information panel does a scaling animation when switching between files. It does not completely make sense because the pixmap passes immediately to the new one, it just animates the scale between the two which just looks glitchy. the effect is particularly visible when switching between a normal folder and one that has thumbnails overlayed on top: the two folder icons appear the same size, but still a weird animation occurs when going from one to another. Also, the rest of the text of the information panel does change immediately. ideally perhaps some sort of fading animation could make sense, but only if everything in that panel faded together, only the icon fading with the text that is already the "new" one doesn't make much sense BUG:503036 --- src/panels/information/pixmapviewer.cpp | 58 ++------------------------------- src/panels/information/pixmapviewer.h | 28 +--------------- 2 files changed, 4 insertions(+), 82 deletions(-) (limited to 'src/panels/information') diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp index b18c9e64e..9ac9bd253 100644 --- a/src/panels/information/pixmapviewer.cpp +++ b/src/panels/information/pixmapviewer.cpp @@ -13,24 +13,14 @@ #include #include -PixmapViewer::PixmapViewer(QWidget *parent, Transition transition) +PixmapViewer::PixmapViewer(QWidget *parent) : QWidget(parent) , m_animatedImage(nullptr) - , m_transition(transition) - , m_animationStep(0) , m_sizeHint() , m_hasAnimatedImage(false) { setMinimumWidth(KIconLoader::SizeEnormous); setMinimumHeight(KIconLoader::SizeEnormous); - - m_animation.setDuration(150); - m_animation.setEasingCurve(QEasingCurve::Linear); - - if (m_transition != NoTransition) { - connect(&m_animation, &QTimeLine::valueChanged, this, QOverload<>::of(&PixmapViewer::update)); - connect(&m_animation, &QTimeLine::finished, this, &PixmapViewer::checkPendingPixmaps); - } } PixmapViewer::~PixmapViewer() @@ -43,16 +33,6 @@ void PixmapViewer::setPixmap(const QPixmap &pixmap) return; } - if ((m_transition != NoTransition) && (m_animation.state() == QTimeLine::Running)) { - m_pendingPixmaps.enqueue(pixmap); - if (m_pendingPixmaps.count() > 5) { - // don't queue more than 5 pixmaps - m_pendingPixmaps.takeFirst(); - } - return; - } - - m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap; m_pixmap = pixmap; // Avoid flicker with static pixmap if an animated image is running @@ -62,10 +42,7 @@ void PixmapViewer::setPixmap(const QPixmap &pixmap) update(); - const bool animateTransition = (m_transition != NoTransition) && (m_pixmap.size() != m_oldPixmap.size()); - if (animateTransition) { - m_animation.start(); - } else if (m_hasAnimatedImage) { + if (m_hasAnimatedImage) { // If there is no transition animation but an animatedImage // and it is not already running, start animating now if (m_animatedImage->state() != QMovie::Running) { @@ -117,40 +94,11 @@ void PixmapViewer::paintEvent(QPaintEvent *event) QPainter painter(this); - if (m_transition != NoTransition || (m_hasAnimatedImage && m_animatedImage->state() != QMovie::Running)) { - const float value = m_animation.currentValue(); - const int scaledWidth = static_cast((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value)); - const int scaledHeight = static_cast((m_oldPixmap.height() * (1.0 - value)) + (m_pixmap.height() * value)); - - const bool useOldPixmap = (m_transition == SizeTransition) && (m_oldPixmap.width() > m_pixmap.width()); - const QPixmap &largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap; - if (!largePixmap.isNull()) { - QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, scaledHeight, Qt::IgnoreAspectRatio, Qt::FastTransformation); - scaledPixmap.setDevicePixelRatio(devicePixelRatioF()); - - style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, scaledPixmap); - } - } else if (!m_pixmap.isNull()) { + if (!m_pixmap.isNull()) { style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, m_pixmap); } } -void PixmapViewer::checkPendingPixmaps() -{ - if (!m_pendingPixmaps.isEmpty()) { - QPixmap pixmap = m_pendingPixmaps.dequeue(); - m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap; - m_pixmap = pixmap; - update(); - m_animation.start(); - } else if (m_hasAnimatedImage) { - m_animatedImage->setScaledSize(m_pixmap.size()); - m_animatedImage->start(); - } else { - m_oldPixmap = m_pixmap; - } -} - void PixmapViewer::updateAnimatedImageFrame() { Q_ASSERT(m_animatedImage); diff --git a/src/panels/information/pixmapviewer.h b/src/panels/information/pixmapviewer.h index 32c06fe15..a71ce6677 100644 --- a/src/panels/information/pixmapviewer.h +++ b/src/panels/information/pixmapviewer.h @@ -26,27 +26,7 @@ class PixmapViewer : public QWidget Q_OBJECT public: - enum Transition { - /** No transition is done when the pixmap is changed. */ - NoTransition, - - /** - * The old pixmap is replaced by the new pixmap and the size is - * adjusted smoothly to the size of the new pixmap. - */ - DefaultTransition, - - /** - * If the old pixmap and the new pixmap have the same content, but - * a different size it is recommended to use Transition::SizeTransition - * instead of Transition::DefaultTransition. In this case it is assured - * that the larger pixmap is used for downscaling, which leads - * to an improved scaling output. - */ - SizeTransition - }; - - explicit PixmapViewer(QWidget *parent, Transition transition = DefaultTransition); + explicit PixmapViewer(QWidget *parent); ~PixmapViewer() override; void setPixmap(const QPixmap &pixmap); @@ -73,17 +53,11 @@ protected: void paintEvent(QPaintEvent *event) override; private Q_SLOTS: - void checkPendingPixmaps(); void updateAnimatedImageFrame(); private: QPixmap m_pixmap; - QPixmap m_oldPixmap; QMovie *m_animatedImage; - QQueue m_pendingPixmaps; - QTimeLine m_animation; - Transition m_transition; - int m_animationStep; QSize m_sizeHint; bool m_hasAnimatedImage; }; -- cgit v1.3