Skip to content
Snippets Groups Projects
Commit eed852d8 authored by Denis Mingulov's avatar Denis Mingulov Committed by Oswald Buddenhagen
Browse files

Image Viewer: Fix for compiling without QtSvg


Merge-request: 177
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@nokia.com>
parent efe3dc93
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
#include <QtGui/QMouseEvent> #include <QtGui/QMouseEvent>
#include <QtGui/QGraphicsRectItem> #include <QtGui/QGraphicsRectItem>
#include <QtGui/QPixmap> #include <QtGui/QPixmap>
#ifndef QT_NO_SVG
#include <QtSvg/QGraphicsSvgItem> #include <QtSvg/QGraphicsSvgItem>
#endif
#include <QtGui/QImageReader> #include <QtGui/QImageReader>
#include <qmath.h> #include <qmath.h>
...@@ -104,15 +106,19 @@ void ImageView::drawBackground(QPainter *p, const QRectF &) ...@@ -104,15 +106,19 @@ void ImageView::drawBackground(QPainter *p, const QRectF &)
bool ImageView::openFile(QString fileName) bool ImageView::openFile(QString fileName)
{ {
#ifndef QT_NO_SVG
bool isSvg = false; bool isSvg = false;
#endif
QByteArray format = QImageReader::imageFormat(fileName); QByteArray format = QImageReader::imageFormat(fileName);
// if it is impossible to recognize a file format - file will not be open correctly // if it is impossible to recognize a file format - file will not be open correctly
if (format.isEmpty()) if (format.isEmpty())
return false; return false;
#ifndef QT_NO_SVG
if (format.startsWith("svg")) if (format.startsWith("svg"))
isSvg = true; isSvg = true;
#endif
QGraphicsScene *s = scene(); QGraphicsScene *s = scene();
...@@ -123,9 +129,12 @@ bool ImageView::openFile(QString fileName) ...@@ -123,9 +129,12 @@ bool ImageView::openFile(QString fileName)
resetTransform(); resetTransform();
// image // image
#ifndef QT_NO_SVG
if (isSvg) { if (isSvg) {
d_ptr->imageItem = new QGraphicsSvgItem(fileName); d_ptr->imageItem = new QGraphicsSvgItem(fileName);
} else { } else
#endif
{
QPixmap pixmap(fileName); QPixmap pixmap(fileName);
QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap);
pixmapItem->setTransformationMode(Qt::SmoothTransformation); pixmapItem->setTransformationMode(Qt::SmoothTransformation);
......
...@@ -27,7 +27,7 @@ OTHER_FILES += \ ...@@ -27,7 +27,7 @@ OTHER_FILES += \
ImageViewer.pluginspec \ ImageViewer.pluginspec \
ImageViewer.mimetypes.xml ImageViewer.mimetypes.xml
QT += svg contains(QT_CONFIG, svg):QT += svg
FORMS += \ FORMS += \
imageviewertoolbar.ui imageviewertoolbar.ui
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment