2010-10-12 21:51:57 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-05-27 20:36:14 +02:00
|
|
|
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.
|
|
|
|
*/
|
2012-05-27 20:36:14 +02:00
|
|
|
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.
|
|
|
|
*/
|
2010-12-06 22:54:58 +01:00
|
|
|
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.
|
|
|
|
*/
|
2012-05-27 20:36:14 +02:00
|
|
|
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
2010-10-12 21:51:57 +02:00
|
|
|
|
2012-11-27 13:33:50 +01:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
public:
|
|
|
|
SvgItem(QDeclarativeItem *parent=0);
|
|
|
|
~SvgItem();
|
|
|
|
|
|
|
|
void setElementId(const QString &elementID);
|
|
|
|
QString elementId() const;
|
|
|
|
|
2010-11-05 21:22:47 +01:00
|
|
|
void setSvg(Plasma::Svg *svg);
|
|
|
|
Plasma::Svg *svg() const;
|
|
|
|
|
2010-12-06 23:19:33 +01:00
|
|
|
void setSmooth(const bool smooth);
|
|
|
|
bool smooth() const;
|
|
|
|
|
2010-12-06 22:54:58 +01:00
|
|
|
QSizeF naturalSize() const;
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
|
|
|
|
2012-11-27 13:33:50 +01:00
|
|
|
void setImplicitWidth(qreal width);
|
|
|
|
qreal implicitWidth() const;
|
|
|
|
|
|
|
|
void setImplicitHeight(qreal height);
|
|
|
|
qreal implicitHeight() const;
|
|
|
|
|
2010-12-06 22:54:58 +01:00
|
|
|
Q_SIGNALS:
|
2012-05-27 20:36:14 +02:00
|
|
|
void elementIdChanged();
|
|
|
|
void svgChanged();
|
2010-12-06 22:54:58 +01:00
|
|
|
void naturalSizeChanged();
|
2012-05-27 20:36:14 +02:00
|
|
|
void smoothChanged();
|
2012-11-27 13:33:50 +01:00
|
|
|
void implicitWidthChanged();
|
|
|
|
void implicitHeightChanged();
|
2010-12-06 22:54:58 +01:00
|
|
|
|
2011-03-18 13:32:49 +01:00
|
|
|
protected Q_SLOTS:
|
|
|
|
void updateNeeded();
|
|
|
|
|
2010-10-12 21:51:57 +02:00
|
|
|
private:
|
2010-11-05 21:22:47 +01:00
|
|
|
QWeakPointer<Plasma::Svg> m_svg;
|
2010-10-12 21:51:57 +02:00
|
|
|
QString m_elementID;
|
2010-12-06 23:19:33 +01:00
|
|
|
bool m_smooth;
|
2010-10-12 21:51:57 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|