--- infoscreen/pictureview.cpp 2010/01/06 22:18:52 528 +++ infoscreen/pictureview.cpp 2010/05/05 09:37:08 709 @@ -1,7 +1,7 @@ #include "pictureview.h" #include - +#include #include "httpwrapper.h" @@ -10,11 +10,30 @@ { } + void PictureView::paintEvent ( QPaintEvent* event) { Q_UNUSED(event); + + QSize s = this->size(); + + QBrush blackBrush(Qt::black); + QPainter painter(this); - painter.drawPixmap(0,0,image); + painter.fillRect( QRect(0,0,s.width(), s.height()), blackBrush); + + int x = 0; + int y = 0; + + if (image.width() < s.width() ) { + x = (s.width() - image.width()) / 2; + } + if (image.height() < s.height() ) { + y = (s.height() - image.height()) / 2; + } + + + painter.drawPixmap(x,y,image); painter.end(); } @@ -25,12 +44,17 @@ image = it.value(); this->repaint(); } else { - QByteArray data = HttpWrapper::getSyncData(source); + qDebug() << "Loading file " << source; QPixmap pixmap; - pixmap.loadFromData( data ); + if (source.at(0) == '/') { //local file + pixmap = QPixmap(source); + } else { + QByteArray data = HttpWrapper::getSyncData(source); + pixmap.loadFromData( data ); + } - QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation ); + QPixmap scaledImage = pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); image = scaledImage; this->repaint();