1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qvirtualkeyboardobserver.h"
5
6#include <QtCore/private/qobject_p.h>
7
8QT_BEGIN_NAMESPACE
9
10class QVirtualKeyboardObserverPrivate : public QObjectPrivate
11{
12public:
13 QVirtualKeyboardObserverPrivate()
14 {}
15
16 QVariant layout;
17};
18
19/*!
20 \qmltype KeyboardObserver
21 \instantiates QVirtualKeyboardObserver
22 \inqmlmodule QtQuick.VirtualKeyboard
23 \ingroup qtvirtualkeyboard-internal-qml
24 \brief Acts as a hub for keyboard event notifications.
25*/
26
27/*!
28 \class QVirtualKeyboardObserver
29 \inmodule QtVirtualKeyboard
30 \ingroup qtvirtualkeyboard-cpp-for-devs
31 \brief Acts as a hub for keyboard event notifications.
32*/
33
34QVirtualKeyboardObserver::QVirtualKeyboardObserver(QObject *parent) :
35 QObject(*new QVirtualKeyboardObserverPrivate, parent)
36{
37 connect(sender: this, signal: &QVirtualKeyboardObserver::layoutChanged, context: this, slot: &QVirtualKeyboardObserver::invalidateLayout);
38}
39
40/*!
41 \property QVirtualKeyboardObserver::layout
42 \brief The current keyboard layout expressed as a variant.
43*/
44/*!
45 \qmlproperty variant KeyboardObserver::layout
46 \readonly
47 \brief The current keyboard layout expressed as a variant.
48*/
49QVariant QVirtualKeyboardObserver::layout()
50{
51 Q_D(QVirtualKeyboardObserver);
52
53 if (d->layout.isNull())
54 QMetaObject::invokeMethod(obj: this, member: "scanLayout", Q_RETURN_ARG(QVariant, d->layout));
55
56 return d->layout;
57}
58
59void QVirtualKeyboardObserver::invalidateLayout()
60{
61 Q_D(QVirtualKeyboardObserver);
62 d->layout = QVariant();
63}
64
65QT_END_NAMESPACE
66

source code of qtvirtualkeyboard/src/virtualkeyboard/qvirtualkeyboardobserver.cpp