DtkGui
DTK Gui module
载入中...
搜索中...
未找到
dsvgrenderer.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSVGRENDERER_H
6#define DSVGRENDERER_H
7
8#include <dtkgui_global.h>
9#include <DObject>
10
11#include <QObject>
12#include <QRectF>
13
14QT_BEGIN_NAMESPACE
15class QPainter;
16QT_END_NAMESPACE
17
18#ifdef Q_OS_LINUX
19DGUI_BEGIN_NAMESPACE
20class DSvgRendererPrivate;
21class DSvgRenderer : public QObject, public DTK_CORE_NAMESPACE::DObject
22{
23 Q_PROPERTY(QRectF viewBox READ viewBoxF WRITE setViewBox)
24public:
25 explicit DSvgRenderer(QObject *parent = Q_NULLPTR);
26 DSvgRenderer(const QString &filename, QObject *parent = Q_NULLPTR);
27 DSvgRenderer(const QByteArray &contents, QObject *parent = Q_NULLPTR);
29
30 bool isValid() const;
31
32 QSize defaultSize() const;
33
34 QRect viewBox() const;
35 QRectF viewBoxF() const;
36 void setViewBox(const QRect &viewbox);
37 void setViewBox(const QRectF &viewbox);
38
39 QRectF boundsOnElement(const QString &id) const;
40 bool elementExists(const QString &id) const;
41
42 QImage toImage(const QSize sz, const QString &elementId = QString()) const;
43
44public Q_SLOTS:
45 bool load(const QString &filename);
46 bool load(const QByteArray &contents);
47 void render(QPainter *p);
48 void render(QPainter *p, const QRectF &bounds);
49
50 void render(QPainter *p, const QString &elementId,
51 const QRectF &bounds = QRectF());
52
53private:
54 D_DECLARE_PRIVATE(DSvgRenderer)
55};
56DGUI_END_NAMESPACE
57#else
58
59#include <QSvgRenderer>
60DGUI_BEGIN_NAMESPACE
61typedef QSvgRenderer DSvgRenderer;
62DGUI_END_NAMESPACE
63
64#endif
65
66#endif // DSVGRENDERER_H
提供了将SVG文件的内容绘制到绘制设备上的方法.