Plasma

svgitem.h
1 /***************************************************************************
2  * Copyright 2010 Marco Martin <[email protected]> *
3  * Copyright 2014 David Edmundson <[email protected]> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
19  ***************************************************************************/
20 #ifndef SVGITEM_P
21 #define SVGITEM_P
22 
23 #include <QQuickItem>
24 #include <QImage>
25 
26 #include "units.h"
27 
28 namespace Plasma
29 {
30 
31 class Svg;
32 
37 class SvgItem : public QQuickItem
38 {
39  Q_OBJECT
40 
44  Q_PROPERTY(QString elementId READ elementId WRITE setElementId NOTIFY elementIdChanged)
45 
46 
56  Q_PROPERTY(Plasma::Svg *svg READ svg WRITE setSvg NOTIFY svgChanged)
57 
61  Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged)
62 
63 public:
65 
66  explicit SvgItem(QQuickItem *parent = nullptr);
67  ~SvgItem() override;
68 
69  void setElementId(const QString &elementID);
70  QString elementId() const;
71 
72  void setSvg(Plasma::Svg *svg);
73  Plasma::Svg *svg() const;
74 
75  QSizeF naturalSize() const;
76 
77  QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
79 
80 Q_SIGNALS:
81  void elementIdChanged();
82  void svgChanged();
83  void naturalSizeChanged();
84 
85 protected Q_SLOTS:
87  void updateNeeded();
88  void updateDevicePixelRatio();
90 
91 private:
92  void scheduleImageUpdate();
93  void updatePolish() override;
94  void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
95 
96  QPointer<Plasma::Svg> m_svg;
97  QString m_elementID;
98  bool m_textureChanged;
99  QImage m_image;
100 };
101 }
102 
103 #endif
Plasma::Svg svg
Svg class that is the source of the image, use it like that:
Definition: svgitem.h:56
Q_SIGNALSQ_SIGNALS
QSizeF naturalSize
The natural, unscaled size of the svg document or the element.
Definition: svgitem.h:61
Namespace for everything in libplasma.
Definition: datamodel.cpp:27
Q_OBJECTQ_OBJECT
QString elementId
The sub element of the svg we want to render.
Definition: svgitem.h:44
Displays an SVG or an element from an SVG file.
Definition: svgitem.h:37
Q_PROPERTY(...)
virtual QSGNode * updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData)
Q_SLOTSQ_SLOTS
QObject * parent() const const
A theme aware image-centric SVG class.
Definition: svg.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 22:41:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.