X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fc3134bdee19aa4b1c482435ae7fbf01eacb6d4c..d511752c9de4d9adc30a15ddf9bf89efc1924a7b:/src/pixmapviewer.cpp diff --git a/src/pixmapviewer.cpp b/src/pixmapviewer.cpp index e4d417d47..79e2487a7 100644 --- a/src/pixmapviewer.cpp +++ b/src/pixmapviewer.cpp @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (C) 2006 by Peter Penz * - * peter.penz@gmx.at * + * Copyright (C) 2006 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -23,10 +22,11 @@ #include #include #include -#include +#include -PixmapViewer::PixmapViewer(QWidget* parent) : +PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) : QWidget(parent), + m_transition(transition), m_animationStep(0) { setMinimumWidth(K3Icon::SizeEnormous); @@ -48,8 +48,13 @@ void PixmapViewer::setPixmap(const QPixmap& pixmap) m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap; m_pixmap = pixmap; + update(); - m_animation.start(); + const bool animate = (m_transition != NoTransition) && + (m_pixmap.size() != m_oldPixmap.size()); + if (animate) { + m_animation.start(); + } } void PixmapViewer::paintEvent(QPaintEvent* event) @@ -65,7 +70,9 @@ void PixmapViewer::paintEvent(QPaintEvent* event) const int x = (width() - scaledWidth ) / 2; const int y = (height() - scaledHeight) / 2; - const QPixmap& largePixmap = (m_oldPixmap.width() > m_pixmap.width()) ? m_oldPixmap : m_pixmap; + const bool useOldPixmap = (m_transition == SizeTransition) && + (m_oldPixmap.width() > m_pixmap.width()); + const QPixmap& largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap; const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, scaledHeight, Qt::IgnoreAspectRatio,