From 6eac099fa98b6dbe5a01ad90e4a1348729b1332b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Sat, 28 Sep 2019 13:26:47 +0300 Subject: Android: Always load qml files from resources The QML files on Android are now available in :/android_rcc_bundle/qml folder, this way we don't need to extract them at very first start up. [ChangeLog][Android] Always load qml files from resources (:/android_rcc_bundle/qml) Change-Id: Ib905e5d5e1577d99bb89e7e0d237fa8b24a1e95f Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/controls/Styles/Android/qquickandroidstyle.cpp | 6 +++--- src/controls/Styles/Android/qquickandroidstyle_p.h | 3 ++- src/controls/plugin.cpp | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/controls/Styles/Android/qquickandroidstyle.cpp b/src/controls/Styles/Android/qquickandroidstyle.cpp index 0c57d795..36fe0e82 100644 --- a/src/controls/Styles/Android/qquickandroidstyle.cpp +++ b/src/controls/Styles/Android/qquickandroidstyle.cpp @@ -85,11 +85,11 @@ QByteArray QQuickAndroidStyle1::data() const return m_data; } -QString QQuickAndroidStyle1::filePath(const QString &fileName) const +QUrl QQuickAndroidStyle1::filePath(const QString &fileName) const { if (!fileName.isEmpty()) - return m_path + QFileInfo(fileName).fileName(); - return QString(); + return QUrl::fromLocalFile(m_path + QFileInfo(fileName).fileName()); + return {}; } QColor QQuickAndroidStyle1::colorValue(uint value) const diff --git a/src/controls/Styles/Android/qquickandroidstyle_p.h b/src/controls/Styles/Android/qquickandroidstyle_p.h index 6911eb8d..856b5753 100644 --- a/src/controls/Styles/Android/qquickandroidstyle_p.h +++ b/src/controls/Styles/Android/qquickandroidstyle_p.h @@ -41,6 +41,7 @@ #define QQUICKANDROIDSTYLE_P_H #include +#include #include QT_BEGIN_NAMESPACE @@ -57,7 +58,7 @@ public: QByteArray data() const; Q_INVOKABLE QColor colorValue(uint value) const; - Q_INVOKABLE QString filePath(const QString &fileName) const; + Q_INVOKABLE QUrl filePath(const QString &fileName) const; enum Gravity { NO_GRAVITY = 0x0000, diff --git a/src/controls/plugin.cpp b/src/controls/plugin.cpp index 82eef800..6d34f285 100644 --- a/src/controls/plugin.cpp +++ b/src/controls/plugin.cpp @@ -239,30 +239,38 @@ void QtQuickControls1Plugin::initializeEngine(QQmlEngine *engine, const char *ur QString QtQuickControls1Plugin::fileLocation() const { -#ifndef QT_STATIC +#ifdef Q_OS_ANDROID + return "qrc:/android_rcc_bundle/qml/QtQuick/Controls"; +#else +# ifndef QT_STATIC if (isLoadedFromResource()) return "qrc:/QtQuick/Controls"; return baseUrl().toString(); -#else +# else return "qrc:/qt-project.org/imports/QtQuick/Controls"; +# endif #endif } bool QtQuickControls1Plugin::isLoadedFromResource() const { -#ifdef QT_STATIC +#ifdef Q_OS_ANDROID + return true; +#else +# ifdef QT_STATIC // When static it is included automatically // for us. return false; -#endif -#if defined(ALWAYS_LOAD_FROM_RESOURCES) +# endif +# if defined(ALWAYS_LOAD_FROM_RESOURCES) return true; -#else +# else // If one file is missing, it will load all the files from the resource QFile file(baseUrl().toLocalFile() + "/ApplicationWindow.qml"); if (!file.exists()) return true; return false; +# endif #endif } -- cgit v1.2.1