accept file:// urls as absolute paths
This commit is contained in:
parent
9f0765b002
commit
819b42932d
@ -169,12 +169,17 @@ QString SvgPrivate::cachePath(const QString &path, const QSize &size)
|
|||||||
|
|
||||||
bool SvgPrivate::setImagePath(const QString &imagePath)
|
bool SvgPrivate::setImagePath(const QString &imagePath)
|
||||||
{
|
{
|
||||||
const bool isThemed = !QDir::isAbsolutePath(imagePath);
|
QString actualPath = imagePath;
|
||||||
|
if (imagePath.startsWith("file://")) {
|
||||||
|
//length of file://
|
||||||
|
actualPath = actualPath.mid(7);
|
||||||
|
}
|
||||||
|
const bool isThemed = !QDir::isAbsolutePath(actualPath);
|
||||||
|
|
||||||
// lets check to see if we're already set to this file
|
// lets check to see if we're already set to this file
|
||||||
if (isThemed == themed &&
|
if (isThemed == themed &&
|
||||||
((themed && themePath == imagePath) ||
|
((themed && themePath == actualPath) ||
|
||||||
(!themed && path == imagePath))) {
|
(!themed && path == actualPath))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,12 +203,12 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
|
|||||||
elementsWithSizeHints.clear();
|
elementsWithSizeHints.clear();
|
||||||
|
|
||||||
if (themed) {
|
if (themed) {
|
||||||
themePath = imagePath;
|
themePath = actualPath;
|
||||||
themeFailed = false;
|
themeFailed = false;
|
||||||
QObject::connect(actualTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
QObject::connect(actualTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
||||||
} else if (QFile::exists(imagePath)) {
|
} else if (QFile::exists(actualPath)) {
|
||||||
QObject::connect(cacheAndColorsTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()), Qt::UniqueConnection);
|
QObject::connect(cacheAndColorsTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()), Qt::UniqueConnection);
|
||||||
path = imagePath;
|
path = actualPath;
|
||||||
} else {
|
} else {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// qDebug() << "file '" << path << "' does not exist!";
|
// qDebug() << "file '" << path << "' does not exist!";
|
||||||
@ -215,7 +220,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
|
|||||||
|
|
||||||
// also images with absolute path needs to have a natural size initialized,
|
// 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
|
// even if looks a bit weird using Theme to store non-themed stuff
|
||||||
if (themed || QFile::exists(imagePath)) {
|
if (themed || QFile::exists(actualPath)) {
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
if (cacheAndColorsTheme()->findInRectsCache(path, "_Natural", rect)) {
|
if (cacheAndColorsTheme()->findInRectsCache(path, "_Natural", rect)) {
|
||||||
naturalSize = rect.size();
|
naturalSize = rect.size();
|
||||||
@ -229,7 +234,7 @@ bool SvgPrivate::setImagePath(const QString &imagePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!themed) {
|
if (!themed) {
|
||||||
QFile f(imagePath);
|
QFile f(actualPath);
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
lastModified = info.lastModified().toTime_t();
|
lastModified = info.lastModified().toTime_t();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user