diff options
Diffstat (limited to 'src/plugins/thai/plugin')
-rw-r--r-- | src/plugins/thai/plugin/plugin.pro | 47 | ||||
-rw-r--r-- | src/plugins/thai/plugin/thai.json | 6 | ||||
-rw-r--r-- | src/plugins/thai/plugin/thaiinputmethod.cpp | 94 | ||||
-rw-r--r-- | src/plugins/thai/plugin/thaiinputmethod_p.h | 65 | ||||
-rw-r--r-- | src/plugins/thai/plugin/thaiplugin.cpp | 43 | ||||
-rw-r--r-- | src/plugins/thai/plugin/thaiplugin.h | 49 |
6 files changed, 304 insertions, 0 deletions
diff --git a/src/plugins/thai/plugin/plugin.pro b/src/plugins/thai/plugin/plugin.pro new file mode 100644 index 00000000..81f05b4b --- /dev/null +++ b/src/plugins/thai/plugin/plugin.pro @@ -0,0 +1,47 @@ +TARGET = qtvirtualkeyboard_thai +QT += qml virtualkeyboard + +HEADERS += \ + thaiinputmethod_p.h \ + thaiplugin.h +SOURCES += \ + thaiinputmethod.cpp \ + thaiplugin.cpp +OTHER_FILES += \ + thai.json + +DEFINES += \ + QT_NO_CAST_TO_ASCII \ + QT_ASCII_CAST_WARNINGS \ + QT_NO_CAST_FROM_ASCII \ + QT_NO_CAST_FROM_BYTEARRAY + +include(../../../config.pri) + +!disable-hunspell { + QT += hunspellinputmethod-private +} + +LAYOUT_FILES += \ + $$LAYOUTS_BASE/content/layouts/th_TH/dialpad.fallback \ + $$LAYOUTS_BASE/content/layouts/th_TH/digits.fallback \ + $$LAYOUTS_BASE/content/layouts/th_TH/main.qml \ + $$LAYOUTS_BASE/content/layouts/th_TH/numbers.fallback \ + $$LAYOUTS_BASE/content/layouts/th_TH/symbols.qml + +OTHER_FILES += \ + $$LAYOUT_FILES + +virtualkeyboard_thai_layouts.files = $$LAYOUT_FILES +virtualkeyboard_thai_layouts.base = $$LAYOUTS_BASE +virtualkeyboard_thai_layouts.prefix = $$LAYOUTS_PREFIX +RESOURCES += virtualkeyboard_thai_layouts + +win32 { + QMAKE_TARGET_PRODUCT = "Qt Virtual Keyboard Thai (Qt $$QT_VERSION)" + QMAKE_TARGET_DESCRIPTION = "Virtual Keyboard Extension for Qt." +} + +PLUGIN_TYPE = virtualkeyboard +PLUGIN_CLASS_NAME = QtVirtualKeyboardThaiPlugin +load(qt_plugin) diff --git a/src/plugins/thai/plugin/thai.json b/src/plugins/thai/plugin/thai.json new file mode 100644 index 00000000..aac036cb --- /dev/null +++ b/src/plugins/thai/plugin/thai.json @@ -0,0 +1,6 @@ +{ + "Name": "thai", + "Provider": "Qt Thai Extension", + "InputMethod": "ThaiInputMethod", + "Version": 100 +} diff --git a/src/plugins/thai/plugin/thaiinputmethod.cpp b/src/plugins/thai/plugin/thaiinputmethod.cpp new file mode 100644 index 00000000..57dc8a67 --- /dev/null +++ b/src/plugins/thai/plugin/thaiinputmethod.cpp @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "thaiinputmethod_p.h" +#include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h> +#include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h> + +QT_BEGIN_NAMESPACE +namespace QtVirtualKeyboard { + +/*! + \class QtVirtualKeyboard::ThaiInputMethod + \internal +*/ + +ThaiInputMethod::ThaiInputMethod(QObject *parent) : + ThaiInputMethodBase(parent) +{ +} + +#ifndef QT_HUNSPELLINPUTMETHOD_LIB +QList<QVirtualKeyboardInputEngine::InputMode> ThaiInputMethod::inputModes( + const QString &locale) +{ + Q_UNUSED(locale) + return QList<QVirtualKeyboardInputEngine::InputMode>() << QVirtualKeyboardInputEngine::InputMode::Latin; +} + +bool ThaiInputMethod::setInputMode(const QString &locale, + QVirtualKeyboardInputEngine::InputMode inputMode) +{ + Q_UNUSED(locale) + Q_UNUSED(inputMode) + return true; +} + +bool ThaiInputMethod::setTextCase(QVirtualKeyboardInputEngine::TextCase textCase) +{ + Q_UNUSED(textCase) + return true; +} +#endif + +bool ThaiInputMethod::keyEvent(Qt::Key key, + const QString &text, + Qt::KeyboardModifiers modifiers) +{ + const bool isMark = text.length() == 2 && text.at(0) == QLatin1Char(' '); +#ifdef QT_HUNSPELLINPUTMETHOD_LIB + if (isMark) { + const QString mark(text.right(1)); + return ThaiInputMethodBase::keyEvent(static_cast<Qt::Key>(mark.at(0).unicode()), + mark, modifiers); + } + return ThaiInputMethodBase::keyEvent(key, text, modifiers); +#else + Q_UNUSED(key) + if (isMark) { + const QString mark(text.right(1)); + inputContext()->sendKeyClick(static_cast<Qt::Key>(mark.at(0).unicode()), mark, modifiers); + return true; + } + return false; +#endif +} + +} // namespace QtVirtualKeyboard +QT_END_NAMESPACE diff --git a/src/plugins/thai/plugin/thaiinputmethod_p.h b/src/plugins/thai/plugin/thaiinputmethod_p.h new file mode 100644 index 00000000..12ab5d3b --- /dev/null +++ b/src/plugins/thai/plugin/thaiinputmethod_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef THAIINPUTMETHOD_H +#define THAIINPUTMETHOD_H + +#ifdef QT_HUNSPELLINPUTMETHOD_LIB +#include <QtHunspellInputMethod/private/hunspellinputmethod_p.h> +#define ThaiInputMethodBase HunspellInputMethod +#else +#include <QtVirtualKeyboard/qvirtualkeyboardabstractinputmethod.h> +#define ThaiInputMethodBase QVirtualKeyboardAbstractInputMethod +#endif + +QT_BEGIN_NAMESPACE +namespace QtVirtualKeyboard { + +class ThaiInputMethodPrivate; + +class ThaiInputMethod : public ThaiInputMethodBase +{ + Q_OBJECT + Q_DECLARE_PRIVATE(ThaiInputMethod) +public: + explicit ThaiInputMethod(QObject *parent = nullptr); + +#ifndef QT_HUNSPELLINPUTMETHOD_LIB + QList<QVirtualKeyboardInputEngine::InputMode> inputModes(const QString &locale); + bool setInputMode(const QString &locale, QVirtualKeyboardInputEngine::InputMode inputMode); + bool setTextCase(QVirtualKeyboardInputEngine::TextCase textCase); +#endif + + bool keyEvent(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers); +}; + +} // namespace QtVirtualKeyboard +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/thai/plugin/thaiplugin.cpp b/src/plugins/thai/plugin/thaiplugin.cpp new file mode 100644 index 00000000..1f9428fc --- /dev/null +++ b/src/plugins/thai/plugin/thaiplugin.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "thaiplugin.h" +#include "thaiinputmethod_p.h" +#include <QtQml> + +QT_BEGIN_NAMESPACE + +using namespace QtVirtualKeyboard; + +void QtVirtualKeyboardThaiPlugin::registerTypes(const char *uri) const +{ + qmlRegisterType<ThaiInputMethod>(uri, 2, 3, "ThaiInputMethod"); +} + +QT_END_NAMESPACE diff --git a/src/plugins/thai/plugin/thaiplugin.h b/src/plugins/thai/plugin/thaiplugin.h new file mode 100644 index 00000000..d3ab2728 --- /dev/null +++ b/src/plugins/thai/plugin/thaiplugin.h @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef THAIPLUGIN_H +#define THAIPLUGIN_H + +#include <QVirtualKeyboardExtensionPlugin> + +QT_BEGIN_NAMESPACE + +class QtVirtualKeyboardThaiPlugin : public QVirtualKeyboardExtensionPlugin +{ + Q_OBJECT + Q_INTERFACES(QVirtualKeyboardExtensionPlugin) + Q_PLUGIN_METADATA(IID QVirtualKeyboardExtensionPluginFactoryInterface_iid + FILE "thai.json") +public: + void registerTypes(const char *uri) const; +}; + +QT_END_NAMESPACE + +#endif |