be absolutely sure to reset the natural size and renderer of the svg when theme or path changing
BUG:194948 svn path=/trunk/KDE/kdelibs/; revision=976576
This commit is contained in:
parent
25b34778ce
commit
f9d7a4bfa2
44
svg.cpp
44
svg.cpp
@ -103,7 +103,7 @@ class SvgPrivate
|
||||
.arg(path);
|
||||
}
|
||||
|
||||
bool setImagePath(const QString &imagePath, Svg *q)
|
||||
bool setImagePath(const QString &imagePath)
|
||||
{
|
||||
bool isThemed = !QDir::isAbsolutePath(imagePath);
|
||||
|
||||
@ -126,6 +126,7 @@ class SvgPrivate
|
||||
themed = isThemed;
|
||||
path.clear();
|
||||
themePath.clear();
|
||||
localRectCache.clear();
|
||||
|
||||
if (themed) {
|
||||
themePath = imagePath;
|
||||
@ -136,7 +137,6 @@ class SvgPrivate
|
||||
kDebug() << "file '" << path << "' does not exist!";
|
||||
}
|
||||
|
||||
|
||||
// check if svg wants colorscheme applied
|
||||
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||
q, SLOT(colorsChanged()));
|
||||
@ -147,7 +147,8 @@ class SvgPrivate
|
||||
q, SLOT(colorsChanged()));
|
||||
}
|
||||
|
||||
//also images with absolute path needs to have a natural size initialized, even if looks a bit weird using Theme to store non-themed stuff
|
||||
// also images with absolute path needs to have a natural size initialized,
|
||||
// even if looks a bit weird using Theme to store non-themed stuff
|
||||
if (themed || QFile::exists(imagePath)) {
|
||||
QRectF rect;
|
||||
bool found = actualTheme()->findInRectsCache(path, "_Natural", rect);
|
||||
@ -155,12 +156,20 @@ class SvgPrivate
|
||||
if (!found) {
|
||||
createRenderer();
|
||||
naturalSize = renderer->defaultSize();
|
||||
//kDebug() << "natural size for" << path << "from renderer is" << naturalSize;
|
||||
actualTheme()->insertIntoRectsCache(path, "_Natural", QRectF(QPointF(0,0), naturalSize));
|
||||
} else {
|
||||
naturalSize = rect.size();
|
||||
//kDebug() << "natural size for" << path << "from cache is" << naturalSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (!themed) {
|
||||
QFile f(imagePath);
|
||||
QFileInfo info(f);
|
||||
lastModified = info.lastModified().toTime_t();
|
||||
}
|
||||
|
||||
return updateNeeded;
|
||||
}
|
||||
|
||||
@ -325,6 +334,7 @@ class SvgPrivate
|
||||
QRectF elementRect = renderer->elementExists(elementId) ?
|
||||
renderer->boundsOnElement(elementId) : QRectF();
|
||||
naturalSize = renderer->defaultSize();
|
||||
//kDebug() << "natural size for" << path << "is" << naturalSize;
|
||||
qreal dx = size.width() / naturalSize.width();
|
||||
qreal dy = size.height() / naturalSize.height();
|
||||
|
||||
@ -365,17 +375,10 @@ class SvgPrivate
|
||||
return;
|
||||
}
|
||||
|
||||
QString newPath = actualTheme()->imagePath(themePath);
|
||||
|
||||
if (path == newPath) {
|
||||
return;
|
||||
}
|
||||
|
||||
path = newPath;
|
||||
//delete d->renderer; we're a KSharedPtr
|
||||
QString currentPath = themePath;
|
||||
themePath.clear();
|
||||
eraseRenderer();
|
||||
|
||||
localRectCache.clear();
|
||||
setImagePath(currentPath);
|
||||
|
||||
//kDebug() << themePath << ">>>>>>>>>>>>>>>>>> theme changed";
|
||||
emit q->repaintNeeded();
|
||||
@ -388,6 +391,7 @@ class SvgPrivate
|
||||
}
|
||||
|
||||
eraseRenderer();
|
||||
//kDebug() << "repaint needed from colorsChanged";
|
||||
emit q->repaintNeeded();
|
||||
}
|
||||
|
||||
@ -554,15 +558,9 @@ bool Svg::containsMultipleImages() const
|
||||
|
||||
void Svg::setImagePath(const QString &svgFilePath)
|
||||
{
|
||||
d->setImagePath(svgFilePath, this);
|
||||
|
||||
if (!d->themed) {
|
||||
QFile f(svgFilePath);
|
||||
QFileInfo info(f);
|
||||
d->lastModified = info.lastModified().toTime_t();
|
||||
}
|
||||
|
||||
d->eraseRenderer();
|
||||
d->setImagePath(svgFilePath);
|
||||
//kDebug() << "repaintNeeded";
|
||||
emit repaintNeeded();
|
||||
}
|
||||
|
||||
@ -589,7 +587,9 @@ void Svg::setTheme(Plasma::Theme *theme)
|
||||
|
||||
d->theme = theme;
|
||||
if (!imagePath().isEmpty()) {
|
||||
setImagePath(imagePath());
|
||||
QString path = imagePath();
|
||||
d->themePath.clear();
|
||||
setImagePath(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user