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
qandroidviewsignalmanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QANDROIDVIEWSIGNALMANAGER_P_H
6#define QANDROIDVIEWSIGNALMANAGER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qhash.h>
20#include <QtCore/qjnitypes.h>
21#include <QtCore/qjniobject.h>
22#include <QtCore/qmap.h>
23#include <QtCore/qobject.h>
24#include <QtCore/qmutex.h>
25#include <QtQuick/qquickview.h>
26
27QT_BEGIN_NAMESPACE
28
29class QAndroidViewSignalManager : public QObject
30{
31 using connection_key_t = int;
32
33public:
34 explicit QAndroidViewSignalManager(QQuickView *view, QObject *parent = nullptr);
35
36 int qt_metacall(QMetaObject::Call call, int methodId, void **args) override;
37
38 void removeConnection(connection_key_t signalIdx);
39 bool addConnection(const QString &signalName,
40 const QJniArray<jclass> &argTypes,
41 const QJniObject &listener,
42 int id);
43
44private:
45 /*
46 This will store the necessary information to call the listener
47 when the signal is emitted, including the Java function name and
48 signature so that we can call it quickly without recalculating those.
49 */
50 struct ConnectionInfo
51 {
52 QMetaObject::Connection connection;
53 QJniObject listenerObject;
54 QString qmlSignalName;
55
56 QList<QMetaType::Type> qmlArgumentTypes;
57 bool isPropertySignal;
58 std::optional<int> qmlPropertyIndex; // Only filled if isPropertySignal
59 int connectionId;
60 };
61
62 struct QueuedConnectionInfo
63 {
64 connection_key_t id;
65 QString signalName;
66 QJniArray<jclass> argTypes;
67 QJniObject listener;
68 };
69
70 bool hasConnection(connection_key_t key) const;
71 connection_key_t createNewSignalKey() const;
72 void onViewStatusChanged(QQuickView::Status status);
73 bool queueConnection(const QString &signalName,
74 const QJniArray<jclass> &argTypes,
75 const QJniObject &listener,
76 int id);
77
78 QMap<connection_key_t, ConnectionInfo> m_connections;
79 QQuickView *m_view;
80 QList<QueuedConnectionInfo> m_queuedConnections;
81 QMutex m_queueMutex;
82};
83
85
86#endif // QANDROIDVIEWSIGNALMANAGER_P_H
QObject * parent
Definition qobject.h:74
The QQuickView class provides a window for displaying a Qt Quick user interface.
Definition qquickview.h:21
Combined button and popup list for selecting options.
QJniObject qVariantToQJniObject(const QVariant &data)
std::optional< int > propertyIndexForSignal(const QMetaMethod &signal, const QMetaObject &object)
QByteArray qmlSignalSignature(const QString &signalName, const QJniArray< jclass > &javaArgClasses)
QList< QMetaType::Type > metaMethodArgumentTypes(const QMetaMethod &method)
int indexOfSignal(const QMetaObject &metaObject, const QString &signalName, const QJniArray< jclass > &javaArgClasses)
QByteArray qmlTypeArgStringFromJavaTypeArgs(const QJniArray< jclass > &javaArgClasses)
QJniObject voidStarToQJniObject(const QMetaType::Type type, const void *data)