aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/styles
diff options
context:
space:
mode:
authorGatis Paeglis <gatis.paeglis@digia.com>2014-07-21 12:09:37 +0200
committerGatis Paeglis <gatis.paeglis@digia.com>2014-08-28 17:17:56 +0300
commitee4dcc89b81a3a51ef2a5aa934084ddbe004dc44 (patch)
treea6fea6fc48e37b84d00e23c1aeb7d67edab57031 /src/virtualkeyboard/styles
parent30a9a7f249dbe628d27922f72038109a91526489 (diff)
Add support for pre-compiling qml files
Adding the Qt Quick Compiler support requires utilizing Qt Resource System. This is achieved by generating the required resource files during execution of qmake and using qrc URL paths in the vkb plugin when in pre-compiled qml mode. The configure option to enable pre-compiled qml support is: CONFIG+=qtquickcompiler When "CONFIG+=qtquickcompiler" configure option is omitted - vkb plugin deploys all the required files on the file system. When "CONFIG+=qtquickcompiler" is set - vkb does not deploy any of the *.qml files. One limitation when using the pre-compiled qml case is that users can not add new layouts dynamically, this feature can be added in later patches. Change-Id: I7f27ea78f14370ee9082d1723f21b1d6230eef42 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'src/virtualkeyboard/styles')
-rw-r--r--src/virtualkeyboard/styles/styles.pro40
-rw-r--r--src/virtualkeyboard/styles/styles_plugin.cpp10
2 files changed, 40 insertions, 10 deletions
diff --git a/src/virtualkeyboard/styles/styles.pro b/src/virtualkeyboard/styles/styles.pro
index a3a625a7..b9e3f13f 100644
--- a/src/virtualkeyboard/styles/styles.pro
+++ b/src/virtualkeyboard/styles/styles.pro
@@ -1,32 +1,54 @@
TEMPLATE = lib
TARGET = qtvirtualkeyboardstylesplugin
android-no-sdk {
- TARGETPATH = /system/qml/QtQuick/Enterprise/VirtualKeyboard/Styles
+ INSTALL_PATH = /system/qml/QtQuick/Enterprise/VirtualKeyboard/Styles
} else:!isEmpty(CROSS_COMPILE) {
- TARGETPATH = /usr/local/Qt-$$[QT_VERSION]/qml/QtQuick/Enterprise/VirtualKeyboard/Styles
+ INSTALL_PATH = /usr/local/Qt-$$[QT_VERSION]/qml/QtQuick/Enterprise/VirtualKeyboard/Styles
} else {
- TARGETPATH = $$[QT_INSTALL_QML]/QtQuick/Enterprise/VirtualKeyboard/Styles
+ INSTALL_PATH = $$[QT_INSTALL_QML]/QtQuick/Enterprise/VirtualKeyboard/Styles
}
QT += qml quick
CONFIG += qt plugin
-target.path = $$TARGETPATH
+target.path = $$INSTALL_PATH
INSTALLS += target
+qtquickcompiler {
+ TARGETPATH = QtQuick/Enterprise/VirtualKeyboard/Styles
+ # without the next line it fails to compile - QTRD-3291
+ CONFIG += qtquickcompiler
+ DEFINES += COMPILING_QML
+ DEFINES += STYLES_IMPORT_PATH=\\\"qrc:/\\\"
+} else {
+ DEFINES += STYLES_IMPORT_PATH=\\\"file://$$INSTALL_PATH/\\\"
+}
+
SOURCES += \
styles_plugin.cpp
HEADERS += \
styles_plugin.h
-OTHER_FILES += \
+QML_FILES += \
+ qmldir \
KeyboardStyle.qml \
KeyPanel.qml \
KeyIcon.qml \
- SelectionListItem.qml \
- qmldir \
+ SelectionListItem.qml
+
+qtquickcompiler {
+ # generate qrc file, this should work out-of-box with later releases of qtquickcompiler
+ include(../generateresource.prf)
+ RESOURCES += $$generate_resource(styles.qrc, $$QML_FILES)
+}
+
+OTHER_FILES += \
plugins.qmltypes
-other.files = $$OTHER_FILES
-other.path = $$TARGETPATH
+qtquickcompiler {
+ other.files = $$OTHER_FILES qmldir
+} else {
+ other.files = $$OTHER_FILES $$QML_FILES
+}
+other.path = $$INSTALL_PATH
INSTALLS += other
diff --git a/src/virtualkeyboard/styles/styles_plugin.cpp b/src/virtualkeyboard/styles/styles_plugin.cpp
index 1c369d33..0a1f6165 100644
--- a/src/virtualkeyboard/styles/styles_plugin.cpp
+++ b/src/virtualkeyboard/styles/styles_plugin.cpp
@@ -28,5 +28,13 @@
void StylesPlugin::registerTypes(const char *uri)
{
- Q_UNUSED(uri)
+#ifdef COMPILING_QML
+ Q_INIT_RESOURCE(styles_qtquickcompiler);
+#endif
+ const QString path(STYLES_IMPORT_PATH);
+ qmlRegisterType(QUrl(path + "KeyboardStyle.qml"), uri, 1, 0, "KeyboardStyle");
+ qmlRegisterType(QUrl(path + "KeyboardStyle.qml"), uri, 1, 1, "KeyboardStyle");
+ qmlRegisterType(QUrl(path + "KeyIcon.qml"), uri, 1, 0, "KeyIcon");
+ qmlRegisterType(QUrl(path + "KeyPanel.qml"), uri, 1, 0, "KeyPanel");
+ qmlRegisterType(QUrl(path + "SelectionListItem.qml"), uri, 1, 0, "SelectionListItem");
}