aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/virtualkeyboard/3rdparty/hunspell/hunspell.pro2
-rw-r--r--src/virtualkeyboard/3rdparty/pinyin/pinyin.pro3
-rw-r--r--src/virtualkeyboard/content/InputPanel.qml2
-rw-r--r--src/virtualkeyboard/content/components/Keyboard.qml9
-rw-r--r--src/virtualkeyboard/declarativeinputcontext.cpp12
-rw-r--r--src/virtualkeyboard/declarativeinputcontext.h2
-rw-r--r--src/virtualkeyboard/declarativesettings.cpp12
-rw-r--r--src/virtualkeyboard/generateresource.prf27
-rw-r--r--src/virtualkeyboard/plugin.cpp52
-rw-r--r--src/virtualkeyboard/plugin.h37
-rw-r--r--src/virtualkeyboard/styles/styles.pro40
-rw-r--r--src/virtualkeyboard/styles/styles_plugin.cpp10
-rw-r--r--src/virtualkeyboard/virtualkeyboard.pro92
-rw-r--r--src/virtualkeyboard/xcbinputpanel.cpp3
14 files changed, 251 insertions, 52 deletions
diff --git a/src/virtualkeyboard/3rdparty/hunspell/hunspell.pro b/src/virtualkeyboard/3rdparty/hunspell/hunspell.pro
index 1b5b1678..4dcc72fb 100644
--- a/src/virtualkeyboard/3rdparty/hunspell/hunspell.pro
+++ b/src/virtualkeyboard/3rdparty/hunspell/hunspell.pro
@@ -9,6 +9,8 @@ CONFIG += precompile_header warn_off
debug {
DEFINES += HUNSPELL_WARNING_ON
}
+CONFIG -= qtquickcompiler # QTRD-3292
+
dll {
android-no-sdk {
target.path = /system/lib
diff --git a/src/virtualkeyboard/3rdparty/pinyin/pinyin.pro b/src/virtualkeyboard/3rdparty/pinyin/pinyin.pro
index 2051c7cf..e688ac9d 100644
--- a/src/virtualkeyboard/3rdparty/pinyin/pinyin.pro
+++ b/src/virtualkeyboard/3rdparty/pinyin/pinyin.pro
@@ -6,6 +6,8 @@ CONFIG += dll
QMAKE_CXXFLAGS += -Wno-unused-parameter
#CONFIG += staticlib
#CONFIG += precompile_header warn_off
+CONFIG -= qtquickcompiler # QTRD-3292
+
dll {
android-no-sdk {
target.path = /system/lib
@@ -61,4 +63,3 @@ HEADERS += \
OTHER_FILES +=\
data/rawdict_utf16_65105_freq.txt \
data/valid_utf16.txt
-
diff --git a/src/virtualkeyboard/content/InputPanel.qml b/src/virtualkeyboard/content/InputPanel.qml
index 33726563..c9d46fa9 100644
--- a/src/virtualkeyboard/content/InputPanel.qml
+++ b/src/virtualkeyboard/content/InputPanel.qml
@@ -17,7 +17,7 @@
****************************************************************************/
import QtQuick 2.0
-import "components"
+import QtQuick.Enterprise.VirtualKeyboard 1.1
/*!
\qmltype InputPanel
diff --git a/src/virtualkeyboard/content/components/Keyboard.qml b/src/virtualkeyboard/content/components/Keyboard.qml
index e23635fc..33d08fe4 100644
--- a/src/virtualkeyboard/content/components/Keyboard.qml
+++ b/src/virtualkeyboard/content/components/Keyboard.qml
@@ -283,8 +283,13 @@ Item {
}
FolderListModel {
id: layoutsModel
- folder: "../layouts"
nameFilters: ["$"]
+ Component.onCompleted: {
+ if (InputContext.fileExists("qrc:/content/layouts"))
+ layoutsModel.folder = "qrc:/content/layouts"
+ else
+ layoutsModel.folder = "../layouts"
+ }
}
Connections {
target: layoutsModel
@@ -878,6 +883,8 @@ Item {
}
function getLayoutFile(localeName, layoutType) {
+ if (localeName === "" || layoutType === "")
+ return ""
return layoutsModel.folder + "/" + localeName + "/" + layoutType + ".qml"
}
diff --git a/src/virtualkeyboard/declarativeinputcontext.cpp b/src/virtualkeyboard/declarativeinputcontext.cpp
index dff138eb..c30ed34c 100644
--- a/src/virtualkeyboard/declarativeinputcontext.cpp
+++ b/src/virtualkeyboard/declarativeinputcontext.cpp
@@ -28,6 +28,10 @@
#include <QGuiApplication>
#include <QtCore/private/qobject_p.h>
+#ifdef COMPILING_QML
+#include "qrclayoutsindex.h"
+#endif
+
/*!
\qmlmodule QtQuick.Enterprise.VirtualKeyboard 1.1
@@ -395,9 +399,15 @@ void DeclarativeInputContext::clear()
emit preeditTextChanged();
}
-bool DeclarativeInputContext::fileExists(const QUrl& fileUrl)
+bool DeclarativeInputContext::fileExists(const QUrl &fileUrl)
{
+#ifdef COMPILING_QML
+ // since this uses compile-time information, new layouts
+ // can not be added dynamically
+ return layoutsDir.contains(fileUrl.url());
+#else
return QFile(fileUrl.toLocalFile()).exists();
+#endif
}
bool DeclarativeInputContext::hasEnterKeyAction(QObject *item) const
diff --git a/src/virtualkeyboard/declarativeinputcontext.h b/src/virtualkeyboard/declarativeinputcontext.h
index bc650d74..20e205e6 100644
--- a/src/virtualkeyboard/declarativeinputcontext.h
+++ b/src/virtualkeyboard/declarativeinputcontext.h
@@ -82,7 +82,7 @@ public:
Q_INVOKABLE void clear();
// Helper functions
- Q_INVOKABLE bool fileExists(const QUrl& fileUrl);
+ Q_INVOKABLE bool fileExists(const QUrl &fileUrl);
Q_INVOKABLE bool hasEnterKeyAction(QObject *item) const;
signals:
diff --git a/src/virtualkeyboard/declarativesettings.cpp b/src/virtualkeyboard/declarativesettings.cpp
index 26eba375..fc932764 100644
--- a/src/virtualkeyboard/declarativesettings.cpp
+++ b/src/virtualkeyboard/declarativesettings.cpp
@@ -20,7 +20,8 @@
#include "settings.h"
#include "virtualkeyboarddebug.h"
#include <QQmlEngine>
-#include <QFile>
+#include <QFileInfo>
+#include <QDir>
#include <QtCore/private/qobject_p.h>
class DeclarativeSettingsPrivate : public QObjectPrivate
@@ -54,7 +55,14 @@ public:
styleImportPathList << importPathList.last() + "/QtQuick/Enterprise/VirtualKeyboard/Styles/";
foreach (const QString &styleImportPath, styleImportPathList) {
QString filePath = buildStyleFilePath(styleImportPath, name);
- if (QFile(filePath).exists())
+ bool pathExist = false;
+#ifdef COMPILING_QML
+ // qtquickcompiler removes *.qml file paths from qrc file, but keeps directories - QTRD-3268
+ pathExist = QFileInfo(filePath).dir().exists();
+#else
+ pathExist = QFileInfo(filePath).exists();
+#endif
+ if (pathExist)
return buildStyleImportPath(styleImportPath, name);
}
return QString();
diff --git a/src/virtualkeyboard/generateresource.prf b/src/virtualkeyboard/generateresource.prf
new file mode 100644
index 00000000..2d6c3a7e
--- /dev/null
+++ b/src/virtualkeyboard/generateresource.prf
@@ -0,0 +1,27 @@
+defineReplace(generate_resource) {
+ GENERATED_FILE = $$OUT_PWD/$$1
+ INCLUDED_FILES = $$2
+ GENERATED_CONTENT = \
+ "<RCC>"
+
+ RESOURCE_PREFIX = ""
+ for (FILE, INCLUDED_FILES) {
+ RELATIVE_PATH = $$relative_path($$absolute_path($$FILE), $$_PRO_FILE_PWD_)
+ SUB_FOLDER = /$$dirname(RELATIVE_PATH)
+ !equals(SUB_FOLDER, $$RESOURCE_PREFIX) {
+ !isEmpty(RESOURCE_PREFIX): GENERATED_CONTENT += "</qresource>"
+ RESOURCE_PREFIX = $$SUB_FOLDER
+ GENERATED_CONTENT += "<qresource prefix=\"$$RESOURCE_PREFIX\">"
+ }
+ ABSOLUTE_PATH = $$absolute_path($$FILE)
+ ALIAS_NAME = $$basename(FILE)
+ GENERATED_CONTENT += "<file alias=\"$$ALIAS_NAME\">$$ABSOLUTE_PATH</file>"
+ }
+ !isEmpty(RESOURCE_PREFIX): GENERATED_CONTENT += "</qresource>"
+
+ GENERATED_CONTENT += \
+ "</RCC>"
+ write_file($$GENERATED_FILE, GENERATED_CONTENT)|error("Failed to write resource file!")
+
+ return($$GENERATED_FILE)
+}
diff --git a/src/virtualkeyboard/plugin.cpp b/src/virtualkeyboard/plugin.cpp
index 65c1f019..30e59132 100644
--- a/src/virtualkeyboard/plugin.cpp
+++ b/src/virtualkeyboard/plugin.cpp
@@ -16,11 +16,7 @@
**
****************************************************************************/
-#include <QtQml>
-#include <QStringList>
-#include <qpa/qplatforminputcontextplugin_p.h>
-
-#include "platforminputcontext.h"
+#include "plugin.h"
#include "declarativeinputcontext.h"
#include "declarativeinputengine.h"
#include "declarativeshifthandler.h"
@@ -46,16 +42,6 @@ static QObject *createInputContextModule(QQmlEngine *engine, QJSEngine *scriptEn
return new DeclarativeInputContext(platformInputContext);
}
-class PlatformInputContextPlugin : public QPlatformInputContextPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "qtvirtualkeyboard.json")
-
-public:
- QStringList keys() const;
- QPlatformInputContext *create(const QString&, const QStringList&);
-};
-
QStringList PlatformInputContextPlugin::keys() const
{
return QStringList(QStringLiteral("qtvirtualkeyboard"));
@@ -64,7 +50,15 @@ QStringList PlatformInputContextPlugin::keys() const
QPlatformInputContext *PlatformInputContextPlugin::create(const QString &system, const QStringList &paramList)
{
Q_UNUSED(paramList);
-
+#ifdef COMPILING_QML
+ Q_INIT_RESOURCE(content_qtquickcompiler);
+ Q_INIT_RESOURCE(default_style_qtquickcompiler);
+ Q_INIT_RESOURCE(retro_style_qtquickcompiler);
+#else
+ Q_INIT_RESOURCE(default_style);
+ Q_INIT_RESOURCE(retro_style);
+#endif
+ const QString path(QT_VIRTUALKEYBOARD_IMPORT_PATH);
qmlRegisterSingletonType<DeclarativeInputContext>("QtQuick.Enterprise.VirtualKeyboard", 1, 0, "InputContext", createInputContextModule);
qmlRegisterUncreatableType<DeclarativeInputEngine>("QtQuick.Enterprise.VirtualKeyboard", 1, 0, "InputEngine", "Cannot create input method engine");
qmlRegisterUncreatableType<DeclarativeShiftHandler>("QtQuick.Enterprise.VirtualKeyboard", 1, 0, "ShiftHandler", "Cannot create shift handler");
@@ -82,10 +76,32 @@ QPlatformInputContext *PlatformInputContextPlugin::create(const QString &system,
qmlRegisterType<EnterKeyAction>("QtQuick.Enterprise.VirtualKeyboard", 1, 0, "EnterKeyAction");
qmlRegisterSingletonType<DeclarativeSettings>("QtQuick.Enterprise.VirtualKeyboard.Settings", 1, 0, "VirtualKeyboardSettings", DeclarativeSettings::registerSettingsModule);
+ qmlRegisterType(QUrl(path + "InputPanel.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "InputPanel");
+ const QString componentsPath = path + QLatin1Literal("components/");
+ qmlRegisterType(QUrl(componentsPath + "AlternativeKeys.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "AlternativeKeys");
+ qmlRegisterType(QUrl(componentsPath + "AutoScroller.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "AutoScroller");
+ qmlRegisterType(QUrl(componentsPath + "BackspaceKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "BackspaceKey");
+ qmlRegisterType(QUrl(componentsPath + "BaseKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "BaseKey");
+ qmlRegisterType(QUrl(componentsPath + "ChangeLanguageKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "ChangeLanguageKey");
+ qmlRegisterType(QUrl(componentsPath + "CharacterPreviewBubble.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "CharacterPreviewBubble");
+ qmlRegisterType(QUrl(componentsPath + "EnterKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "EnterKey");
+ qmlRegisterType(QUrl(componentsPath + "FillerKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "FillerKey");
+ qmlRegisterType(QUrl(componentsPath + "HideKeyboardKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "HideKeyboardKey");
+ qmlRegisterType(QUrl(componentsPath + "KeyboardColumn.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "KeyboardColumn");
+ qmlRegisterType(QUrl(componentsPath + "KeyboardLayout.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "KeyboardLayout");
+ qmlRegisterType(QUrl(componentsPath + "KeyboardLayoutLoader.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 1, "KeyboardLayoutLoader");
+ qmlRegisterType(QUrl(componentsPath + "Keyboard.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "Keyboard");
+ qmlRegisterType(QUrl(componentsPath + "KeyboardRow.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "KeyboardRow");
+ qmlRegisterType(QUrl(componentsPath + "Key.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "Key");
+ qmlRegisterType(QUrl(componentsPath + "MultiSoundEffect.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 1, "MultiSoundEffect");
+ qmlRegisterType(QUrl(componentsPath + "MultitapInputMethod.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "MultitapInputMethod");
+ qmlRegisterType(QUrl(componentsPath + "NumberKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "NumberKey");
+ qmlRegisterType(QUrl(componentsPath + "ShiftKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "ShiftKey");
+ qmlRegisterType(QUrl(componentsPath + "SpaceKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "SpaceKey");
+ qmlRegisterType(QUrl(componentsPath + "SymbolModeKey.qml"), "QtQuick.Enterprise.VirtualKeyboard", 1, 0, "SymbolModeKey");
+
if (system.compare(system, QStringLiteral("qtvirtualkeyboard"), Qt::CaseInsensitive) == 0) {
platformInputContext = new PlatformInputContext();
}
return platformInputContext;
}
-
-#include "plugin.moc"
diff --git a/src/virtualkeyboard/plugin.h b/src/virtualkeyboard/plugin.h
new file mode 100644
index 00000000..1fae521a
--- /dev/null
+++ b/src/virtualkeyboard/plugin.h
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of the Qt Quick Enterprise Controls add-on.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
+#ifndef PLUGIN_H
+#define PLUGIN_H
+
+#include <QtQml>
+#include <qpa/qplatforminputcontextplugin_p.h>
+#include "platforminputcontext.h"
+#include <QStringList>
+
+class PlatformInputContextPlugin : public QPlatformInputContextPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "qtvirtualkeyboard.json")
+
+public:
+ QStringList keys() const;
+ QPlatformInputContext *create(const QString&, const QStringList&);
+};
+
+#endif // PLUGIN_H
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");
}
diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro
index 0249f7e4..099b9ac2 100644
--- a/src/virtualkeyboard/virtualkeyboard.pro
+++ b/src/virtualkeyboard/virtualkeyboard.pro
@@ -1,15 +1,15 @@
TEMPLATE = lib
TARGET = qtvirtualkeyboardplugin
android-no-sdk {
- TARGETPATH = /system/plugins/platforminputcontexts
+ INSTALL_PATH = /system/plugins/platforminputcontexts
QMLPATH = /system/qml/QtQuick/Enterprise/VirtualKeyboard
DATAPATH = /system/qtvirtualkeyboard
} else:!isEmpty(CROSS_COMPILE) {
- TARGETPATH = /usr/local/Qt-$$[QT_VERSION]/plugins/platforminputcontexts
+ INSTALL_PATH = /usr/local/Qt-$$[QT_VERSION]/plugins/platforminputcontexts
QMLPATH = /usr/local/Qt-$$[QT_VERSION]/qml/QtQuick/Enterprise/VirtualKeyboard
DATAPATH = /usr/local/Qt-$$[QT_VERSION]/qtvirtualkeyboard
} else {
- TARGETPATH = $$[QT_INSTALL_PLUGINS]/platforminputcontexts
+ INSTALL_PATH = $$[QT_INSTALL_PLUGINS]/platforminputcontexts
QMLPATH = $$[QT_INSTALL_QML]/QtQuick/Enterprise/VirtualKeyboard
DATAPATH = $$[QT_INSTALL_DATA]/qtvirtualkeyboard
}
@@ -17,7 +17,7 @@ android-no-sdk {
QMAKE_DOCS = $$PWD/doc/qtvirtualkeyboard.qdocconf
include(doc/doc.pri)
-target.path = $$TARGETPATH
+target.path = $$INSTALL_PATH
INSTALLS += target
QT += quick gui gui-private core-private
@@ -55,7 +55,8 @@ HEADERS += platforminputcontext.h \
enterkeyaction.h \
enterkeyactionattachedtype.h \
settings.h \
- declarativesettings.h
+ declarativesettings.h \
+ plugin.h
RESOURCES += \
content/styles/default/default_style.qrc \
@@ -66,12 +67,10 @@ retro-style {
DEFINES += QT_VIRTUALKEYBOARD_DEFAULT_STYLE=\\\"default\\\"
}
-OTHER_FILES += content/InputPanel.qml \
- content/qmldir \
- content/components/*.qml \
- content/layouts \
+OTHER_FILES += content/layouts \
content/styles/default/*.qml \
- content/styles/retro/*.qml
+ content/styles/retro/*.qml \
+ generateresource.prf
OTHER += qtvirtualkeyboard.json
@@ -85,12 +84,19 @@ OTHER += qtvirtualkeyboard.json
HEADERS += appinputpanel.h
}
-DEFINES += QT_VIRTUALKEYBOARD_IMPORT_PATH=\\\"$$QMLPATH\\\"
-qml.files = content/*.qml \
- content/qmldir \
+qtquickcompiler {
+ TARGETPATH = QtQuick/Enterprise/VirtualKeyboard
+ DEFINES += COMPILING_QML
+ DEFINES += QT_VIRTUALKEYBOARD_IMPORT_PATH=\\\"qrc:/content/\\\"
+} else {
+ DEFINES += QT_VIRTUALKEYBOARD_IMPORT_PATH=\\\"file://$$QMLPATH/\\\"
+}
+
+qml.files = \
+ content/*.qml \
content/components
qml.path = $$QMLPATH
-INSTALLS += qml
+
pinyin: qml_layouts.files = \
content/layouts/en_GB \
content/layouts/zh_CN
@@ -111,7 +117,63 @@ else: qml_layouts.files = \
content/layouts/ru_RU \
content/layouts/sv_SE
qml_layouts.path = $$QMLPATH/layouts
-INSTALLS += qml_layouts
+
+qtquickcompiler {
+ QML_FILES += content/InputPanel.qml \
+ content/qmldir \
+ content/components/AlternativeKeys.qml \
+ content/components/AutoScroller.qml \
+ content/components/BackspaceKey.qml \
+ content/components/BaseKey.qml \
+ content/components/ChangeLanguageKey.qml \
+ content/components/CharacterPreviewBubble.qml \
+ content/components/EnterKey.qml \
+ content/components/FillerKey.qml \
+ content/components/HideKeyboardKey.qml \
+ content/components/KeyboardColumn.qml \
+ content/components/KeyboardLayoutLoader.qml \
+ content/components/KeyboardLayout.qml \
+ content/components/Keyboard.qml \
+ content/components/KeyboardRow.qml \
+ content/components/Key.qml \
+ content/components/MultiSoundEffect.qml \
+ content/components/MultitapInputMethod.qml \
+ content/components/NumberKey.qml \
+ content/components/ShiftKey.qml \
+ content/components/SpaceKey.qml \
+ content/components/SymbolModeKey.qml
+
+ # generate qrc file, this should work out-of-box with later releases of qtquickcompiler
+ include(generateresource.prf)
+ resource_files = $$QML_FILES
+ for (layoutdir, qml_layouts.files) {
+ resource_files += $$files($$absolute_path($$layoutdir/*), $$_PRO_FILE_PWD_)
+ }
+ RESOURCES += $$generate_resource(content.qrc, $$resource_files)
+
+ # workaround that qtquickcompiler removes *.qml file paths from qrc file (QTRD-3268)
+ LAYOUTS_INDEX_FILE = $$OUT_PWD/qrclayoutsindex.h
+ LAYOUTS_INDEX_CONTENT = "const QStringList layoutsDir = QStringList() " \
+ "<< \"qrc:/content/layouts\""
+
+ for (layoutdir, qml_layouts.files) {
+ layoutfiles = $$files($$absolute_path($$layoutdir/*), $$_PRO_FILE_PWD_)
+ for (qmlfile, layoutfiles) {
+ relativepath = $$relative_path($$qmlfile, $$_PRO_FILE_PWD_)
+ LAYOUTS_INDEX_CONTENT += "<< \"qrc:/$$relativepath\""
+ }
+ }
+
+ LAYOUTS_INDEX_CONTENT += ";"
+ write_file($$LAYOUTS_INDEX_FILE, LAYOUTS_INDEX_CONTENT)|error("Failed to write resource file!")
+
+ qml.files = content/qmldir
+ QMAKE_CLEAN += $$GENERATED_FILE $$LAYOUTS_INDEX_FILE
+} else {
+ qml.files += content/qmldir
+ INSTALLS += qml_layouts
+}
+INSTALLS += qml
!disable-hunspell {
exists(3rdparty/hunspell/src/hunspell/hunspell.h) {
diff --git a/src/virtualkeyboard/xcbinputpanel.cpp b/src/virtualkeyboard/xcbinputpanel.cpp
index 0fb5f92d..b2760e91 100644
--- a/src/virtualkeyboard/xcbinputpanel.cpp
+++ b/src/virtualkeyboard/xcbinputpanel.cpp
@@ -108,8 +108,7 @@ void XcbInputPanel::createView()
d->view->setFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus | Qt::BypassWindowManagerHint);
d->view->setColor(QColor(Qt::transparent));
const QString virtualKeyboardImportPath(QT_VIRTUALKEYBOARD_IMPORT_PATH);
- d->view->engine()->addImportPath(virtualKeyboardImportPath);
- d->view->setSource(QUrl::fromLocalFile(virtualKeyboardImportPath+"/InputPanel.qml"));
+ d->view->setSource(QUrl(virtualKeyboardImportPath + "InputPanel.qml"));
/* Destroy the view along with the last window in application. */
connect(qGuiApp, SIGNAL(lastWindowClosed()), SLOT(destroyView()));
}