diff options
| author | Caroline Chao <caroline.chao@digia.com> | 2013-06-11 09:13:44 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-13 16:19:14 +0200 |
| commit | 41e13d3746c8b7b5cd550091c63fd8ab066422cf (patch) | |
| tree | d9f24de1b9949abffd1bda3fa775c0ba1a5cc272 /src/private/qquickcontrolsettings.cpp | |
| parent | 3b10c17e34bd6da6278600f57a0ecafe5eb58431 (diff) | |
Add qml/js files in resource files
To make deployment of Qt Quick Controls based
applications easier.
Task-number: QTBUG-31565
Change-Id: I0b8af2864ef0dc9121eed3189ced64712bdb3d20
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/private/qquickcontrolsettings.cpp')
| -rw-r--r-- | src/private/qquickcontrolsettings.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index e2daa17fa..d2853982e 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -63,18 +63,24 @@ static QString styleImportName() return QFileInfo(name).fileName(); } -static QString styleImportPath(QQmlEngine *engine, const QString &styleName) +static QString styleImportPath(QQmlEngine *engine, const QString &styleName, bool &fromResources) { QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); QFileInfo info(path); if (info.isRelative()) { + bool found = false; foreach (const QString &import, engine->importPathList()) { QDir dir(import + QLatin1String("/QtQuick/Controls/Styles")); if (dir.exists(styleName)) { + found = true; path = dir.absolutePath(); break; } } + if (!found) { + fromResources = true; + path = "qrc:"; + } } else { path = info.absolutePath(); } @@ -83,23 +89,27 @@ static QString styleImportPath(QQmlEngine *engine, const QString &styleName) QQuickControlSettings::QQuickControlSettings(QQmlEngine *engine) { + m_fromResources = false; m_name = styleImportName(); - m_path = styleImportPath(engine, m_name); + m_path = styleImportPath(engine, m_name, m_fromResources); - if (!QFile::exists(styleFilePath())) { + if (!m_fromResources && !QFile::exists(styleFilePath())) { QString unknownStyle = m_name; m_name = defaultStyleName(); - m_path = styleImportPath(engine, m_name); - qWarning() << "WARNING: Cannot find style" << unknownStyle << "- fallback:" << styleFilePath(); + m_path = styleImportPath(engine, m_name, m_fromResources); + qWarning() << "WARNING: Cannot find style" << unknownStyle << " locally - fallback:" << styleFilePath(); } connect(this, SIGNAL(styleNameChanged()), SIGNAL(styleChanged())); connect(this, SIGNAL(stylePathChanged()), SIGNAL(styleChanged())); } -QUrl QQuickControlSettings::style() const +QString QQuickControlSettings::style() const { - return QUrl::fromLocalFile(styleFilePath()); + if (m_fromResources) + return styleFilePath(); + else + return QUrl::fromLocalFile(styleFilePath()).toString(); } QString QQuickControlSettings::styleName() const |
