diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2018-03-31 20:15:36 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2018-04-04 17:23:45 +0000 |
commit | 53695ba6ac58455117d1d335b0c743e91a58594f (patch) | |
tree | 24b71ec8e8918948e3b4c47127b41408cdaa4dc5 | |
parent | 8342c36a8a216481ddacc6aee514077586b08573 (diff) |
Bundle tcime dictionary in the plugin
This change bundles the tcime dictionaries into plugin by default.
[ChangeLog] The tcime dictionary is now bundled in the plugin by default.
Task-number: QTBUG-66198
Change-Id: I0a8ed09e9a32f0ec3fa08efbdb5802d83e727463
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/virtualkeyboard/doc/src/build.qdoc | 6 | ||||
-rw-r--r-- | src/virtualkeyboard/doc/src/deployment-guide.qdoc | 21 | ||||
-rw-r--r-- | src/virtualkeyboard/tcinputmethod.cpp | 22 | ||||
-rw-r--r-- | src/virtualkeyboard/virtualkeyboard.pro | 27 |
4 files changed, 55 insertions, 21 deletions
diff --git a/src/virtualkeyboard/doc/src/build.qdoc b/src/virtualkeyboard/doc/src/build.qdoc index 8753fdc6..cacdfc99 100644 --- a/src/virtualkeyboard/doc/src/build.qdoc +++ b/src/virtualkeyboard/doc/src/build.qdoc @@ -195,6 +195,12 @@ the preferred input method to the configuration, e.g., \c CONFIG+="lang-zh_TW zh \li This option excludes pinyin resources from the plugin binary. This option may be used to reduce the plugin binary size. \row + \li \e no-bundle-tcime + \li \e n/a + \li Disables bundling of tcime resources + \li This option excludes tcime resources from the plugin binary. This option may be + used to reduce the plugin binary size. +\row \li \e static \li Enables static builds of the virtual keyboard \li This option enables \l {Static builds}{static builds}. diff --git a/src/virtualkeyboard/doc/src/deployment-guide.qdoc b/src/virtualkeyboard/doc/src/deployment-guide.qdoc index 264f1557..b59c4e3c 100644 --- a/src/virtualkeyboard/doc/src/deployment-guide.qdoc +++ b/src/virtualkeyboard/doc/src/deployment-guide.qdoc @@ -179,24 +179,33 @@ There are several environment variables defined by the module that are listed be \li QT_VIRTUALKEYBOARD_CANGJIE_DICTIONARY \li Overrides the location of the Cangjie dictionary. - The default location depends on the value of - \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. + By default, the dictionary is bundled into the plugin's resources. + + To disable resource bundling, add \c CONFIG+=no-bundle-tcime in the + plugin's qmake command line. In this scenario, the default location + depends on the value of \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. For example, for Qt libraries built from source, it could be \c {qtbase/qtvirtualkeyboard/tcime/dict_cangjie.dat}. \row \li QT_VIRTUALKEYBOARD_ZHUYIN_DICTIONARY \li Overrides the location of the Zhuyin dictionary. - The default location depends on the value of - \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. + By default, the dictionary is bundled into the plugin's resources. + + To disable resource bundling, add \c CONFIG+=no-bundle-tcime in the + plugin's qmake command line. In this scenario, the default location + depends on the value of \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. For example, for Qt libraries built from source, it could be \c {qtbase/qtvirtualkeyboard/tcime/dict_zhuyin.dat}. \row \li QT_VIRTUALKEYBOARD_PHRASE_DICTIONARY \li Overrides the location of the phrase dictionary. - The default location depends on the value of - \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. + By default, the dictionary is bundled into the plugin's resources. + + To disable resource bundling, add \c CONFIG+=no-bundle-tcime in the + plugin's qmake command line. In this scenario, the default location + depends on the value of \c {QLibraryInfo::location(QLibraryInfo::DataPath)}. For example, for Qt libraries built from source, it could be \c {qtbase/qtvirtualkeyboard/tcime/dict_phrases.dat}. \row diff --git a/src/virtualkeyboard/tcinputmethod.cpp b/src/virtualkeyboard/tcinputmethod.cpp index 6628ef7c..dce02157 100644 --- a/src/virtualkeyboard/tcinputmethod.cpp +++ b/src/virtualkeyboard/tcinputmethod.cpp @@ -42,6 +42,7 @@ #include "virtualkeyboarddebug.h" #include <QLibraryInfo> +#include <QFileInfo> namespace QtVirtualKeyboard { @@ -371,8 +372,11 @@ bool TCInputMethod::setInputMode(const QString &locale, InputEngine::InputMode i if (inputMode == InputEngine::Cangjie) { if (d->cangjieDictionary.isEmpty()) { QString cangjieDictionary(QString::fromLatin1(qgetenv("QT_VIRTUALKEYBOARD_CANGJIE_DICTIONARY").constData())); - if (cangjieDictionary.isEmpty()) - cangjieDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_cangjie.dat"; + if (!QFileInfo::exists(cangjieDictionary)) { + cangjieDictionary = QLatin1String(":///QtQuick/VirtualKeyboard/3rdparty/tcime/data/qt/dict_cangjie.dat"); + if (!QFileInfo::exists(cangjieDictionary)) + cangjieDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_cangjie.dat"; + } d->cangjieDictionary.load(cangjieDictionary); } d->wordDictionary = &d->cangjieDictionary; @@ -382,8 +386,11 @@ bool TCInputMethod::setInputMode(const QString &locale, InputEngine::InputMode i if (inputMode == InputEngine::Zhuyin) { if (d->zhuyinDictionary.isEmpty()) { QString zhuyinDictionary(QString::fromLatin1(qgetenv("QT_VIRTUALKEYBOARD_ZHUYIN_DICTIONARY").constData())); - if (zhuyinDictionary.isEmpty()) - zhuyinDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_zhuyin.dat"; + if (!QFileInfo::exists(zhuyinDictionary)) { + zhuyinDictionary = QLatin1String(":///QtQuick/VirtualKeyboard/3rdparty/tcime/data/qt/dict_zhuyin.dat"); + if (!QFileInfo::exists(zhuyinDictionary)) + zhuyinDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_zhuyin.dat"; + } d->zhuyinDictionary.load(zhuyinDictionary); } d->wordDictionary = &d->zhuyinDictionary; @@ -392,8 +399,11 @@ bool TCInputMethod::setInputMode(const QString &locale, InputEngine::InputMode i result = d->wordDictionary && !d->wordDictionary->isEmpty(); if (result && d->phraseDictionary.isEmpty()) { QString phraseDictionary(QString::fromLatin1(qgetenv("QT_VIRTUALKEYBOARD_PHRASE_DICTIONARY").constData())); - if (phraseDictionary.isEmpty()) - phraseDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_phrases.dat"; + if (!QFileInfo::exists(phraseDictionary)) { + phraseDictionary = QLatin1String(":///QtQuick/VirtualKeyboard/3rdparty/tcime/data/qt/dict_phrases.dat"); + if (!QFileInfo::exists(phraseDictionary)) + phraseDictionary = QLibraryInfo::location(QLibraryInfo::DataPath) + "/qtvirtualkeyboard/tcime/dict_phrases.dat"; + } d->phraseDictionary.load(phraseDictionary); } if (!result) diff --git a/src/virtualkeyboard/virtualkeyboard.pro b/src/virtualkeyboard/virtualkeyboard.pro index ece00047..3b4a2b96 100644 --- a/src/virtualkeyboard/virtualkeyboard.pro +++ b/src/virtualkeyboard/virtualkeyboard.pro @@ -359,15 +359,24 @@ tcime { cangjie: DEFINES += HAVE_TCIME_CANGJIE zhuyin: DEFINES += HAVE_TCIME_ZHUYIN QMAKE_USE += tcime - tcime_data.files = \ - $$PWD/3rdparty/tcime/data/qt/dict_phrases.dat - cangjie: tcime_data.files += \ - $$PWD/3rdparty/tcime/data/qt/dict_cangjie.dat - zhuyin: tcime_data.files += \ - $$PWD/3rdparty/tcime/data/qt/dict_zhuyin.dat - tcime_data.path = $$DATAPATH/tcime - INSTALLS += tcime_data - !prefix_build: COPIES += tcime_data + !no-bundle-tcime { + TCIME_FILES += 3rdparty/tcime/data/qt/dict_phrases.dat + cangjie: TCIME_FILES += \ + 3rdparty/tcime/data/qt/dict_cangjie.dat + zhuyin: TCIME_FILES += \ + 3rdparty/tcime/data/qt/dict_zhuyin.dat + RESOURCES += $$generate_resource(tcime.qrc, $$TCIME_FILES, /QtQuick/VirtualKeyboard) + } else { + tcime_data.files = \ + $$PWD/3rdparty/tcime/data/qt/dict_phrases.dat + cangjie: tcime_data.files += \ + $$PWD/3rdparty/tcime/data/qt/dict_cangjie.dat + zhuyin: tcime_data.files += \ + $$PWD/3rdparty/tcime/data/qt/dict_zhuyin.dat + tcime_data.path = $$DATAPATH/tcime + INSTALLS += tcime_data + !prefix_build: COPIES += tcime_data + } } hangul { |