Add some convenience methods file(), to get the svg image path and setFile, to set the image path
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=750651
This commit is contained in:
parent
34bd2b87b2
commit
5e77ba9e70
28
svg.cpp
28
svg.cpp
@ -79,12 +79,7 @@ class Svg::Private
|
||||
|
||||
~Private()
|
||||
{
|
||||
if (renderer.count() == 2) {
|
||||
// this and the cache reference it; and boy is this not thread safe ;)
|
||||
renderers.erase(renderers.find(themePath));
|
||||
}
|
||||
|
||||
renderer = 0;
|
||||
eraseRenderer();
|
||||
}
|
||||
|
||||
void removeFromCache()
|
||||
@ -163,6 +158,16 @@ class Svg::Private
|
||||
size = renderer->defaultSize();
|
||||
}
|
||||
|
||||
void eraseRenderer()
|
||||
{
|
||||
if (renderer.count() == 2) {
|
||||
// this and the cache reference it; and boy is this not thread safe ;)
|
||||
renderers.erase(renderers.find(themePath));
|
||||
}
|
||||
|
||||
renderer = 0;
|
||||
}
|
||||
|
||||
QSize elementSize(const QString& elementId)
|
||||
{
|
||||
createRenderer();
|
||||
@ -311,6 +316,17 @@ Svg::ContentType Svg::contentType()
|
||||
return d->contentType;
|
||||
}
|
||||
|
||||
void Svg::setFile(const QString &svgFilePath)
|
||||
{
|
||||
d->themePath = svgFilePath;
|
||||
d->eraseRenderer();
|
||||
}
|
||||
|
||||
QString Svg::file() const
|
||||
{
|
||||
return d->themePath;
|
||||
}
|
||||
|
||||
void Svg::themeChanged()
|
||||
{
|
||||
d->removeFromCache();
|
||||
|
13
svg.h
13
svg.h
@ -50,6 +50,7 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
Q_ENUMS( ContentType )
|
||||
Q_PROPERTY( QSize size READ size )
|
||||
Q_PROPERTY( ContentType contentType READ contentType WRITE setContentType )
|
||||
Q_PROPERTY( QString file READ file WRITE setFile )
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -199,6 +200,18 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
*/
|
||||
ContentType contentType();
|
||||
|
||||
/**
|
||||
* Convenience method for setting the svg file to use for the Svg.
|
||||
* @arg svgFilePath the filepath including name of the svg.
|
||||
*/
|
||||
void setFile(const QString &svgFilePath);
|
||||
|
||||
/**
|
||||
* Convenience method to get the svg filepath and name of svg.
|
||||
* @return the svg's filepath including name of the svg.
|
||||
*/
|
||||
QString file() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void repaintNeeded();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user