diff --git a/svg.cpp b/svg.cpp index 6b9d933db..33984ac80 100644 --- a/svg.cpp +++ b/svg.cpp @@ -376,6 +376,12 @@ void Svg::paint(QPainter *painter, const QRectF &rect, const QString &elementID) painter->drawPixmap(rect, pix, QRectF(QPointF(0, 0), pix.size())); } +void Svg::paint(QPainter *painter, int x, int y, int width, int height, const QString &elementID) +{ + QPixmap pix(d->findInCache(elementID, QSizeF(width, height))); + painter->drawPixmap(x, y, pix, 0, 0, pix.size().width(), pix.size().height()); +} + QSize Svg::size() const { return d->size.toSize(); diff --git a/svg.h b/svg.h index 3ad6f42ef..d76b899e5 100644 --- a/svg.h +++ b/svg.h @@ -120,6 +120,19 @@ class PLASMA_EXPORT Svg : public QObject Q_INVOKABLE void paint(QPainter *painter, const QRectF &rect, const QString &elementID = QString()); + /** + * Paints the SVG represented by this object + * @arg painter the QPainter to use + * @arg x the horizontal coordinate to start painting from + * @arg y the vertical coordinate to start painting from + * @arg width the width of the element to draw + * @arg height the height of the element do draw + * @arg elelementId the ID string of the element to render, or an empty + * string for the whole SVG (the default) + */ + Q_INVOKABLE void paint(QPainter *painter, int x, int y, int width, + int height, const QString &elementID = QString()); + /** * Currently set size of the SVG * @return the current size of a given element