diff --git a/svg.cpp b/svg.cpp index e9a42db31..777bd5dbc 100644 --- a/svg.cpp +++ b/svg.cpp @@ -169,10 +169,18 @@ void Svg::resize( const QSizeF& size ) d->size = size; } +void Svg::resize() +{ + if (!d->renderer) { + d->renderer = new KSvgRenderer(Plasma::Theme::self()->image(d->themePath)); + } + d->size = d->renderer->defaultSize(); +} + QSize Svg::elementSize(const QString& elementId) { if (!d->renderer) { - return QSize(); + d->renderer = new KSvgRenderer(Plasma::Theme::self()->image(d->themePath)); } QSizeF elementSize = d->renderer->boundsOnElement(elementId).size(); diff --git a/svg.h b/svg.h index 83283aad0..8f6b04d30 100644 --- a/svg.h +++ b/svg.h @@ -108,6 +108,13 @@ class PLASMA_EXPORT Svg : public QObject **/ void resize( const QSizeF& size ); + /** + * Resizes the rendered image to the natural size of the SVG. + * Rendering will actually take place on the next call to paint. + * @arg size the new size of the image + **/ + void resize(); + /** * Size of a given element * @arg elementId the id of the element to check