+#include <QWheelEvent>
+
+MyLabel::MyLabel(QWidget *parent)
+{
+}
+
+void MyLabel::setImage(QImage img)
+{
+ m_img = img;
+}
+
+//virtual
+void MyLabel::wheelEvent(QWheelEvent * event)
+{
+ if (event->delta() > 0) emit seek(true);
+ else emit seek(false);
+}
+
+//virtual
+void MyLabel::paintEvent( QPaintEvent * event)
+{
+ QRect r(0, 0, width(), height());
+ QPainter p(this);
+ p.fillRect(r, QColor(KdenliveSettings::window_background()));
+ double aspect_ratio = (double) m_img.width() / m_img.height();
+ int pictureHeight = height();
+ int pictureWidth = width();
+ int calculatedWidth = aspect_ratio * height();
+ if (calculatedWidth > width()) pictureHeight = width() / aspect_ratio;
+ else {
+ int calculatedHeight = width() / aspect_ratio;
+ if (calculatedHeight > height()) pictureWidth = height() * aspect_ratio;
+ }
+ p.drawImage(QRect((width() - pictureWidth) / 2, (height() - pictureHeight) / 2, pictureWidth, pictureHeight), m_img, QRect(0, 0, m_img.width(), m_img.height()));
+ p.end();
+}
+