add matrixForElement(const QString& elementId) const as discussed on panel-devel
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=695665
This commit is contained in:
parent
ac918ad4bf
commit
ce090faab8
14
svg.cpp
14
svg.cpp
@ -177,10 +177,16 @@ class Svg::Private
|
||||
QSizeF naturalSize = renderer->defaultSize();
|
||||
qreal dx = size.width() / naturalSize.width();
|
||||
qreal dy = size.height() / naturalSize.height();
|
||||
|
||||
|
||||
return QRect(elementRect.x() * dx, elementRect.y() * dy,
|
||||
elementRect.width() * dx, elementRect.height() * dy);
|
||||
}
|
||||
|
||||
QMatrix matrixForElement(const QString& elementId)
|
||||
{
|
||||
createRenderer();
|
||||
return renderer->matrixForElement(elementId);
|
||||
}
|
||||
|
||||
static QHash<QString, SharedSvgRenderer::Ptr> renderers;
|
||||
SharedSvgRenderer::Ptr renderer;
|
||||
@ -261,6 +267,12 @@ bool Svg::elementExists(const QString& elementId) const
|
||||
return d->renderer->elementExists(elementId);
|
||||
}
|
||||
|
||||
QMatrix Svg::matrixForElement(const QString& elementId) const
|
||||
{
|
||||
d->createRenderer();
|
||||
return d->renderer->matrixForElement(elementId);
|
||||
}
|
||||
|
||||
bool Svg::isValid() const
|
||||
{
|
||||
d->createRenderer();
|
||||
|
9
svg.h
9
svg.h
@ -30,6 +30,7 @@ class QRect;
|
||||
class QRectF;
|
||||
class QSize;
|
||||
class QSizeF;
|
||||
class QMatrix;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -156,6 +157,14 @@ class PLASMA_EXPORT Svg : public QObject
|
||||
**/
|
||||
Q_INVOKABLE bool elementExists( const QString& elementId ) const;
|
||||
|
||||
/**
|
||||
* The transformation matrix of the element. That includes the
|
||||
* transformation on the element itself.
|
||||
* @arg elementId the id of the element
|
||||
* @return the matrix for the element
|
||||
**/
|
||||
Q_INVOKABLE QMatrix matrixForElement(const QString& elementId) const;
|
||||
|
||||
/**
|
||||
* @return true if the SVG file exists and the document is valid,
|
||||
* otherwise false. This method can be expensive as it
|
||||
|
Loading…
Reference in New Issue
Block a user