]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/pixmapviewer.cpp
Make use of the error messages coming from the places model.
[dolphin.git] / src / pixmapviewer.cpp
index e4d417d47171c3d8da2967fc4f9e7a61274435c5..79e2487a70d22ad5fc0158a7f65e14c1e8ffed32 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
  *                                                                         *
  *   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  *
 #include <kiconloader.h>
 #include <QtGui/QPainter>
 #include <QtGui/QPixmap>
-#include <QtGui/QPaintEvent>
+#include <QtGui/QKeyEvent>
 
-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,