2007-03-08 00:27:37 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
2007-03-08 00:27:37 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-08-06 13:20:02 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2007-03-08 00:27:37 +01:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2007-05-21 16:28:03 +02:00
|
|
|
#include "svg.h"
|
|
|
|
|
2007-05-27 10:01:31 +02:00
|
|
|
#include <QDir>
|
2007-03-08 00:27:37 +01:00
|
|
|
#include <QMatrix>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QPixmapCache>
|
2007-05-29 09:56:21 +02:00
|
|
|
#include <QSharedData>
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
#include <KDebug>
|
2007-05-29 09:56:21 +02:00
|
|
|
#include <KSharedPtr>
|
2007-03-08 21:14:34 +01:00
|
|
|
#include <KSvgRenderer>
|
2008-02-22 02:05:11 +01:00
|
|
|
#include <KColorScheme>
|
|
|
|
#include <KIconEffect>
|
|
|
|
#include <KGlobalSettings>
|
2007-05-29 09:56:21 +02:00
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
#include "theme.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-29 09:56:21 +02:00
|
|
|
class SharedSvgRenderer : public KSvgRenderer, public QSharedData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef KSharedPtr<SharedSvgRenderer> Ptr;
|
|
|
|
|
|
|
|
SharedSvgRenderer(QObject *parent = 0)
|
|
|
|
: KSvgRenderer(parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
SharedSvgRenderer(const QString &filename, QObject *parent = 0)
|
|
|
|
: KSvgRenderer(filename, parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
SharedSvgRenderer(const QByteArray &contents, QObject *parent = 0)
|
|
|
|
: KSvgRenderer(contents, parent)
|
|
|
|
{}
|
|
|
|
|
|
|
|
~SharedSvgRenderer()
|
|
|
|
{
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "leaving this world for a better one.";
|
2007-05-29 09:56:21 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
class Svg::Private
|
|
|
|
{
|
|
|
|
public:
|
2008-04-23 15:07:41 +02:00
|
|
|
Private(Svg *svg)
|
2008-04-16 22:30:18 +02:00
|
|
|
: q(svg),
|
|
|
|
renderer(0),
|
2008-04-17 11:09:48 +02:00
|
|
|
multipleImages(false),
|
2008-04-27 23:49:09 +02:00
|
|
|
themed(false),
|
|
|
|
applyColors(false)
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
2008-01-07 21:20:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~Private()
|
|
|
|
{
|
|
|
|
eraseRenderer();
|
|
|
|
}
|
|
|
|
|
2008-02-07 05:33:57 +01:00
|
|
|
void setImagePath(const QString &imagePath, Svg *q)
|
2008-01-07 21:20:02 +01:00
|
|
|
{
|
2008-02-07 05:33:57 +01:00
|
|
|
if (themed) {
|
2008-04-23 20:35:03 +02:00
|
|
|
disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
2008-02-22 02:05:11 +01:00
|
|
|
disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
2008-02-07 05:33:57 +01:00
|
|
|
}
|
|
|
|
|
2008-01-07 21:20:02 +01:00
|
|
|
themed = !QDir::isAbsolutePath(imagePath);
|
|
|
|
path = themePath = QString();
|
|
|
|
|
|
|
|
if (themed) {
|
|
|
|
themePath = imagePath;
|
2008-04-23 20:35:03 +02:00
|
|
|
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
2008-02-22 02:05:11 +01:00
|
|
|
|
|
|
|
// check if svg wants colorscheme applied
|
|
|
|
createRenderer();
|
|
|
|
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
2008-04-22 23:10:14 +02:00
|
|
|
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
2008-02-22 02:05:11 +01:00
|
|
|
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
|
|
|
}
|
|
|
|
|
2008-01-07 21:20:02 +01:00
|
|
|
} else {
|
2007-05-27 10:01:31 +02:00
|
|
|
path = imagePath;
|
2007-07-23 02:50:10 +02:00
|
|
|
|
|
|
|
if (!QFile::exists(path)) {
|
2008-01-08 02:25:09 +01:00
|
|
|
kDebug() << "Plasma::Svg: file '" << path << "' does not exist!";
|
2007-07-23 02:50:10 +02:00
|
|
|
}
|
2007-05-27 10:01:31 +02:00
|
|
|
}
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2008-02-19 05:28:17 +01:00
|
|
|
void removeFromCache() {
|
|
|
|
if (ids.isEmpty()) {
|
2007-03-08 00:27:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-22 02:05:11 +01:00
|
|
|
foreach (const QString &id, ids) {
|
2008-02-19 05:28:17 +01:00
|
|
|
QPixmapCache::remove(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
ids.clear();
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2008-04-22 01:00:58 +02:00
|
|
|
void findInCache(QPixmap& p, const QString& elementId, const QPainter *itemPainter, const QSizeF &s = QSizeF())
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
2008-04-22 01:00:58 +02:00
|
|
|
createRenderer();
|
|
|
|
|
|
|
|
QSize size;
|
2008-04-17 11:09:48 +02:00
|
|
|
if (elementId.isEmpty() || multipleImages) {
|
2008-04-22 01:00:58 +02:00
|
|
|
size = s.toSize();
|
2008-04-13 19:27:02 +02:00
|
|
|
} else {
|
2008-04-22 01:00:58 +02:00
|
|
|
size = elementSize(elementId);
|
2008-04-13 19:27:02 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 01:00:58 +02:00
|
|
|
if (!size.isValid()) {
|
|
|
|
p = QPixmap();
|
|
|
|
return;
|
2008-04-13 19:27:02 +02:00
|
|
|
}
|
|
|
|
|
2008-04-14 16:41:41 +02:00
|
|
|
QString id = QString::fromLatin1("%3_%2_%1_").arg(size.width())
|
|
|
|
.arg(size.height())
|
|
|
|
.arg(path);
|
2008-04-22 01:00:58 +02:00
|
|
|
|
2007-05-19 00:05:00 +02:00
|
|
|
if (!elementId.isEmpty()) {
|
|
|
|
id.append(elementId);
|
|
|
|
}
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "id is " << id;
|
2007-05-19 00:05:00 +02:00
|
|
|
|
2008-02-22 02:05:11 +01:00
|
|
|
if (!ids.contains(id)) {
|
|
|
|
ids.append(id);
|
|
|
|
}
|
|
|
|
|
2007-05-27 10:01:31 +02:00
|
|
|
if (QPixmapCache::find(id, p)) {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "found cached version of " << id;
|
2007-03-08 00:27:37 +01:00
|
|
|
return;
|
2007-05-21 00:30:41 +02:00
|
|
|
} else {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "didn't find cached version of " << id << ", so re-rendering";
|
2007-05-21 00:30:41 +02:00
|
|
|
}
|
2008-04-21 21:32:26 +02:00
|
|
|
|
2008-04-14 16:41:41 +02:00
|
|
|
//kDebug() << "size for " << elementId << " is " << s;
|
2008-04-22 01:00:58 +02:00
|
|
|
// we have to re-render this puppy
|
2008-04-21 21:32:26 +02:00
|
|
|
|
2008-04-22 01:00:58 +02:00
|
|
|
p = QPixmap(size);
|
2007-03-08 00:27:37 +01:00
|
|
|
|
|
|
|
p.fill(Qt::transparent);
|
2007-05-27 10:01:31 +02:00
|
|
|
QPainter renderPainter(&p);
|
2007-05-19 00:05:00 +02:00
|
|
|
|
2007-05-27 10:01:31 +02:00
|
|
|
if (elementId.isEmpty()) {
|
|
|
|
renderer->render(&renderPainter);
|
2007-05-19 00:05:00 +02:00
|
|
|
} else {
|
2007-05-27 10:01:31 +02:00
|
|
|
renderer->render(&renderPainter, elementId);
|
2007-05-19 00:05:00 +02:00
|
|
|
}
|
2008-01-07 21:20:02 +01:00
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
renderPainter.end();
|
2008-01-07 21:20:02 +01:00
|
|
|
|
2008-02-22 02:05:11 +01:00
|
|
|
// Apply current color scheme if the svg asks for it
|
|
|
|
if (applyColors) {
|
|
|
|
QImage itmp = p.toImage();
|
2008-04-24 00:36:00 +02:00
|
|
|
KIconEffect::colorize(itmp, Theme::defaultTheme()->color(Theme::BackgroundColor), 1.0);
|
2008-02-22 02:05:11 +01:00
|
|
|
p = p.fromImage(itmp);
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:00:58 +02:00
|
|
|
if (!QPixmapCache::insert(id, p)) {
|
2008-04-13 19:27:02 +02:00
|
|
|
//kDebug() << "pixmap cache is too small for inserting" << id << "of size" << s;
|
2008-01-07 21:20:02 +01:00
|
|
|
}
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2007-05-27 10:01:31 +02:00
|
|
|
void createRenderer()
|
|
|
|
{
|
|
|
|
if (renderer) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-07 21:20:02 +01:00
|
|
|
if (themed && path.isEmpty()) {
|
2008-04-22 23:10:14 +02:00
|
|
|
path = Plasma::Theme::defaultTheme()->imagePath(themePath);
|
2007-05-27 10:01:31 +02:00
|
|
|
}
|
|
|
|
|
2007-05-29 09:56:21 +02:00
|
|
|
QHash<QString, SharedSvgRenderer::Ptr>::const_iterator it = renderers.find(path);
|
|
|
|
|
|
|
|
if (it != renderers.end()) {
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << "gots us an existing one!";
|
2007-05-29 09:56:21 +02:00
|
|
|
renderer = it.value();
|
|
|
|
} else {
|
|
|
|
renderer = new SharedSvgRenderer(path);
|
|
|
|
renderers[path] = renderer;
|
|
|
|
}
|
2007-08-31 17:15:04 +02:00
|
|
|
|
|
|
|
size = renderer->defaultSize();
|
2007-05-27 10:01:31 +02:00
|
|
|
}
|
|
|
|
|
2007-12-19 21:29:22 +01:00
|
|
|
void eraseRenderer()
|
|
|
|
{
|
2008-05-02 21:22:07 +02:00
|
|
|
if ( renderer && renderer.count() == 2) {
|
2007-12-19 21:29:22 +01:00
|
|
|
// this and the cache reference it; and boy is this not thread safe ;)
|
|
|
|
renderers.erase(renderers.find(themePath));
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer = 0;
|
|
|
|
}
|
|
|
|
|
2007-05-29 22:27:51 +02:00
|
|
|
QSize elementSize(const QString& elementId)
|
2007-05-29 01:47:41 +02:00
|
|
|
{
|
|
|
|
createRenderer();
|
2008-05-03 19:30:37 +02:00
|
|
|
|
|
|
|
if (!renderer->elementExists(elementId)) {
|
|
|
|
return QSize(0, 0);
|
|
|
|
}
|
|
|
|
|
2007-05-29 01:47:41 +02:00
|
|
|
QSizeF elementSize = renderer->boundsOnElement(elementId).size();
|
|
|
|
QSizeF naturalSize = renderer->defaultSize();
|
|
|
|
qreal dx = size.width() / naturalSize.width();
|
|
|
|
qreal dy = size.height() / naturalSize.height();
|
2007-05-29 22:27:51 +02:00
|
|
|
elementSize.scale(elementSize.width() * dx, elementSize.height() * dy, Qt::IgnoreAspectRatio);
|
2007-05-29 01:47:41 +02:00
|
|
|
|
|
|
|
return elementSize.toSize();
|
|
|
|
}
|
|
|
|
|
2008-04-16 16:31:43 +02:00
|
|
|
QRectF elementRect(const QString& elementId)
|
2007-07-27 01:07:26 +02:00
|
|
|
{
|
|
|
|
createRenderer();
|
|
|
|
QRectF elementRect = renderer->boundsOnElement(elementId);
|
|
|
|
QSizeF naturalSize = renderer->defaultSize();
|
|
|
|
qreal dx = size.width() / naturalSize.width();
|
|
|
|
qreal dy = size.height() / naturalSize.height();
|
2007-11-19 00:03:57 +01:00
|
|
|
|
2008-04-16 16:31:43 +02:00
|
|
|
return QRectF(elementRect.x() * dx, elementRect.y() * dy,
|
2007-07-27 01:07:26 +02:00
|
|
|
elementRect.width() * dx, elementRect.height() * dy);
|
|
|
|
}
|
2008-02-19 05:28:17 +01:00
|
|
|
|
2007-08-02 18:14:35 +02:00
|
|
|
QMatrix matrixForElement(const QString& elementId)
|
|
|
|
{
|
|
|
|
createRenderer();
|
|
|
|
return renderer->matrixForElement(elementId);
|
|
|
|
}
|
2007-07-27 01:07:26 +02:00
|
|
|
|
2008-04-16 22:30:18 +02:00
|
|
|
void themeChanged()
|
|
|
|
{
|
|
|
|
if (!themed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-22 23:10:14 +02:00
|
|
|
QString newPath = Theme::defaultTheme()->imagePath(themePath);
|
2008-04-16 22:30:18 +02:00
|
|
|
|
|
|
|
if (path == newPath) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeFromCache();
|
|
|
|
path = newPath;
|
|
|
|
//delete d->renderer; we're a KSharedPtr
|
|
|
|
eraseRenderer();
|
2008-06-04 04:51:31 +02:00
|
|
|
|
|
|
|
// check if new theme svg wants colorscheme applied
|
|
|
|
createRenderer();
|
|
|
|
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
|
|
|
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
|
|
|
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
|
|
|
} else {
|
|
|
|
disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
|
|
|
}
|
|
|
|
|
2008-04-16 22:30:18 +02:00
|
|
|
emit q->repaintNeeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
void colorsChanged()
|
|
|
|
{
|
|
|
|
if (!applyColors) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
removeFromCache();
|
|
|
|
eraseRenderer();
|
|
|
|
emit q->repaintNeeded();
|
|
|
|
}
|
|
|
|
|
|
|
|
Svg *q;
|
2007-05-29 09:56:21 +02:00
|
|
|
static QHash<QString, SharedSvgRenderer::Ptr> renderers;
|
|
|
|
SharedSvgRenderer::Ptr renderer;
|
2007-03-08 00:27:37 +01:00
|
|
|
QString themePath;
|
|
|
|
QString path;
|
2008-02-19 05:28:17 +01:00
|
|
|
QList<QString> ids;
|
2007-05-19 00:05:00 +02:00
|
|
|
QSizeF size;
|
2008-04-17 11:09:48 +02:00
|
|
|
bool multipleImages;
|
2007-05-27 10:01:31 +02:00
|
|
|
bool themed;
|
2008-02-22 02:05:11 +01:00
|
|
|
bool applyColors;
|
2007-03-08 00:27:37 +01:00
|
|
|
};
|
|
|
|
|
2008-01-22 05:34:49 +01:00
|
|
|
QHash<QString, SharedSvgRenderer::Ptr> Svg::Private::renderers;
|
2007-05-29 09:56:21 +02:00
|
|
|
|
2008-04-23 15:07:41 +02:00
|
|
|
Svg::Svg(QObject* parent)
|
2007-05-29 22:27:51 +02:00
|
|
|
: QObject(parent),
|
2008-04-23 15:07:41 +02:00
|
|
|
d(new Private(this))
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Svg::~Svg()
|
|
|
|
{
|
2007-06-07 22:57:18 +02:00
|
|
|
delete d;
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2007-05-22 02:20:52 +02:00
|
|
|
void Svg::paint(QPainter* painter, const QPointF& point, const QString& elementID)
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
|
|
|
QPixmap pix;
|
2008-06-19 12:15:09 +02:00
|
|
|
|
|
|
|
if (elementID.isNull()) {
|
|
|
|
d->findInCache(pix, elementID, painter, size());
|
|
|
|
} else {
|
|
|
|
d->findInCache(pix, elementID, painter);
|
|
|
|
}
|
2008-04-21 21:32:26 +02:00
|
|
|
|
|
|
|
if (pix.isNull()) {
|
2008-04-13 19:27:02 +02:00
|
|
|
return;
|
2008-04-21 21:32:26 +02:00
|
|
|
}
|
|
|
|
|
2008-04-14 16:41:41 +02:00
|
|
|
painter->drawPixmap(QRectF(point, pix.size()), pix, QRectF(QPointF(0,0), pix.size()));
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2007-05-22 02:20:52 +02:00
|
|
|
void Svg::paint(QPainter* painter, int x, int y, const QString& elementID)
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
2007-05-29 22:27:51 +02:00
|
|
|
paint(painter, QPointF(x, y), elementID);
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2007-05-22 02:20:52 +02:00
|
|
|
void Svg::paint(QPainter* painter, const QRectF& rect, const QString& elementID)
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
|
|
|
QPixmap pix;
|
2008-04-13 19:27:02 +02:00
|
|
|
d->findInCache(pix, elementID, painter, rect.size());
|
2008-04-14 16:41:41 +02:00
|
|
|
painter->drawPixmap(rect, pix, QRectF(QPointF(0,0), pix.size()));
|
2007-03-08 00:27:37 +01:00
|
|
|
}
|
|
|
|
|
2008-04-16 16:31:43 +02:00
|
|
|
QSize Svg::size() const
|
|
|
|
{
|
|
|
|
return d->size.toSize();
|
|
|
|
}
|
|
|
|
|
2008-04-16 19:23:58 +02:00
|
|
|
void Svg::resize( qreal width, qreal height )
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
|
|
|
resize( QSize( width, height ) );
|
|
|
|
}
|
|
|
|
|
2007-05-19 00:05:00 +02:00
|
|
|
void Svg::resize( const QSizeF& size )
|
2007-03-08 00:27:37 +01:00
|
|
|
{
|
2007-08-31 17:15:04 +02:00
|
|
|
d->createRenderer();
|
2007-03-08 00:27:37 +01:00
|
|
|
d->size = size;
|
|
|
|
}
|
|
|
|
|
2007-05-21 00:56:38 +02:00
|
|
|
void Svg::resize()
|
|
|
|
{
|
2007-05-27 10:01:31 +02:00
|
|
|
d->createRenderer();
|
2007-10-01 07:31:32 +02:00
|
|
|
d->size = d->renderer->defaultSize();
|
2007-05-21 00:56:38 +02:00
|
|
|
}
|
|
|
|
|
2007-05-21 01:31:44 +02:00
|
|
|
QSize Svg::elementSize(const QString& elementId) const
|
2007-05-19 00:05:00 +02:00
|
|
|
{
|
2007-05-29 01:47:41 +02:00
|
|
|
return d->elementSize(elementId);
|
2007-05-21 00:39:38 +02:00
|
|
|
}
|
|
|
|
|
2008-04-16 16:31:43 +02:00
|
|
|
QRectF Svg::elementRect(const QString& elementId) const
|
2007-07-27 01:07:26 +02:00
|
|
|
{
|
|
|
|
return d->elementRect(elementId);
|
|
|
|
}
|
|
|
|
|
2008-04-16 16:31:43 +02:00
|
|
|
bool Svg::hasElement(const QString& elementId) const
|
2007-05-29 22:27:51 +02:00
|
|
|
{
|
|
|
|
d->createRenderer();
|
|
|
|
return d->renderer->elementExists(elementId);
|
|
|
|
}
|
|
|
|
|
2007-11-17 22:34:28 +01:00
|
|
|
QString Svg::elementAtPoint(const QPoint &point) const
|
|
|
|
{
|
|
|
|
d->createRenderer();
|
|
|
|
QSizeF naturalSize = d->renderer->defaultSize();
|
|
|
|
qreal dx = d->size.width() / naturalSize.width();
|
|
|
|
qreal dy = d->size.height() / naturalSize.height();
|
2008-01-08 02:25:09 +01:00
|
|
|
//kDebug() << point << "is really" << QPoint(point.x() *dx, naturalSize.height() - point.y() * dy);
|
2007-11-17 22:34:28 +01:00
|
|
|
|
|
|
|
return QString(); // d->renderer->elementAtPoint(QPoint(point.x() *dx, naturalSize.height() - point.y() * dy));
|
|
|
|
}
|
|
|
|
|
2007-07-23 02:50:10 +02:00
|
|
|
bool Svg::isValid() const
|
|
|
|
{
|
|
|
|
d->createRenderer();
|
|
|
|
return d->renderer->isValid();
|
|
|
|
}
|
|
|
|
|
2008-04-17 11:09:48 +02:00
|
|
|
void Svg::setContainsMultipleImages(bool multiple)
|
2007-05-29 22:27:51 +02:00
|
|
|
{
|
2008-04-17 11:09:48 +02:00
|
|
|
d->multipleImages = multiple;
|
2007-05-29 22:27:51 +02:00
|
|
|
}
|
|
|
|
|
2008-04-17 11:09:48 +02:00
|
|
|
bool Svg::containsMultipleImages() const
|
2007-05-29 22:27:51 +02:00
|
|
|
{
|
2008-04-17 11:09:48 +02:00
|
|
|
return d->multipleImages;
|
2007-05-29 22:27:51 +02:00
|
|
|
}
|
|
|
|
|
2008-04-16 22:48:53 +02:00
|
|
|
void Svg::setImagePath(const QString &svgFilePath)
|
2007-12-19 21:29:22 +01:00
|
|
|
{
|
2008-02-07 05:33:57 +01:00
|
|
|
d->setImagePath(svgFilePath, this);
|
2007-12-19 21:29:22 +01:00
|
|
|
d->eraseRenderer();
|
2008-04-24 22:12:24 +02:00
|
|
|
emit repaintNeeded();
|
2007-12-19 21:29:22 +01:00
|
|
|
}
|
|
|
|
|
2008-04-16 22:48:53 +02:00
|
|
|
QString Svg::imagePath() const
|
2007-12-19 21:29:22 +01:00
|
|
|
{
|
2008-02-06 02:26:18 +01:00
|
|
|
return d->themed ? d->themePath : d->path;
|
2007-12-19 21:29:22 +01:00
|
|
|
}
|
|
|
|
|
2007-03-08 00:27:37 +01:00
|
|
|
} // Plasma namespace
|
|
|
|
|
|
|
|
#include "svg.moc"
|
|
|
|
|