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 <qohosinternalwindowid_p.h>
12#include <qohosplugincore.h>
13#include <string>
14
16
17enum class QXComponentType {
20};
21
22template<QXComponentType Type>
24{
25public:
26 explicit QXComponent(::OH_NativeXComponent *xc);
27
28 QXComponent(const QXComponent &) = default;
29 QXComponent &operator=(const QXComponent &) = default;
30
31 QXComponent(QXComponent &&) = default;
33
34 bool operator==(const QXComponent<Type> &other) const;
35 bool operator<(const QXComponent<Type> &other) const;
36
38
39private:
40 ::OH_NativeXComponent *m_XComponent;
41};
42
45
47{
48public:
56
57 QXComponentId(const QXComponentId &other) = default;
58 QXComponentId &operator=(const QXComponentId &other) = default;
59
60 QXComponentId(QXComponentId &&other) = default;
61 QXComponentId &operator=(QXComponentId &&other) = default;
62
63 bool operator==(const QXComponentId &other) const;
64 bool operator!=(const QXComponentId &other) const;
65 bool operator<(const QXComponentId &other) const;
66
67 static QXComponentId createForNativeNodeMainWindow(const std::string &qAbilityInstanceId);
68 static QXComponentId createForNativeNodeSubWindow(QtOhos::InternalWindowId windowId);
69 static QXComponentId createForRenderXComponent(QtOhos::InternalWindowId windowId);
70 static QXComponentId createForNativeNodeFloatWindow(QtOhos::InternalWindowId windowId);
71
72 static QOhosOptional<QXComponentId> tryCreateFromXComponent(::OH_NativeXComponent *xComponent);
73
74 std::string stringId() const;
75 QNapi::Value toNapiValue(napi_env env) const;
76
78
79private:
80 QXComponentId(std::string id);
81
82 std::string m_id;
83 QOhosOptional<RecognizedType> m_optRecognizedType;
84};
85
86template<QXComponentType Type>
87QXComponent<Type>::QXComponent(::OH_NativeXComponent *xc) : m_XComponent(xc)
88{
89 if (xc == nullptr)
90 qOhosReportFatalErrorAndAbort("::OH_NativeXComponent was null");
91}
92
93template<QXComponentType Type>
94bool QXComponent<Type>::operator==(const QXComponent<Type> &other) const
95{
96 return m_XComponent == other.m_XComponent;
97}
98
99template<QXComponentType Type>
100bool QXComponent<Type>::operator<(const QXComponent<Type> &other) const
101{
102 return m_XComponent < other.m_XComponent;
103}
104
105template<QXComponentType Type>
107{
108 return m_XComponent;
109}
110
111QT_END_NAMESPACE
112
113#endif
static std::unique_ptr< Node > takeOwnershipOfExternalNode(::ArkUI_NodeHandle nodeHandle)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, bool value)
static std::unique_ptr< Node > createOrFail(::ArkUI_NodeType type)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, std::uint32_t value)
void setAttributeOrFail(::ArkUI_NodeAttributeType attributeType, std::int32_t value)
static QOhosOptional<::ArkUI_NodeHandle > tryfindChild(::ArkUI_NodeHandle nodeHandle, const std::function< bool(::ArkUI_NodeHandle)> predicate)
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
Node & operator=(const Node &)=delete
void removeChildOrFail(Node &child)
static bool isQtManagedNode(::ArkUI_NodeHandle nodeHandle)
void setLengthMetricUnitOrFail(::ArkUI_LengthMetricUnit unit)
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)
void setDragEventsHandler(QOhosConsumer<::ArkUI_NodeEventType, ::ArkUI_DragEvent * > dragEventsHandler)
void setMouseEventsHandler(QOhosConsumer<::ArkUI_UIInputEvent * > mouseEventsHandler)
QEmbeddedWindowNode & operator=(const QEmbeddedWindowNode &)=delete
void setGesturesHandler(QOhosConsumer< const NativeGestureInfo & > gesturesHandler)
void setSizeParentFillPercentageNormalized(const QSizeF &size)
void setZIndex(std::int32_t index)
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
QEmbeddedWindowNode(QEmbeddedWindowNode &&)=delete
void setPosition(const QPointF &position)
void setHoverEventsHandler(QOhosConsumer<::ArkUI_UIInputEvent * > hoverEventsHandler)
QEmbeddedWindowNode & operator=(QEmbeddedWindowNode &&)=delete
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
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
void addGeneralEntry(const std::string &typeId, std::uint8_t *buff, std::uint32_t buffSize)
QOhosUdmfRecord & operator=(QOhosUdmfRecord &&)=default
QOhosUdmfRecord(const QOhosUdmfRecord &)=delete
bool isEmpty() const
QOhosOptional< QSpan< std::uint8_t > > tryGetGeneralEntry(const std::string &typeId)
QOhosUdsObject< T > getEntry()
Definition qohosudmf.h:144
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)
QXComponentId & operator=(QXComponentId &&other)=default
std::string stringId() const
static QXComponentId createForNativeNodeSubWindow(QtOhos::InternalWindowId windowId)
static QXComponentId createForRenderXComponent(QtOhos::InternalWindowId windowId)
QOhosOptional< RecognizedType > recognizedType() const
static QOhosOptional< QXComponentId > tryCreateFromXComponent(::OH_NativeXComponent *xComponent)
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)
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:87
bool operator==(const QXComponent< Type > &other) const
Definition qxcomponent.h:94
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()
QT_BEGIN_NAMESPACE QOhosOptional<::PIXEL_FORMAT > tryMapQtPixelFormatToOhosPixelFormat(QImage::Format format)
QNapi::Object createNapiPixelMapFromQImage(QtOhos::JsState &jsState, const QImage &image)
std::shared_ptr<::OH_PixelmapNative > makeEmptyNativePixelMap()
QImage createQImageFromNativePixelMap(::OH_PixelmapNative *pixelMap)
std::shared_ptr<::OH_PixelmapNative > wrapNativePixelMapPtr(::OH_PixelmapNative *pixelMap)
QT_BEGIN_NAMESPACE std::shared_ptr<::OH_PixelmapNative > createNativePixelMapFromQImage(QImage qImage)
QXComponentType
Definition qxcomponent.h:17
QXComponent< QXComponentType::Render > QXComponentRender
Definition qxcomponent.h:43
QXComponent< QXComponentType::Node > QXComponentNode
Definition qxcomponent.h:44
::ArkUI_GestureEvent * event
static constexpr const char * udmfMetaId
static QArkUi::CZString getDefaultContent()