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
qxcomponent.h
Go to the documentation of this file.
1// Copyright (C) 2025 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
4#ifndef QXCOMPONENT_H
5#define QXCOMPONENT_H
6
7#include <QtCore/QtGlobal>
8#include <QtCore/private/qnapi_p.h>
9#include <QtCore/private/qohoscommon_p.h>
10#include <ace/xcomponent/native_interface_xcomponent.h>
11#include <optional>
12#include <qohosinternalwindowid_p.h>
13#include <qohosplugincore.h>
14#include <string>
15
17
18enum class QXComponentType {
21};
22
23template<QXComponentType Type>
25{
26public:
27 explicit QXComponent(::OH_NativeXComponent *xc);
28
29 QXComponent(const QXComponent &) = default;
30 QXComponent &operator=(const QXComponent &) = default;
31
32 QXComponent(QXComponent &&) = default;
34
35 bool operator==(const QXComponent<Type> &other) const;
36 bool operator<(const QXComponent<Type> &other) const;
37
39
40private:
41 ::OH_NativeXComponent *m_XComponent;
42};
43
46
48{
49public:
57
58 QXComponentId(const QXComponentId &other) = default;
59 QXComponentId &operator=(const QXComponentId &other) = default;
60
61 QXComponentId(QXComponentId &&other) = default;
62 QXComponentId &operator=(QXComponentId &&other) = default;
63
64 bool operator==(const QXComponentId &other) const;
65 bool operator!=(const QXComponentId &other) const;
66 bool operator<(const QXComponentId &other) const;
67
68 static QXComponentId createForNativeNodeMainWindow(const std::string &qAbilityInstanceId);
69 static QXComponentId createForNativeNodeSubWindow(QtOhos::InternalWindowId windowId);
70 static QXComponentId createForRenderXComponent(QtOhos::InternalWindowId windowId);
71 static QXComponentId createForNativeNodeFloatWindow(QtOhos::InternalWindowId windowId);
72
73 static std::optional<QXComponentId> tryCreateFromXComponent(::OH_NativeXComponent *xComponent);
74
75 std::string stringId() const;
76 QNapi::Value toNapiValue(napi_env env) const;
77
78 std::optional<RecognizedType> recognizedType() const;
79
80private:
81 QXComponentId(std::string id);
82
83 std::string m_id;
84 std::optional<RecognizedType> m_optRecognizedType;
85};
86
87template<QXComponentType Type>
88QXComponent<Type>::QXComponent(::OH_NativeXComponent *xc) : m_XComponent(xc)
89{
90 if (xc == nullptr)
91 qOhosReportFatalErrorAndAbort("::OH_NativeXComponent was null");
92}
93
94template<QXComponentType Type>
95bool QXComponent<Type>::operator==(const QXComponent<Type> &other) const
96{
97 return m_XComponent == other.m_XComponent;
98}
99
100template<QXComponentType Type>
101bool QXComponent<Type>::operator<(const QXComponent<Type> &other) const
102{
103 return m_XComponent < other.m_XComponent;
104}
105
106template<QXComponentType Type>
108{
109 return m_XComponent;
110}
111
112QT_END_NAMESPACE
113
114#endif
std::uint32_t siblingsCount() const
static std::unique_ptr< Node > takeOwnershipOfExternalNode(::ArkUI_NodeHandle nodeHandle)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, bool value)
static QPoint nodeGlobalPosition(::ArkUI_NodeHandle nodeHandle)
static std::unique_ptr< Node > createOrFail(::ArkUI_NodeType type)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, std::uint32_t value)
bool hasParent() const
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, std::int32_t value)
void moveTo(std::uint32_t index)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, const std::array< std::uint32_t, N > &value)
Node & operator=(Node &&)=delete
T getAttributeOrFail(::ArkUI_NodeAttributeType attributeType) const
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, const std::array< float, N > &value)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, const std::string &value)
void setEventHandler(::ArkUI_NodeEventType eventType, std::function< void(::ArkUI_NodeEvent *)> eventHandler)
Node(Node &&)=delete
::ArkUI_NodeHandle handle() const
Node(const Node &)=delete
static std::optional<::ArkUI_NodeHandle > tryfindChild(::ArkUI_NodeHandle nodeHandle, const std::function< bool(::ArkUI_NodeHandle)> predicate)
Node & operator=(const Node &)=delete
void removeChildOrFail(Node &child)
static bool isQtManagedNode(::ArkUI_NodeHandle nodeHandle)
void setLengthMetricUnitOrFail(::ArkUI_LengthMetricUnit unit)
static QPoint nodeDisplayPosition(::ArkUI_NodeHandle nodeHandle)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, const std::array< std::int32_t, N > &value)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, float value)
void addChildOrFail(Node &child)
std::int32_t getAttributeOrFail(::ArkUI_NodeAttributeType attributeType) const
ParentDescriptor(ParentDescriptor &&)=default
ParentDescriptor(std::shared_ptr< QXComponentNode > node)
ParentDescriptor & operator=(ParentDescriptor &&)=default
std::shared_ptr< QXComponentNode > xComponentNodeOrNull() const
std::shared_ptr< QEmbeddedWindowNode > embeddedWindowNodeOrNull() const
ParentDescriptor & operator=(const ParentDescriptor &)=default
ParentDescriptor(const ParentDescriptor &)=default
bool operator==(const ParentDescriptor &) const
void setHitTestMode(::ArkUI_HitTestMode hitTestMode)
QEmbeddedWindowNode & operator=(const QEmbeddedWindowNode &)=delete
void setHoverEventsHandler(QOhosConsumer< NativeNodeHoverEvent > hoverEventsHandler)
void setGesturesHandler(QOhosConsumer< const NativeGestureInfo & > gesturesHandler)
void setSizeParentFillPercentageNormalized(const QSizeF &size)
void setAxisEventsHandler(QOhosConsumer<::ArkUI_UIInputEvent * > axisEventsHandler)
void setParentOrReparent(ParentDescriptor parent)
void setKeyEventsHandler(QOhosConsumer<::ArkUI_UIInputEvent * > keyEventsHandler)
QEmbeddedWindowNode(std::unique_ptr< Node > stack, std::unique_ptr< Node > contentNode, std::unique_ptr< QtOhos::WindowIdStruct > windowId)
QEmbeddedWindowNode(const QEmbeddedWindowNode &)=delete
std::shared_ptr< void > startDrag(std::vector< std::shared_ptr<::OH_PixelmapNative > > pixelMaps, const QPointF &hotspot, QOhosUdmfData udmfData, std::function< void(::ArkUI_DragAndDropInfo *)> statusListener)
static const std::int32_t minimumNodeZIndexValue
void setSize(const QSizeF &size)
void setBackgroundColor(const QColor &color)
void handleGestureEvent(const NativeGestureInfo &nativeGestureInfo) const
void setDragEventsHandler(QOhosConsumer<::ArkUI_NodeEvent * > dragEventsHandler)
QEmbeddedWindowNode(QEmbeddedWindowNode &&)=delete
void setPosition(const QPointF &position)
void setCoastingAxisEventsHandler(QOhosConsumer<::ArkUI_UIInputEvent * > coastingAxisEventsHandler)
void setMouseEventsHandler(QOhosConsumer< NativeNodeMouseEvent > mouseEventsHandler)
QEmbeddedWindowNode & operator=(QEmbeddedWindowNode &&)=delete
static QOhosUdmfData takeOwnership(::OH_UdmfData *nativePtr)
QOhosUdmfData(QOhosUdmfData &&)=default
QOhosUdmfData(const QOhosUdmfData &)=delete
QOhosUdmfData & operator=(const QOhosUdmfData &)=delete
::OH_UdmfData * nativePtr()
std::vector< QOhosUdmfRecord > getRecords()
QOhosUdmfData & operator=(QOhosUdmfData &&)=default
void addRecord(QOhosUdmfRecord &&record)
::OH_UdmfData * release() &&
std::vector< std::string > getTypes() const
void addEntry(QOhosUdsObject< T > udsObject)
Definition qohosudmf.h:136
QOhosUdmfRecord(QOhosUdmfRecord &&)=default
std::optional< QSpan< const std::uint8_t > > tryGetGeneralEntry(const std::string &typeId) const
QOhosUdmfRecord & operator=(QOhosUdmfRecord &&)=default
QOhosUdmfRecord(const QOhosUdmfRecord &)=delete
QOhosUdsObject< T > getEntry() const
Definition qohosudmf.h:144
void addGeneralEntry(const std::string &typeId, QSpan< const std::uint8_t > buffer)
bool isEmpty() const
QOhosUdmfRecord & operator=(const QOhosUdmfRecord &)=delete
std::vector< std::string > getTypes() const
Definition qohosudmf.cpp:80
void setProviderForDataFetchFunc(std::vector< std::string > typeIds, std::function< void *(const char *)> dataFetchFunc)
QOhosUdsObject(QOhosUdsObject< T > &&)=default
QOhosUdsObject(const QOhosUdsObject< T > &)=delete
QOhosUdsObject< T > & operator=(QOhosUdsObject< T > &&)=default
QOhosUdsObject< T > & operator=(const QOhosUdsObject< T > &)=delete
QOhosUdsObject(typename QOhosUdsMeta< T >::Content content)
static QXComponentId createForNativeNodeMainWindow(const std::string &qAbilityInstanceId)
static std::optional< QXComponentId > tryCreateFromXComponent(::OH_NativeXComponent *xComponent)
QXComponentId & operator=(QXComponentId &&other)=default
std::string stringId() const
static QXComponentId createForNativeNodeSubWindow(QtOhos::InternalWindowId windowId)
static QXComponentId createForRenderXComponent(QtOhos::InternalWindowId windowId)
QNapi::Value toNapiValue(napi_env env) const
bool operator!=(const QXComponentId &other) const
bool operator==(const QXComponentId &other) const
bool operator<(const QXComponentId &other) const
QXComponentId(QXComponentId &&other)=default
static QXComponentId createForNativeNodeFloatWindow(QtOhos::InternalWindowId windowId)
std::optional< RecognizedType > recognizedType() const
QXComponentId & operator=(const QXComponentId &other)=default
QXComponentId(const QXComponentId &other)=default
QXComponent & operator=(const QXComponent &)=default
bool operator<(const QXComponent< Type > &other) const
QXComponent & operator=(QXComponent &&)=default
QXComponent(::OH_NativeXComponent *xc)
Definition qxcomponent.h:88
bool operator==(const QXComponent< Type > &other) const
Definition qxcomponent.h:95
QXComponent(const QXComponent &)=default
QXComponent(QXComponent &&)=default
::OH_NativeXComponent * handle() const
Combined button and popup list for selecting options.
std::unique_ptr< T, void(*)(T *)> createUds()
QXComponentType
Definition qxcomponent.h:18
QXComponent< QXComponentType::Render > QXComponentRender
Definition qxcomponent.h:44
QXComponent< QXComponentType::Node > QXComponentNode
Definition qxcomponent.h:45
::ArkUI_GestureEvent * event
static constexpr const char * udmfMetaId
static QArkUi::CZString getDefaultContent()