summaryrefslogtreecommitdiffstats
path: root/src/declarative/extra
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-14 03:09:38 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-14 03:09:38 (GMT)
commit403350d5d6d85fb1ef9718401a6a60af313eaf5a (patch)
tree6b8fa0c0de673a5f34ab8a74ae76d8742ce4fc67 /src/declarative/extra
parent3491cdb2c1c9184adfb0fab1e636afd784a6565e (diff)
downloadQt-403350d5d6d85fb1ef9718401a6a60af313eaf5a.zip
Qt-403350d5d6d85fb1ef9718401a6a60af313eaf5a.tar.gz
Qt-403350d5d6d85fb1ef9718401a6a60af313eaf5a.tar.bz2
Workaround QUrl::toLocalFile not knowing about qrc:
QNetworkAccess does similar things.
Diffstat (limited to 'src/declarative/extra')
-rw-r--r--src/declarative/extra/qmlfontloader.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/declarative/extra/qmlfontloader.cpp b/src/declarative/extra/qmlfontloader.cpp
index 66c8567..4a447de 100644
--- a/src/declarative/extra/qmlfontloader.cpp
+++ b/src/declarative/extra/qmlfontloader.cpp
@@ -92,6 +92,15 @@ QmlFontLoader::~QmlFontLoader()
{
}
+static QString toLocalFileOrQrc(const QUrl& url)
+{
+ QString r = url.toLocalFile();
+ if (r.isEmpty() && url.scheme() == QLatin1String("qrc"))
+ r = QLatin1Char(':') + url.path();
+ return r;
+}
+
+
/*!
\qmlproperty url FontLoader::source
The url of the font to load.
@@ -112,8 +121,9 @@ void QmlFontLoader::setSource(const QUrl &url)
d->status = Loading;
emit statusChanged();
#ifndef QT_NO_LOCALFILE_OPTIMIZED_QML
- if (d->url.scheme() == QLatin1String("file")) {
- QFile file(d->url.toLocalFile());
+ QString lf = toLocalFileOrQrc(d->url);
+ if (!lf.isEmpty()) {
+ QFile file(lf);
file.open(QIODevice::ReadOnly);
QByteArray ba = file.readAll();
d->addFontToDatabase(ba);