1 |
#include "pictureview.h" |
#include "pictureview.h" |
2 |
|
|
3 |
#include <QPainter> |
#include <QPainter> |
4 |
|
#include <QDebug> |
5 |
|
|
6 |
#include "httpwrapper.h" |
#include "httpwrapper.h" |
7 |
|
|
10 |
{ |
{ |
11 |
} |
} |
12 |
|
|
13 |
|
|
14 |
|
// TODO: if the picture doesn't fill the screen, fill the canvas with black before drawing the picture and |
15 |
|
// place the image mid-screen |
16 |
void PictureView::paintEvent ( QPaintEvent* event) |
void PictureView::paintEvent ( QPaintEvent* event) |
17 |
{ |
{ |
18 |
Q_UNUSED(event); |
Q_UNUSED(event); |
28 |
image = it.value(); |
image = it.value(); |
29 |
this->repaint(); |
this->repaint(); |
30 |
} else { |
} else { |
31 |
QByteArray data = HttpWrapper::getSyncData(source); |
qDebug() << "Loading file " << source; |
32 |
|
|
33 |
QPixmap pixmap; |
QPixmap pixmap; |
34 |
pixmap.loadFromData( data ); |
if (source.at(0) == '/') { //local file |
35 |
|
pixmap = QPixmap(source); |
36 |
|
} else { |
37 |
|
QByteArray data = HttpWrapper::getSyncData(source); |
38 |
|
pixmap.loadFromData( data ); |
39 |
|
} |
40 |
|
|
41 |
QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation ); |
QPixmap scaledImage = pixmap.scaledToHeight(size().height(), Qt::SmoothTransformation ); |
42 |
|
|