Allow rendering of a specific svg element id. You can still render them all if you don't specify a element name but now you can also use a specific element. Doesn't handle resizing.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=751533
This commit is contained in:
Shawn Starr 2007-12-22 05:31:57 +00:00
parent 4d641580fa
commit 8d9aa19d83
3 changed files with 7 additions and 3 deletions

View File

@ -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);
}

View File

@ -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.

View File

@ -171,6 +171,7 @@ public:
QString infoText;
Svg svg;
Svg *iconSvg;
QString iconSvgElement;
QPixmap iconSvgPixmap;
int svgElements;
QSizeF size;