mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
LP-139 fixed erroneous warning about missing pfd.svg
This commit is contained in:
parent
1ea729ecc6
commit
88dcb62ed6
@ -26,12 +26,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "svgimageprovider.h"
|
#include "svgimageprovider.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QSvgRenderer>
|
||||||
|
|
||||||
SvgImageProvider::SvgImageProvider(const QString &basePath) :
|
SvgImageProvider::SvgImageProvider(const QString &basePath) :
|
||||||
QObject(),
|
|
||||||
QQuickImageProvider(QQuickImageProvider::Image),
|
QQuickImageProvider(QQuickImageProvider::Image),
|
||||||
m_basePath(basePath)
|
m_basePath(basePath)
|
||||||
{}
|
{}
|
||||||
@ -46,15 +48,12 @@ QSvgRenderer *SvgImageProvider::loadRenderer(const QString &svgFile)
|
|||||||
QSvgRenderer *renderer = m_renderers.value(svgFile);
|
QSvgRenderer *renderer = m_renderers.value(svgFile);
|
||||||
|
|
||||||
if (!renderer) {
|
if (!renderer) {
|
||||||
renderer = new QSvgRenderer(svgFile);
|
QFileInfo fi(svgFile);
|
||||||
|
|
||||||
QString fn = QUrl::fromLocalFile(m_basePath).resolved(svgFile).toLocalFile();
|
// if svgFile is relative, make it relative to base
|
||||||
|
QString fn = fi.isRelative() ? QUrl::fromLocalFile(m_basePath).resolved(svgFile).toLocalFile() : svgFile;
|
||||||
// convert path to be relative to base
|
|
||||||
if (!renderer->isValid()) {
|
|
||||||
renderer->load(fn);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
renderer = new QSvgRenderer(fn);
|
||||||
if (!renderer->isValid()) {
|
if (!renderer->isValid()) {
|
||||||
qWarning() << "Failed to load svg file:" << svgFile << fn;
|
qWarning() << "Failed to load svg file:" << svgFile << fn;
|
||||||
delete renderer;
|
delete renderer;
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
#ifndef SVGIMAGEPROVIDER_H_
|
#ifndef SVGIMAGEPROVIDER_H_
|
||||||
#define SVGIMAGEPROVIDER_H_
|
#define SVGIMAGEPROVIDER_H_
|
||||||
|
|
||||||
#include <QObject>
|
#include "utils_global.h"
|
||||||
|
|
||||||
#include <QQuickImageProvider>
|
#include <QQuickImageProvider>
|
||||||
#include <QSvgRenderer>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
#include "utils_global.h"
|
class QSvgRenderer;
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT SvgImageProvider : public QObject, public QQuickImageProvider {
|
class QTCREATOR_UTILS_EXPORT SvgImageProvider : public QObject, public QQuickImageProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -41,14 +41,14 @@ public:
|
|||||||
SvgImageProvider(const QString &basePath);
|
SvgImageProvider(const QString &basePath);
|
||||||
~SvgImageProvider();
|
~SvgImageProvider();
|
||||||
|
|
||||||
QSvgRenderer *loadRenderer(const QString &svgFile);
|
|
||||||
|
|
||||||
QImage requestImage(const QString &id, QSize *size, const QSize & requestedSize);
|
QImage requestImage(const QString &id, QSize *size, const QSize & requestedSize);
|
||||||
QPixmap requestPixmap(const QString &id, QSize *size, const QSize & requestedSize);
|
QPixmap requestPixmap(const QString &id, QSize *size, const QSize & requestedSize);
|
||||||
|
|
||||||
Q_INVOKABLE QRectF scaledElementBounds(const QString &svgFile, const QString &elementName);
|
Q_INVOKABLE QRectF scaledElementBounds(const QString &svgFile, const QString &elementName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QSvgRenderer *loadRenderer(const QString &svgFile);
|
||||||
|
|
||||||
QMap<QString, QSvgRenderer *> m_renderers;
|
QMap<QString, QSvgRenderer *> m_renderers;
|
||||||
QString m_basePath;
|
QString m_basePath;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user