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
qohosudsobject.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 QOHOSUDSOBJECT_H
5#define QOHOSUDSOBJECT_H
6
7#include <QtGui/private/qohosimageconversions_p.h>
8#include <database/udmf/udmf_meta.h>
9#include <database/udmf/uds.h>
10#include <multimedia/image_framework/image/pixelmap_native.h>
11#include <qarkui/qarkuiutils.h>
12#include <qohosutils.h>
13
15
16template<typename T>
17struct QOhosUdsMeta
18{
19};
20
21template<>
23{
25
26 static constexpr const char *udmfMetaId = UDMF_META_PLAIN_TEXT;
27
29 {
30 return "";
31 }
32};
33
34template<>
35struct QOhosUdsMeta<::OH_UdsHtml>
36{
37 using Content = QArkUi::CZString;
38
39 static constexpr const char *udmfMetaId = UDMF_META_HTML;
40
41 static QArkUi::CZString getDefaultContent()
42 {
43 return "";
44 }
45};
46
47template<>
48struct QOhosUdsMeta<::OH_UdsFileUri>
49{
50 using Content = QArkUi::CZString;
51
52 static constexpr const char *udmfMetaId = UDMF_META_GENERAL_FILE_URI;
53
54 static QArkUi::CZString getDefaultContent()
55 {
56 return "";
57 }
58};
59
60template<>
61struct QOhosUdsMeta<::OH_UdsHyperlink>
62{
63 using Content = QArkUi::CZString;
64
65 static constexpr const char *udmfMetaId = UDMF_META_HYPERLINK;
66
67 static QArkUi::CZString getDefaultContent()
68 {
69 return "";
70 }
71};
72
73template<>
74struct QOhosUdsMeta<::OH_UdsPixelMap>
75{
76 using Content = std::shared_ptr<::OH_PixelmapNative>;
77
78 static constexpr const char *udmfMetaId = UDMF_META_OPENHARMONY_PIXEL_MAP;
79
80 static std::shared_ptr<::OH_PixelmapNative> getDefaultContent()
81 {
82 return makeEmptyOhosNativePixelMap();
83 }
84};
85
86template<typename T>
88{
89public:
92
93 QOhosUdsObject(const QOhosUdsObject<T> &) = delete;
94 QOhosUdsObject<T> &operator=(const QOhosUdsObject<T> &) = delete;
96 QOhosUdsObject<T> &operator=(QOhosUdsObject<T> &&) = default;
97
98 T *release() &&;
99 T *data();
100
101 typename QOhosUdsMeta<T>::Content getContent();
102
103private:
104 std::unique_ptr<T, void (*)(T *)> m_data;
105};
106
108
109template<typename T>
111{
112};
113
114template<>
123
124template<>
126{
127 static auto createFunc() { return Q_OHOS_NAMED_FUNC(::OH_UdsHtml_Create); }
131 static auto getEmptyContent() { return ""; }
132};
133
134template<>
143
144template<>
153
154template<>
161
162template<typename T>
163std::unique_ptr<T, void (*)(T *)> createUds()
164{
165 return {
166 QArkUi::callArkUiOrFailOnNullResult(
167 details_qohosudsobject_h::UdsMeta<T>::createFunc()),
168 [](T *data) {
169 QArkUi::callArkUi(
170 details_qohosudsobject_h::UdsMeta<T>::destroyFunc(),
171 data);
172 }
173 };
174}
175
176}
177
178template<typename T>
183
184template<typename T>
186 : m_data(details_qohosudsobject_h::createUds<T>())
187{
188 QArkUi::callArkUiOrFailOnErrorResult(
189 details_qohosudsobject_h::UdsMeta<T>::contentSetterFunc(),
190 m_data.get(), content);
191}
192
193template<>
194QOhosUdsObject<::OH_UdsPixelMap>::QOhosUdsObject(
195 typename QOhosUdsMeta<::OH_UdsPixelMap>::Content content);
196
197template<>
198QOhosUdsObject<::OH_UdsFileUri>::QOhosUdsObject(
199 typename QOhosUdsMeta<::OH_UdsFileUri>::Content content);
200
201template<typename T>
203{
204 return m_data.release();
205}
206
207template<typename T>
209{
210 return m_data.get();
211}
212
213template<typename T>
214typename QOhosUdsMeta<T>::Content QOhosUdsObject<T>::getContent()
215{
216 using namespace details_qohosudsobject_h;
217
218 auto *contentPtr = QArkUi::callArkUi(
219 UdsMeta<T>::getNullableContentFunc(),
220 m_data.get());
221 return contentPtr != nullptr ? contentPtr : UdsMeta<T>::getEmptyContent();
222}
223
224template<>
225typename QOhosUdsMeta<::OH_UdsPixelMap>::Content QOhosUdsObject<::OH_UdsPixelMap>::getContent();
226
227QT_END_NAMESPACE
228
229#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:135
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:143
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)
Combined button and popup list for selecting options.
std::unique_ptr< T, void(*)(T *)> createUds()
QXComponent< QXComponentType::Node > QXComponentNode
Definition qxcomponent.h:45
::ArkUI_GestureEvent * event
static constexpr const char * udmfMetaId
static QArkUi::CZString getDefaultContent()