diff options
| author | Marco Martin <[email protected]> | 2025-10-23 16:26:12 +0200 |
|---|---|---|
| committer | Marco Martin <[email protected]> | 2025-10-23 16:26:12 +0200 |
| commit | 2a3f1badca2a5f21bfb62022d3ff435c7e74cca7 (patch) | |
| tree | 2f0e553ffc04fd1335d3786be33e459e8a7c2023 /src/panels/information/pixmapviewer.cpp | |
| parent | c7dd75500a1796c1d938be4d9c0ad089476b3951 (diff) | |
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
Diffstat (limited to 'src/panels/information/pixmapviewer.cpp')
| -rw-r--r-- | src/panels/information/pixmapviewer.cpp | 58 |
1 files changed, 3 insertions, 55 deletions
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 <QPainter> #include <QStyle> -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<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 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); |
