]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/information/pixmapviewer.cpp
Merge branch 'master' into frameworks
[dolphin.git] / src / panels / information / pixmapviewer.cpp
index afa4c2f282d655a41a37bfcde7e1ac8f138b8d44..0053e43f974e8b5d50ff81ffa3477080df8333fa 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
  *                                                                         *
  *   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>
 
-#include <QLayout>
 #include <QPainter>
 #include <QPixmap>
-#include <QKeyEvent>
 
 PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
     QWidget(parent),
@@ -39,8 +37,8 @@ PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) :
     m_animation.setCurveShape(QTimeLine::LinearCurve);
 
     if (m_transition != NoTransition) {
-        connect(&m_animation, SIGNAL(valueChanged(qreal)), this, SLOT(update()));
-        connect(&m_animation, SIGNAL(finished()), this, SLOT(checkPendingPixmaps()));
+        connect(&m_animation, &QTimeLine::valueChanged, this, static_cast<void(PixmapViewer::*)()>(&PixmapViewer::update));
+        connect(&m_animation, &QTimeLine::finished, this, &PixmapViewer::checkPendingPixmaps);
     }
 }
 
@@ -102,11 +100,13 @@ void PixmapViewer::paintEvent(QPaintEvent* event)
         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,
-                                                        Qt::FastTransformation);
-        painter.drawPixmap(x, y, scaledPixmap);
+       if (!largePixmap.isNull()) {
+            const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth,
+                                                            scaledHeight,
+                                                            Qt::IgnoreAspectRatio,
+                                                            Qt::FastTransformation);
+            painter.drawPixmap(x, y, scaledPixmap);
+       }
     } else {
         const int x = (width()  - m_pixmap.width() ) / 2;
         const int y = (height() - m_pixmap.height()) / 2;
@@ -127,4 +127,3 @@ void PixmapViewer::checkPendingPixmaps()
     }
 }
 
-#include "pixmapviewer.moc"