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 | |
8 | QT_BEGIN_NAMESPACE |
9 | namespace QtVirtualKeyboard { |
10 | |
11 | /*! |
12 | \class QtVirtualKeyboard::ThaiInputMethod |
13 | \internal |
14 | */ |
15 | |
16 | ThaiInputMethod::ThaiInputMethod(QObject *parent) : |
17 | ThaiInputMethodBase(parent) |
18 | { |
19 | } |
20 | |
21 | #ifndef QT_HUNSPELLINPUTMETHOD_LIB |
22 | QList<QVirtualKeyboardInputEngine::InputMode> ThaiInputMethod::inputModes( |
23 | const QString &locale) |
24 | { |
25 | Q_UNUSED(locale); |
26 | return QList<QVirtualKeyboardInputEngine::InputMode>() << QVirtualKeyboardInputEngine::InputMode::Latin; |
27 | } |
28 | |
29 | bool ThaiInputMethod::setInputMode(const QString &locale, |
30 | QVirtualKeyboardInputEngine::InputMode inputMode) |
31 | { |
32 | Q_UNUSED(locale); |
33 | Q_UNUSED(inputMode); |
34 | return true; |
35 | } |
36 | |
37 | bool ThaiInputMethod::setTextCase(QVirtualKeyboardInputEngine::TextCase textCase) |
38 | { |
39 | Q_UNUSED(textCase); |
40 | return true; |
41 | } |
42 | #endif |
43 | |
44 | bool 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 |
68 | QT_END_NAMESPACE |
69 |