1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef SHADOWINPUTCONTEXT_P_H
5#define SHADOWINPUTCONTEXT_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 <QObject>
19#include <QPointer>
20#include <QMetaType>
21#include <QRectF>
22#include <QtQml/qqml.h>
23#include <QtVirtualKeyboard/qvirtualkeyboard_global.h>
24#include <QtCore/private/qglobal_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class QVirtualKeyboardInputContext;
29class QVirtualKeyboardInputContextPrivate;
30
31namespace QtVirtualKeyboard {
32
33class ShadowInputContextPrivate;
34
35class Q_VIRTUALKEYBOARD_EXPORT ShadowInputContext : public QObject
36{
37 Q_OBJECT
38 Q_DISABLE_COPY(ShadowInputContext)
39 Q_DECLARE_PRIVATE(ShadowInputContext)
40 Q_PROPERTY(QObject *inputItem READ inputItem WRITE setInputItem NOTIFY inputItemChanged)
41 Q_PROPERTY(QRectF anchorRectangle READ anchorRectangle NOTIFY anchorRectangleChanged)
42 Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
43 Q_PROPERTY(bool anchorRectIntersectsClipRect READ anchorRectIntersectsClipRect NOTIFY anchorRectIntersectsClipRectChanged)
44 Q_PROPERTY(bool cursorRectIntersectsClipRect READ cursorRectIntersectsClipRect NOTIFY cursorRectIntersectsClipRectChanged)
45 Q_PROPERTY(bool selectionControlVisible READ selectionControlVisible NOTIFY selectionControlVisibleChanged)
46 QML_NAMED_ELEMENT(ShadowInputContext)
47 QML_UNCREATABLE("ShadowInputContext is only available via InputContext.priv.shadow")
48
49 explicit ShadowInputContext(QObject *parent = nullptr);
50
51 void setInputContext(QVirtualKeyboardInputContext *inputContext);
52
53public:
54 QObject *inputItem() const;
55 void setInputItem(QObject *inputItem);
56 QRectF anchorRectangle() const;
57 QRectF cursorRectangle() const;
58 bool anchorRectIntersectsClipRect() const;
59 bool cursorRectIntersectsClipRect() const;
60 bool selectionControlVisible() const;
61
62 Q_INVOKABLE void setSelectionOnFocusObject(const QPointF &anchorPos, const QPointF &cursorPos);
63 Q_INVOKABLE void updateSelectionProperties();
64
65signals:
66 void inputItemChanged();
67 void anchorRectangleChanged();
68 void cursorRectangleChanged();
69 void anchorRectIntersectsClipRectChanged();
70 void cursorRectIntersectsClipRectChanged();
71 void selectionControlVisibleChanged();
72
73private:
74 void update(Qt::InputMethodQueries queries);
75 QVariant queryFocusObject(Qt::InputMethodQuery query, QVariant argument);
76
77private:
78 friend class ::QVirtualKeyboardInputContextPrivate;
79 friend class ::QVirtualKeyboardInputContext;
80};
81
82} // namespace QtVirtualKeyboard
83QT_END_NAMESPACE
84
85#endif // SHADOWINPUTCONTEXT_P_H
86

source code of qtvirtualkeyboard/src/virtualkeyboard/shadowinputcontext_p.h