plasma-framework/declarativeimports/core/svgitem.h

111 lines
3.8 KiB
C
Raw Normal View History

/***************************************************************************
* Copyright 2010 Marco Martin <mart@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef SVGITEM_P
#define SVGITEM_P
#include <QDeclarativeItem>
namespace Plasma {
class Svg;
class SvgItem : public QDeclarativeItem
{
Q_OBJECT
2012-01-10 12:06:59 +01:00
/**
* The sub element of the svg we want to render. If empty the whole svg document will be painted.
*/
Q_PROPERTY(QString elementId READ elementId WRITE setElementId NOTIFY elementIdChanged)
2012-01-10 12:06:59 +01:00
/**
* Svg class that is the source of the image, use it like that:
* <code>
* SvgItem {
* svg: Svg {imagePath: "widgets/arrows"}
* elementId: "arrow-left"
* }
* </code>
* Instead of a Svg declaration it can also be the id of a Svg declared elsewhere, useful to share Svg instances.
*/
Q_PROPERTY(Plasma::Svg * svg READ svg WRITE setSvg NOTIFY svgChanged)
2012-01-10 12:06:59 +01:00
/**
* The natural, unscaled size of the svg document or the element. useful if a pixel perfect rendering of outlines is needed.
*/
Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged)
2012-01-10 12:06:59 +01:00
/**
* If true enable antialiasing in paint: default off, better quality but less performance.
*/
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
/**
* suggested default size hint for width (default to naturalSize.width)
*/
Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged)
/**
* suggested default size hint for height (default to naturalSize.height)
*/
Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged)
public:
SvgItem(QDeclarativeItem *parent=0);
~SvgItem();
void setElementId(const QString &elementID);
QString elementId() const;
void setSvg(Plasma::Svg *svg);
Plasma::Svg *svg() const;
void setSmooth(const bool smooth);
bool smooth() const;
QSizeF naturalSize() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setImplicitWidth(qreal width);
qreal implicitWidth() const;
void setImplicitHeight(qreal height);
qreal implicitHeight() const;
Q_SIGNALS:
void elementIdChanged();
void svgChanged();
void naturalSizeChanged();
void smoothChanged();
void implicitWidthChanged();
void implicitHeightChanged();
2011-03-18 13:32:49 +01:00
protected Q_SLOTS:
void updateNeeded();
private:
QWeakPointer<Plasma::Svg> m_svg;
QString m_elementID;
bool m_smooth;
};
}
#endif