diff --git a/widgets/icon.cpp b/widgets/icon.cpp index d70f94fc7..2fd6817d2 100644 --- a/widgets/icon.cpp +++ b/widgets/icon.cpp @@ -454,13 +454,15 @@ void Icon::calculateSize(const QStyleOptionGraphicsItem *option) update(); } -void Icon::setSvg(const QString &svgFilePath) +void Icon::setSvg(const QString &svgFilePath, const QString &elementId) { if (!d->iconSvg) { d->iconSvg = new Plasma::Svg(svgFilePath); } else { d->iconSvg->setFile(svgFilePath); } + + d->iconSvgElement = elementId; } void Icon::Private::drawBackground(QPainter *painter, IconState state) @@ -533,7 +535,7 @@ QPixmap Icon::Private::decoration(const QStyleOptionGraphicsItem *option, bool u QImage img(iconSize.toSize(), QImage::Format_ARGB32_Premultiplied); { QPainter p(&img); - iconSvg->paint(&p, img.rect()); + iconSvg->paint(&p, img.rect(), iconSvgElement); } iconSvgPixmap = QPixmap::fromImage(img); } diff --git a/widgets/icon.h b/widgets/icon.h index aedbadb3d..2efd3816c 100644 --- a/widgets/icon.h +++ b/widgets/icon.h @@ -94,8 +94,9 @@ public: /** * Convenience method to set the svg image to use when given the filepath and name of svg. * @param svgFilePath the svg filepath including name of the svg. + * @param svgIconElement the svg element to use when displaying the svg. Defaults to all of them. */ - void setSvg(const QString &svgFilePath); + void setSvg(const QString &svgFilePath, const QString &svgIconElement = QString()); /** * Returns the meta text associated with this icon. diff --git a/widgets/icon_p.h b/widgets/icon_p.h index 3ed2d1aae..47b7ef52c 100644 --- a/widgets/icon_p.h +++ b/widgets/icon_p.h @@ -171,6 +171,7 @@ public: QString infoText; Svg svg; Svg *iconSvg; + QString iconSvgElement; QPixmap iconSvgPixmap; int svgElements; QSizeF size;