1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "thaiinputmethod_p.h"
5#include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h>
6#include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h>
7
8QT_BEGIN_NAMESPACE
9namespace QtVirtualKeyboard {
10
11/*!
12 \class QtVirtualKeyboard::ThaiInputMethod
13 \internal
14*/
15
16ThaiInputMethod::ThaiInputMethod(QObject *parent) :
17 ThaiInputMethodBase(parent)
18{
19}
20
21#ifndef QT_HUNSPELLINPUTMETHOD_LIB
22QList<QVirtualKeyboardInputEngine::InputMode> ThaiInputMethod::inputModes(
23 const QString &locale)
24{
25 Q_UNUSED(locale);
26 return QList<QVirtualKeyboardInputEngine::InputMode>() << QVirtualKeyboardInputEngine::InputMode::Latin;
27}
28
29bool ThaiInputMethod::setInputMode(const QString &locale,
30 QVirtualKeyboardInputEngine::InputMode inputMode)
31{
32 Q_UNUSED(locale);
33 Q_UNUSED(inputMode);
34 return true;
35}
36
37bool ThaiInputMethod::setTextCase(QVirtualKeyboardInputEngine::TextCase textCase)
38{
39 Q_UNUSED(textCase);
40 return true;
41}
42#endif
43
44bool ThaiInputMethod::keyEvent(Qt::Key key,
45 const QString &text,
46 Qt::KeyboardModifiers modifiers)
47{
48 const bool isMark = text.size() == 2 && text.at(i: 0) == QLatin1Char(' ');
49#ifdef QT_HUNSPELLINPUTMETHOD_LIB
50 if (isMark) {
51 const QString mark(text.right(1));
52 return ThaiInputMethodBase::keyEvent(static_cast<Qt::Key>(mark.at(0).unicode()),
53 mark, modifiers);
54 }
55 return ThaiInputMethodBase::keyEvent(key, text, modifiers);
56#else
57 Q_UNUSED(key);
58 if (isMark) {
59 const QString mark(text.right(n: 1));
60 inputContext()->sendKeyClick(key: static_cast<Qt::Key>(mark.at(i: 0).unicode()), text: mark, modifiers);
61 return true;
62 }
63 return false;
64#endif
65}
66
67} // namespace QtVirtualKeyboard
68QT_END_NAMESPACE
69

source code of qtvirtualkeyboard/src/plugins/thai/thaiinputmethod.cpp