forked from qt-creator/qt-creator
Image Viewer: Fix for compiling without QtSvg
Merge-request: 177 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
committed by
Oswald Buddenhagen
parent
efe3dc93d6
commit
eed852d8be
@@ -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 &)
|
|||||||
|
|
||||||
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)
|
|||||||
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 += \
|
|||||||
ImageViewer.pluginspec \
|
ImageViewer.pluginspec \
|
||||||
ImageViewer.mimetypes.xml
|
ImageViewer.mimetypes.xml
|
||||||
|
|
||||||
QT += svg
|
contains(QT_CONFIG, svg):QT += svg
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
imageviewertoolbar.ui
|
imageviewertoolbar.ui
|
||||||
|
|||||||
Reference in New Issue
Block a user