Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
platforminputcontext_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef PLATFORMINPUTCONTEXT_P_H
5#define PLATFORMINPUTCONTEXT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qpa/qplatforminputcontext.h>
19#include <QtGui/QInputMethod>
20#include <QtCore/private/qglobal_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class PlatformInputContext : public QPlatformInputContext
25{
26public:
27 PlatformInputContext()
28 : m_visible(false), m_action(QInputMethod::Click), m_cursorPosition(0),
29 m_invokeActionCallCount(0), m_showInputPanelCallCount(0), m_hideInputPanelCallCount(0),
30 m_updateCallCount(0), m_direction(Qt::LeftToRight)
31 {
32 }
33
34 void showInputPanel() override
35 {
36 m_visible = true;
37 m_showInputPanelCallCount++;
38 }
39 void hideInputPanel() override
40 {
41 m_visible = false;
42 m_hideInputPanelCallCount++;
43 }
44 bool isInputPanelVisible() const override
45 {
46 return m_visible;
47 }
48 void invokeAction(QInputMethod::Action action, int cursorPosition) override
49 {
50 m_invokeActionCallCount++;
51 m_action = action;
52 m_cursorPosition = cursorPosition;
53 }
54 void update(Qt::InputMethodQueries) override
55 {
56 m_updateCallCount++;
57 }
58
59 QLocale locale() const override
60 {
61 if (m_direction == Qt::RightToLeft)
62 return QLocale(QLocale::Arabic);
63 else
64 return QLocale(QLocale::English);
65 }
66
67 Qt::LayoutDirection inputDirection() const override
68 {
69 return m_direction;
70 }
71
72 void setInputDirection(Qt::LayoutDirection direction) {
73 m_direction = direction;
74 emitLocaleChanged();
75 emitInputDirectionChanged(inputDirection());
76 }
77
78 void clear() {
79 m_cursorPosition = 0;
80 m_invokeActionCallCount = 0;
81 m_visible = false;
82 m_showInputPanelCallCount = 0;
83 m_hideInputPanelCallCount = 0;
84 m_updateCallCount = 0;
85 }
86
87 bool m_visible;
88 QInputMethod::Action m_action;
89 int m_cursorPosition;
90 int m_invokeActionCallCount;
91 int m_showInputPanelCallCount;
92 int m_hideInputPanelCallCount;
93 int m_updateCallCount;
94 Qt::LayoutDirection m_direction;
95};
96
97QT_END_NAMESPACE
98
99#endif // PLATFORMINPUTCONTEXT_P_H