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