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:
parent
4d641580fa
commit
8d9aa19d83
@ -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);
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -171,6 +171,7 @@ public:
|
||||
QString infoText;
|
||||
Svg svg;
|
||||
Svg *iconSvg;
|
||||
QString iconSvgElement;
|
||||
QPixmap iconSvgPixmap;
|
||||
int svgElements;
|
||||
QSizeF size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user