aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2018-08-03 12:26:48 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2018-08-16 13:01:07 +0000
commit7e772c199257cf1c076c2b05b3e6fbf4cc142d01 (patch)
tree5a4ab1bf72d11ae6b4bf554c57878b4cd46803ca /src/plugins
parent396f60411d50c5a6c7905c722943a509e9db3fa9 (diff)
Add Thai keyboard layout
[ChangeLog] Added Thai keyboard layout Change-Id: Ie527524f110a02729e2c81fa97408a00464eda4f Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod_p.cpp2
-rw-r--r--src/plugins/plugins.pro1
-rw-r--r--src/plugins/thai/plugin/plugin.pro35
-rw-r--r--src/plugins/thai/plugin/thai.json6
-rw-r--r--src/plugins/thai/plugin/thaiinputmethod.cpp94
-rw-r--r--src/plugins/thai/plugin/thaiinputmethod_p.h65
-rw-r--r--src/plugins/thai/plugin/thaiplugin.cpp43
-rw-r--r--src/plugins/thai/plugin/thaiplugin.h49
-rw-r--r--src/plugins/thai/thai.pro4
9 files changed, 299 insertions, 0 deletions
diff --git a/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod_p.cpp b/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod_p.cpp
index 0120815a..3a6777b2 100644
--- a/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod_p.cpp
+++ b/src/plugins/hunspell/hunspellinputmethod/hunspellinputmethod_p.cpp
@@ -189,6 +189,8 @@ bool HunspellInputMethodPrivate::isValidInputChar(const QChar &c) const
return true;
if (isJoiner(c))
return true;
+ if (c.isMark())
+ return true;
return false;
}
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 4833416c..ce5a5cc1 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -13,3 +13,4 @@ pinyin: SUBDIRS += pinyin
t9write: SUBDIRS += t9write
tcime: SUBDIRS += tcime
myscript: SUBDIRS += myscript
+thai: SUBDIRS += thai
diff --git a/src/plugins/thai/plugin/plugin.pro b/src/plugins/thai/plugin/plugin.pro
new file mode 100644
index 00000000..3b690b18
--- /dev/null
+++ b/src/plugins/thai/plugin/plugin.pro
@@ -0,0 +1,35 @@
+TARGET = qtvirtualkeyboard_thai
+QT += qml virtualkeyboard
+
+HEADERS += \
+ thaiinputmethod_p.h \
+ thaiplugin.h
+SOURCES += \
+ thaiinputmethod.cpp \
+ thaiplugin.cpp
+OTHER_FILES += \
+ thai.json
+
+include(../../../config.pri)
+
+!disable-hunspell {
+ QT += hunspellinputmethod-private
+}
+
+LAYOUT_FILES += \
+ $$LAYOUTS_BASE/content/layouts/th_TH/main.qml \
+ $$LAYOUTS_BASE/content/layouts/th_TH/symbols.qml
+
+layouts.files = $$LAYOUT_FILES
+layouts.base = $$LAYOUTS_BASE
+layouts.prefix = $$LAYOUTS_PREFIX
+RESOURCES += 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 = ThaiPlugin
+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..0330d105
--- /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/inputengine.h>
+#include <QtVirtualKeyboard/inputcontext.h>
+
+QT_BEGIN_NAMESPACE
+namespace QtVirtualKeyboard {
+
+/*!
+ \class QtVirtualKeyboard::ThaiInputMethod
+ \internal
+*/
+
+ThaiInputMethod::ThaiInputMethod(QObject *parent) :
+ ThaiInputMethodBase(parent)
+{
+}
+
+#ifndef HAVE_HUNSPELL
+QList<InputEngine::InputMode> ThaiInputMethod::inputModes(
+ const QString &locale)
+{
+ Q_UNUSED(locale)
+ return QList<InputEngine::InputMode>() << InputEngine::Latin;
+}
+
+bool ThaiInputMethod::setInputMode(const QString &locale,
+ InputEngine::InputMode inputMode)
+{
+ Q_UNUSED(locale)
+ Q_UNUSED(inputMode)
+ return true;
+}
+
+bool ThaiInputMethod::setTextCase(InputEngine::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) == QChar(' ');
+#ifdef HAVE_HUNSPELL
+ 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..d59cfac6
--- /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 HAVE_HUNSPELL
+#include <QtHunspellInputMethod/private/hunspellinputmethod_p.h>
+#define ThaiInputMethodBase HunspellInputMethod
+#else
+#include <QtVirtualKeyboard/abstractinputmethod.h>
+#define ThaiInputMethodBase AbstractInputMethod
+#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 HAVE_HUNSPELL
+ QList<InputEngine::InputMode> inputModes(const QString &locale);
+ bool setInputMode(const QString &locale, InputEngine::InputMode inputMode);
+ bool setTextCase(InputEngine::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..7267c668
--- /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 ThaiPlugin::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..cd9a225a
--- /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 ThaiPlugin : 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
diff --git a/src/plugins/thai/thai.pro b/src/plugins/thai/thai.pro
new file mode 100644
index 00000000..b6e92972
--- /dev/null
+++ b/src/plugins/thai/thai.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+
+SUBDIRS += \
+ plugin